Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Commit 2e5bb3b

Browse files
committed
Merge branch 'dev' of https://github.com/SharePoint/PnP-PowerShell into dev
2 parents 45eb71c + f0c63ca commit 2e5bb3b

File tree

4 files changed

+46
-3
lines changed

4 files changed

+46
-3
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
1010
## [3.23.2007.0]
1111

1212
### Added
13-
- Added `-WithRightsAssignedDetailed` parameter to `Get-PnPUser` allowing for fine grained (broken) permissions on item, list and site level to be shown [PR #2754](https://github.com/pnp/PnP-PowerShell/pull/2754)
13+
- Added `-WithRightsAssignedDetailed` parameter to `Get-PnPUser` when used against SharePoint Online allowing for fine grained (broken) permissions on item, list and site level to be shown [PR #2754](https://github.com/pnp/PnP-PowerShell/pull/2754)
1414
- Added a `-RowLimit` parameter to `Clear-PnPRecycleBinItem` and `Restore-PnPRecycleBinItem` so that it can be used on recycle bins which hold more than 5000 items [PR #2760](https://github.com/pnp/PnP-PowerShell/pull/2760)
1515
- Added connection option to `Connect-PnPOnline` taking `-Scopes` and `-Credentials` to allow setting up a delegated permission token for use with Microsoft Graph and the Office 365 Management API. See [this wiki page](https://github.com/pnp/PnP-PowerShell/wiki/Connect-options#connect-using-scopes-and-credentials) for more details. [PR #2746](https://github.com/pnp/PnP-PowerShell/pull/2746)
1616
- Added support for enabling and disabling fields using `Set-PnPField -Identity FieldName -Values @{AllowDeletion=$false}` [PR #2766](https://github.com/pnp/PnP-PowerShell/pull/2766)
1717
- Added the following cmdlets to add/remove/clear owners and members of Microsoft 365 Groups: `Add-PnPMicrosoft365GroupMember`, `Add-PnPMicrosoft365GroupOwner`, `Remove-PnPMicrosoft365GroupMember`, `Remove-PnPMicrosoft365GroupOwner`, `Clear-PnPMicrosoft365GroupMember`, `Clear-PnPMicrosoft365GroupOwner` [PR #2750](https://github.com/pnp/PnP-PowerShell/pull/2750)
1818
- Added Add-PnPTeamsChannel, Add-PnPTeamsTab, Add-PnPTeamsUser, Get-PnPTeamsApp, Get-PnPTeamsChannel, Get-PnPTeamsChannelMessage, Get-PnPTeamsTab, Get-PnPTeamsTeam, Get-PnPTeamsUser, New-PnPTeamsApp, New-PnPTeamsTeam, Remove-PnPTeamsChannel, Remove-PnPTeamsTab, Remove-PnPTeamsTeam, Remove-PnPTeamsUser, Set-PnPTeamsChannel, Set-PnPTeamsTab, Set-PnPTeamsTeam, Set-PnPTeamsPicture, Submit-PnPTeamsChannelMessage, Update-PnPTeamsApp cmdlets
1919
- Added Get-PnPFileVersion, Remove-PnPFileVersion, Restore-PnPFileVersion cmdlets
20+
- Added `-HideFromAddressLists` and `-HideFromOutlookClients` to `Set-PnPUnifiedGroup` to allow for setting the visibility of Microsoft 365 Groups [PR #2717](https://github.com/pnp/PnP-PowerShell/pull/2717)
2021

2122
### Changed
2223
- Updated implementation of `Move-PnPFile` to now also support moving of files and folders accross site collections [PR #2749](https://github.com/pnp/PnP-PowerShell/pull/2749)

Commands/Files/CopyFile.cs

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace SharePointPnP.PowerShell.Commands.Files
1414
[Cmdlet(VerbsCommon.Copy, "PnPFile", SupportsShouldProcess = true)]
1515
[CmdletHelp("Copies a file or folder to a different location. This location can be within the same document library, same site, same site collection or even to another site collection on the same tenant. Currently there is a 200MB file size limit for the file or folder to be copied.",
1616
Category = CmdletHelpCategory.Files)]
17+
#if !ONPREMISES
1718
[CmdletExample(
1819
Remarks = "Copies a file named company.docx located in a document library called Shared Documents in the site collection project to the Shared Documents library in the site collection otherproject. If a file named company.docx already exists, it won't perform the copy.",
1920
Code = @"PS:>Copy-PnPFile -ServerRelativeUrl ""/sites/project/Shared Documents/company.docx"" -TargetServerRelativeLibrary ""/sites/otherproject/Shared Documents""",
@@ -22,6 +23,7 @@ namespace SharePointPnP.PowerShell.Commands.Files
2223
Remarks = "Copies a folder named Archive located in a document library called Shared Documents in the site collection project to the Shared Documents library in the site collection otherproject. If a folder named Archive already exists, it will overwrite it.",
2324
Code = @"PS:>Copy-PnPFile -ServerRelativeUrl ""/sites/project/Shared Documents/Archive"" -TargetServerRelativeLibrary ""/sites/otherproject/Shared Documents"" -OverwriteIfAlreadyExists",
2425
SortOrder = 2)]
26+
#endif
2527
[CmdletExample(
2628
Remarks = "Copies a file named company.docx located in a document library called Documents to a new document named company2.docx in the same library.",
2729
Code = @"PS:>Copy-PnPFile -SourceUrl Documents/company.docx -TargetUrl Documents/company2.docx",
@@ -75,7 +77,9 @@ public class CopyFile : PnPWebCmdlet
7577
public string SourceUrl = string.Empty;
7678

7779
[Parameter(Mandatory = true, Position = 1, HelpMessage = "Server relative Url where to copy the file or folder to. Must not include the file name.")]
80+
#if !ONPREMISES
7881
[Alias(nameof(MoveFile.TargetServerRelativeLibrary))] // Aliases is present to allow for switching between Move-PnPFile and Copy-PnPFile keeping the same parameters.
82+
#endif
7983
public string TargetUrl = string.Empty;
8084

8185
[Parameter(Mandatory = false, HelpMessage = "If provided, if a file already exists at the TargetUrl, it will be overwritten. If omitted, the copy operation will be canceled if the file already exists at the TargetUrl location.")]
@@ -113,14 +117,18 @@ protected override void ExecuteCmdlet()
113117

114118
if (Force || ShouldContinue(string.Format(Resources.CopyFile0To1, SourceUrl, TargetUrl), Resources.Confirm))
115119
{
120+
#if !ONPREMISES
116121
if (sourceWebUri != targetWebUri)
117122
{
118123
CopyToOtherSiteCollection(sourceUri, targetUri);
119124
}
120125
else
121126
{
127+
#endif
122128
CopyWithinSameSiteCollection(currentContextUri, sourceWebUri, targetWebUri);
129+
#if !ONPREMISES
123130
}
131+
#endif
124132
}
125133
}
126134

@@ -271,6 +279,7 @@ private void CopyWithinSameSiteCollection(Uri currentContextUri, Uri sourceWebUr
271279
}
272280
}
273281

282+
#if !ONPREMISES
274283
/// <summary>
275284
/// Allows copying to another site collection
276285
/// </summary>
@@ -284,6 +293,7 @@ private void CopyToOtherSiteCollection(Uri source, Uri destination)
284293
});
285294
ClientContext.ExecuteQueryRetry();
286295
}
296+
#endif
287297

288298
private void CopyFolder(Folder sourceFolder, Folder targetFolder)
289299
{

Commands/Graph/SetMicrosoft365Group.cs

+17-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ namespace SharePointPnP.PowerShell.Commands.Graph
3535
Code = @"PS:> Set-PnPMicrosoft365Group -Identity $group -Owners [email protected]",
3636
Remarks = "Sets [email protected] as owner of the group",
3737
SortOrder = 5)]
38+
[CmdletExample(
39+
Code = @"PS:> Set-PnPMicrosoft365Group -Identity $group -HideFromOutlookClients:$false",
40+
Remarks = "Ensures the provided group will be shown in Outlook clients",
41+
SortOrder = 6)]
3842
[CmdletRelatedLink(Text = "Documentation", Url = "https://docs.microsoft.com/graph/api/group-update")]
3943
[CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All)]
4044
public class SetMicrosoft365Group : PnPGraphCmdlet
@@ -63,6 +67,12 @@ public class SetMicrosoft365Group : PnPGraphCmdlet
6367
[Parameter(Mandatory = false, HelpMessage = "Creates a Microsoft Teams team associated with created group")]
6468
public SwitchParameter CreateTeam;
6569

70+
[Parameter(Mandatory = false, HelpMessage = "Hides the group from the Global Address List")]
71+
public bool? HideFromAddressLists;
72+
73+
[Parameter(Mandatory = false, HelpMessage = "Hides the group from Outlook Clients")]
74+
public bool? HideFromOutlookClients;
75+
6676
protected override void ExecuteCmdlet()
6777
{
6878
UnifiedGroupEntity group = null;
@@ -101,6 +111,12 @@ protected override void ExecuteCmdlet()
101111
groupLogo: groupLogoStream,
102112
isPrivate: isPrivateGroup,
103113
createTeam: CreateTeam);
114+
115+
if (ParameterSpecified(nameof(HideFromAddressLists)) || ParameterSpecified(nameof(HideFromOutlookClients)))
116+
{
117+
// For this scenario a separate call needs to be made
118+
UnifiedGroupsUtility.SetUnifiedGroupVisibility(group.GroupId, AccessToken, HideFromAddressLists, HideFromOutlookClients);
119+
}
104120
}
105121
catch(Exception e)
106122
{
@@ -115,4 +131,4 @@ protected override void ExecuteCmdlet()
115131
}
116132
}
117133
}
118-
#endif
134+
#endif

Commands/Principals/GetUser.cs

+17-1
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,30 @@ namespace SharePointPnP.PowerShell.Commands.Principals
4141
Code = @"PS:> Get-PnPUser -WithRightsAssigned -Web subsite1",
4242
Remarks = "Returns only those users from the User Information List of the current site collection who currently have any kind of access rights given either directly to the user or Active Directory Group or given to the user or Active Directory Group via membership of a SharePoint Group to subsite 'subsite1'",
4343
SortOrder = 6)]
44+
#if !ONPREMISES
4445
[CmdletExample(
4546
Code = @"PS:> Get-PnPUser -WithRightsAssignedDetailed",
4647
Remarks = "Returns all users who have been granted explicit access to the current site, lists and listitems",
4748
SortOrder = 7)]
49+
#endif
4850
public class GetUser : PnPWebCmdlet
4951
{
5052
private const string PARAMETERSET_IDENTITY = "Identity based request";
5153
private const string PARAMETERSET_WITHRIGHTSASSIGNED = "With rights assigned";
54+
#if !ONPREMISES
5255
private const string PARAMETERSET_WITHRIGHTSASSIGNEDDETAILED = "With rights assigned detailed";
56+
#endif
5357

5458
[Parameter(Mandatory = false, ValueFromPipeline = true, ParameterSetName = PARAMETERSET_IDENTITY, HelpMessage = "User ID or login name")]
5559
public UserPipeBind Identity;
5660

5761
[Parameter(Mandatory = false, ParameterSetName = PARAMETERSET_WITHRIGHTSASSIGNED, HelpMessage = "If provided, only users that currently have any kinds of access rights assigned to the current site collection will be returned. Otherwise all users, even those who previously had rights assigned, but not anymore at the moment, will be returned as the information is pulled from the User Information List. Only works if you don't provide an -Identity.")]
5862
public SwitchParameter WithRightsAssigned;
5963

64+
#if !ONPREMISES
6065
[Parameter(Mandatory = false, ParameterSetName = PARAMETERSET_WITHRIGHTSASSIGNEDDETAILED, HelpMessage = "If provided, only users that currently have any specific kind of access rights assigned to the current site, lists or listitems/documents will be returned. Otherwise all users, even those who previously had rights assigned, but not anymore at the moment, will be returned as the information is pulled from the User Information List. Only works if you don't provide an -Identity.")]
6166
public SwitchParameter WithRightsAssignedDetailed;
67+
#endif
6268

6369
/// <summary>
6470
/// Output type used with parameter WithRightsAssignedDetailed
@@ -103,7 +109,11 @@ protected override void ExecuteCmdlet()
103109

104110
List<DetailedUser> users = new List<DetailedUser>();
105111

106-
if (WithRightsAssigned || WithRightsAssignedDetailed)
112+
if (WithRightsAssigned
113+
#if !ONPREMISES
114+
|| WithRightsAssignedDetailed
115+
#endif
116+
)
107117
{
108118
// Get all the role assignments and role definition bindings to be able to see which users have been given rights directly on the site level
109119
SelectedWeb.Context.Load(SelectedWeb.RoleAssignments, ac => ac.Include(a => a.RoleDefinitionBindings, a => a.Member));
@@ -125,6 +135,7 @@ protected override void ExecuteCmdlet()
125135
allUsersWithPermissions.AddRange(usersWithDirectPermissions);
126136
allUsersWithPermissions.AddRange(usersWithGroupPermissions);
127137

138+
#if !ONPREMISES
128139
// Add the found users and add them to the custom object
129140
if (WithRightsAssignedDetailed)
130141
{
@@ -144,6 +155,7 @@ protected override void ExecuteCmdlet()
144155
}
145156
}
146157
else
158+
#endif
147159
{
148160
// Filter out the users that have been given rights at both places so they will only be returned once
149161
WriteObject(allUsersWithPermissions.GroupBy(u => u.Id).Select(u => u.First()), true);
@@ -155,6 +167,7 @@ protected override void ExecuteCmdlet()
155167
WriteObject(SelectedWeb.SiteUsers, true);
156168
}
157169

170+
#if !ONPREMISES
158171
if (WithRightsAssignedDetailed)
159172
{
160173
SelectedWeb.Context.Load(SelectedWeb.Lists, l => l.Include(li => li.ItemCount, li => li.IsSystemList, li=>li.IsCatalog, li => li.RootFolder.ServerRelativeUrl, li => li.RoleAssignments, li => li.Title, li => li.HasUniqueRoleAssignments));
@@ -310,6 +323,7 @@ protected override void ExecuteCmdlet()
310323
WriteObject(new { userInformation.Title, userInformation.LoginName, userInformation.Email, Groups, Permissions }, true);
311324
}
312325
}
326+
#endif
313327
}
314328
else
315329
{
@@ -335,6 +349,7 @@ protected override void ExecuteCmdlet()
335349
}
336350
}
337351

352+
#if !ONPREMISES
338353
private void WriteProgress(ProgressRecord record, string message, int step, int count)
339354
{
340355
var percentage = Convert.ToInt32((100 / Convert.ToDouble(count)) * Convert.ToDouble(step));
@@ -373,5 +388,6 @@ private static List<DetailedUser> GetPermissions(RoleAssignmentCollection roleAs
373388
}
374389
return users;
375390
}
391+
#endif
376392
}
377393
}

0 commit comments

Comments
 (0)