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

Commit b00812b

Browse files
Merge pull request #1320 from SharePoint/dev
January 2018 Release
2 parents 68f2ead + 35c6c6d commit b00812b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+949
-97
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#if !ONPREMISES
2+
using System.Linq;
3+
using System.Management.Automation;
4+
using Microsoft.Online.SharePoint.TenantAdministration;
5+
using Microsoft.SharePoint.Client;
6+
using SharePointPnP.PowerShell.CmdletHelpAttributes;
7+
using SharePointPnP.PowerShell.Commands.Base;
8+
using SharePointPnP.PowerShell.Commands.Enums;
9+
using System.Collections.Generic;
10+
using Newtonsoft.Json;
11+
using Newtonsoft.Json.Linq;
12+
13+
namespace SharePointPnP.PowerShell.Commands
14+
{
15+
[Cmdlet(VerbsCommon.Get, "PnPTenantAppCatalogUrl", SupportsShouldProcess = true)]
16+
[CmdletHelp(@"Retrieves the url of the tenant scoped app catalog.",
17+
Category = CmdletHelpCategory.TenantAdmin,
18+
SupportedPlatform = CmdletSupportedPlatform.Online)]
19+
[CmdletExample(Code = @"PS:> Get-PnPTenantAppCatalogUrl", Remarks = "Returns the url of the tenant scoped app catalog site collection", SortOrder = 1)]
20+
public class GetTenantAppCatalogUrl : PnPCmdlet
21+
{
22+
[Parameter(Mandatory = false, HelpMessage = "The key of the value to retrieve.")]
23+
public string Key;
24+
25+
protected override void ExecuteCmdlet()
26+
{
27+
var settings = Microsoft.SharePoint.Client.TenantSettings.GetCurrent(ClientContext);
28+
settings.EnsureProperties(s => s.CorporateCatalogUrl);
29+
WriteObject(settings.CorporateCatalogUrl);
30+
}
31+
}
32+
}
33+
#endif

Commands/Admin/RemoveTenantSite.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace SharePointPnP.PowerShell.Commands
1111
{
12-
[Cmdlet(VerbsCommon.Remove, "PnPTenantSite", ConfirmImpact = ConfirmImpact.High, SupportsShouldProcess = true)]
12+
[Cmdlet(VerbsCommon.Remove, "PnPTenantSite", ConfirmImpact = ConfirmImpact.High, SupportsShouldProcess = false)]
1313
[CmdletHelp("Removes a site collection",
1414
"Removes a site collection which is listed in your tenant administration site.",
1515
SupportedPlatform = CmdletSupportedPlatform.Online,
@@ -46,7 +46,8 @@ public class RemoveSite : PnPAdminCmdlet
4646
[Obsolete("Use Clear-PnPTenantRecycleBinItem instead.")]
4747
public SwitchParameter FromRecycleBin;
4848

49-
[Parameter(Mandatory = false, HelpMessage = "Do not ask for confirmation.")] public SwitchParameter Force;
49+
[Parameter(Mandatory = false, HelpMessage = "Do not ask for confirmation.")]
50+
public SwitchParameter Force;
5051

5152
protected override void ExecuteCmdlet()
5253
{
@@ -56,22 +57,29 @@ protected override void ExecuteCmdlet()
5657
Url = $"{uri.ToString().TrimEnd('/')}/{Url.TrimStart('/')}";
5758
}
5859

59-
if (Force || ShouldContinue(string.Format(Resources.RemoveSiteCollection0, Url), Resources.Confirm))
60+
bool dodelete = true;
61+
// Check if not deleting the root web
62+
var siteUri = new Uri(Url);
63+
if ($"{siteUri.Scheme}://{siteUri.Host}".Equals(Url, StringComparison.OrdinalIgnoreCase) && !Force)
64+
{
65+
dodelete = false;
66+
dodelete = ShouldContinue("You are trying to delete the root site collection. Be aware that you need to contact Office 365 Support in order to create a new root site collection. Also notice that some CSOM and REST operations require the root site collection to be present. Removing this site can affect all your remote processing code, even when accessing non-root site collections.", Resources.Confirm);
67+
}
68+
69+
if (dodelete && (Force || ShouldContinue(string.Format(Resources.RemoveSiteCollection0, Url), Resources.Confirm)))
6070
{
6171
Func<TenantOperationMessage, bool> timeoutFunction = TimeoutFunction;
6272

6373
#pragma warning disable 618
6474
if (!FromRecycleBin)
6575
#pragma warning restore 618
6676
{
67-
6877
Tenant.DeleteSiteCollection(Url, !MyInvocation.BoundParameters.ContainsKey("SkipRecycleBin"), timeoutFunction);
6978
}
7079
else
7180
{
7281
Tenant.DeleteSiteCollectionFromRecycleBin(Url, true, timeoutFunction);
7382
}
74-
7583
}
7684
}
7785

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#if !ONPREMISES
2+
using OfficeDevPnP.Core.Entities;
3+
using OfficeDevPnP.Core.Framework.Graph;
4+
using SharePointPnP.PowerShell.CmdletHelpAttributes;
5+
using SharePointPnP.PowerShell.Commands.Base;
6+
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Management.Automation;
10+
11+
namespace SharePointPnP.PowerShell.Commands.Graph
12+
{
13+
[Cmdlet("Get", "PnPUnifiedGroupMembers")]
14+
[CmdletHelp("Gets members of a paricular Office 365 Group (aka Unified Group)",
15+
Category = CmdletHelpCategory.Graph,
16+
SupportedPlatform = CmdletSupportedPlatform.Online)]
17+
[CmdletExample(
18+
Code = "PS:> Get-PnPUnifiedGroupMembers -Identity $groupId",
19+
Remarks = "Retrieves all the members of a specific Office 365 Group based on its ID",
20+
SortOrder = 1)]
21+
[CmdletExample(
22+
Code = "PS:> Get-PnPUnifiedGroupMembers -Identity $group",
23+
Remarks = "Retrieves all the members of a specific Office 365 Group based on the group's object instance",
24+
SortOrder = 2)]
25+
public class GetUnifiedGroupMembers : PnPGraphCmdlet
26+
{
27+
[Parameter(Mandatory = true, HelpMessage = "The Identity of the Office 365 Group.")]
28+
public UnifiedGroupPipeBind Identity;
29+
30+
protected override void ExecuteCmdlet()
31+
{
32+
UnifiedGroupEntity group = null;
33+
34+
if (Identity != null)
35+
{
36+
// We have to retrieve a specific group
37+
if (Identity.Group != null)
38+
{
39+
group = UnifiedGroupsUtility.GetUnifiedGroup(Identity.Group.GroupId, AccessToken, includeSite: false);
40+
}
41+
else if (!String.IsNullOrEmpty(Identity.GroupId))
42+
{
43+
group = UnifiedGroupsUtility.GetUnifiedGroup(Identity.GroupId, AccessToken, includeSite: false);
44+
}
45+
}
46+
47+
if (group != null)
48+
{
49+
// Get members of the group.
50+
51+
List<UnifiedGroupUser> members = UnifiedGroupsUtility.GetUnifiedGroupMembers(group, AccessToken);
52+
WriteObject(members);
53+
}
54+
55+
}
56+
}
57+
}
58+
#endif
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#if !ONPREMISES
2+
using OfficeDevPnP.Core.Entities;
3+
using OfficeDevPnP.Core.Framework.Graph;
4+
using SharePointPnP.PowerShell.CmdletHelpAttributes;
5+
using SharePointPnP.PowerShell.Commands.Base;
6+
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Management.Automation;
10+
11+
namespace SharePointPnP.PowerShell.Commands.Graph
12+
{
13+
[Cmdlet("Get", "PnPUnifiedGroupOwners")]
14+
[CmdletHelp("Gets owners of a paricular Office 365 Group (aka Unified Group)",
15+
Category = CmdletHelpCategory.Graph,
16+
SupportedPlatform = CmdletSupportedPlatform.Online)]
17+
[CmdletExample(
18+
Code = "PS:> Get-PnPUnifiedGroupOwners -Identity $groupId",
19+
Remarks = "Retrieves all the owners of a specific Office 365 Group based on its ID",
20+
SortOrder = 1)]
21+
[CmdletExample(
22+
Code = "PS:> Get-PnPUnifiedGroupOwners -Identity $group",
23+
Remarks = "Retrieves all the owners of a specific Office 365 Group based on the group's object instance",
24+
SortOrder = 2)]
25+
public class GetUnifiedGroupOwners : PnPGraphCmdlet
26+
{
27+
[Parameter(Mandatory = true, HelpMessage = "The Identity of the Office 365 Group.")]
28+
public UnifiedGroupPipeBind Identity;
29+
30+
protected override void ExecuteCmdlet()
31+
{
32+
UnifiedGroupEntity group = null;
33+
34+
if (Identity != null)
35+
{
36+
// We have to retrieve a specific group
37+
if (Identity.Group != null)
38+
{
39+
group = UnifiedGroupsUtility.GetUnifiedGroup(Identity.Group.GroupId, AccessToken, includeSite: false);
40+
}
41+
else if (!String.IsNullOrEmpty(Identity.GroupId))
42+
{
43+
group = UnifiedGroupsUtility.GetUnifiedGroup(Identity.GroupId, AccessToken, includeSite: false);
44+
}
45+
}
46+
47+
if (group != null)
48+
{
49+
// Get Owners of the group.
50+
51+
List<UnifiedGroupUser> owners = UnifiedGroupsUtility.GetUnifiedGroupOwners(group, AccessToken);
52+
WriteObject(owners);
53+
}
54+
55+
}
56+
}
57+
}
58+
#endif

Commands/Lists/NewList.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ namespace SharePointPnP.PowerShell.Commands.Lists
1616
Code = @"PS:> New-PnPList -Title ""Demo List"" -Url ""DemoList"" -Template Announcements",
1717
SortOrder = 2,
1818
Remarks = "Create a list with a title that is different from the url")]
19+
[CmdletExample(
20+
Code = "PS:> New-PnPList -Title HiddenList -Template GenericList -Hidden",
21+
SortOrder = 3,
22+
Remarks = "Create a new custom list and hides it from the SharePoint UI.")]
1923
public class NewList : PnPWebCmdlet
2024
{
2125
[Parameter(Mandatory = true, HelpMessage = "The Title of the list")]
@@ -27,6 +31,9 @@ public class NewList : PnPWebCmdlet
2731
[Parameter(Mandatory = false, HelpMessage = "If set, will override the url of the list.")]
2832
public string Url = null;
2933

34+
[Parameter(Mandatory = false, HelpMessage = "Switch parameter if list should be hidden from the SharePoint UI")]
35+
public SwitchParameter Hidden;
36+
3037
[Parameter(Mandatory = false, HelpMessage = "Switch parameter if versioning should be enabled")]
3138
public SwitchParameter EnableVersioning;
3239

@@ -42,7 +49,11 @@ public class NewList : PnPWebCmdlet
4249

4350
protected override void ExecuteCmdlet()
4451
{
45-
var list = SelectedWeb.CreateList(Template, Title, EnableVersioning, true, Url, EnableContentTypes);
52+
var list = SelectedWeb.CreateList(Template, Title, EnableVersioning, true, Url, EnableContentTypes, Hidden);
53+
if (Hidden)
54+
{
55+
SelectedWeb.DeleteNavigationNode(Title, "Recent", OfficeDevPnP.Core.Enums.NavigationType.QuickLaunch);
56+
}
4657
if (OnQuickLaunch)
4758
{
4859
list.OnQuickLaunch = true;

Commands/Lists/SetList.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@ namespace SharePointPnP.PowerShell.Commands.Lists
1212
Code = @"Set-PnPList -Identity ""Demo List"" -EnableContentTypes $true",
1313
Remarks = "Switches the Enable Content Type switch on the list",
1414
SortOrder = 1)]
15+
[CmdletExample(
16+
Code = @"Set-PnPList -Identity ""Demo List"" -Hidden $true",
17+
Remarks = "Hides the list from the SharePoint UI.",
18+
SortOrder = 2)]
1519
[CmdletExample(
1620
Code = @"Set-PnPList -Identity ""Demo List"" -EnableVersioning $true",
1721
Remarks = "Turns on major versions on a list",
18-
SortOrder = 2)]
22+
SortOrder = 3)]
1923
[CmdletExample(
2024
Code = @"Set-PnPList -Identity ""Demo List"" -EnableVersioning $true -MajorVersions 20",
2125
Remarks = "Turns on major versions on a list and sets the maximum number of Major Versions to keep to 20.",
22-
SortOrder = 3)]
26+
SortOrder = 4)]
2327
[CmdletExample(
2428
Code = @"Set-PnPList -Identity ""Demo Library"" -EnableVersioning $true -EnableMinorVersions $true -MajorVersions 20 -MinorVersions 5",
2529
Remarks = "Turns on major versions on a document library and sets the maximum number of Major versions to keep to 20 and sets the maximum of Minor versions to 5.",
26-
SortOrder = 4)]
30+
SortOrder = 5)]
2731
public class SetList : PnPWebCmdlet
2832
{
2933
[Parameter(Mandatory = true, HelpMessage = "The ID, Title or Url of the list.")]
@@ -51,6 +55,9 @@ public bool
5155
[Parameter(Mandatory = false, HelpMessage = "The title of the list")]
5256
public string Title = string.Empty;
5357

58+
[Parameter(Mandatory = false, HelpMessage = "Hide the list from the SharePoint UI. Set to $true to hide, $false to show.")]
59+
public bool Hidden;
60+
5461
[Parameter(Mandatory = false, HelpMessage = "Enable or disable versioning. Set to $true to enable, $false to disable.")]
5562
public bool EnableVersioning;
5663

@@ -82,16 +89,23 @@ protected override void ExecuteCmdlet()
8289
isDirty = true;
8390
}
8491

92+
if (MyInvocation.BoundParameters.ContainsKey("Hidden") && Hidden != list.Hidden)
93+
{
94+
list.Hidden = Hidden;
95+
isDirty = true;
96+
}
97+
8598
if (MyInvocation.BoundParameters.ContainsKey("EnableContentTypes") && list.ContentTypesEnabled != EnableContentTypes)
8699
{
87100
list.ContentTypesEnabled = EnableContentTypes;
88101
isDirty = true;
89102
}
90103

91-
list.EnsureProperties(l => l.EnableVersioning, l => l.EnableMinorVersions);
104+
list.EnsureProperties(l => l.EnableVersioning, l => l.EnableMinorVersions, l => l.Hidden);
92105

93106
var enableVersioning = list.EnableVersioning;
94107
var enableMinorVersions = list.EnableMinorVersions;
108+
var hidden = list.Hidden;
95109

96110
if (MyInvocation.BoundParameters.ContainsKey("EnableVersioning") && EnableVersioning != enableVersioning)
97111
{

Commands/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@
4444
// You can specify all the values or you can default the Build and Revision Numbers
4545
// by using the '*' as shown below:
4646
// [assembly: AssemblyVersion("1.0.*")]
47-
[assembly: AssemblyVersion("2.21.1712.2")]
48-
[assembly: AssemblyFileVersion("2.21.1712.2")]
47+
[assembly: AssemblyVersion("2.22.1801.0")]
48+
[assembly: AssemblyFileVersion("2.22.1801.0")]
4949
[assembly: InternalsVisibleTo("SharePointPnP.PowerShell.Tests")]

Commands/SharePointPnP.PowerShell.Commands.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@
409409
<Reference Include="System.Xml" />
410410
</ItemGroup>
411411
<ItemGroup>
412+
<Compile Include="Admin\GetTenantAppCatalogUrl.cs" />
412413
<Compile Include="Admin\RemoveStorageEntity.cs" />
413414
<Compile Include="Base\PipeBinds\ClientSideWebPartPipeBind.cs" />
414415
<Compile Include="Base\PipeBinds\TenantSiteScriptPipeBind.cs" />
@@ -475,6 +476,8 @@
475476
<Compile Include="Files\RenameFile.cs" />
476477
<Compile Include="Base\PipeBinds\RecycleBinItemPipeBind.cs" />
477478
<Compile Include="Files\RenameFolder.cs" />
479+
<Compile Include="Graph\GetUnifiedGroupOwners.cs" />
480+
<Compile Include="Graph\GetUnifiedGroupMembers.cs" />
478481
<Compile Include="Graph\UpdateSiteClassification.cs" />
479482
<Compile Include="Graph\RemoveSiteClassification.cs" />
480483
<Compile Include="Graph\DisableSiteClassification.cs" />
@@ -712,7 +715,9 @@
712715
<Compile Include="Web\SetWebPermission.cs" />
713716
<Compile Include="Web\SetRequestAccessEmails.cs" />
714717
<Compile Include="Workflows\AddWorkflowDefinition.cs" />
718+
<Compile Include="Workflows\GetWorkflowInstances.cs" />
715719
<Compile Include="Workflows\ResumeWorkflowInstance.cs" />
720+
<Compile Include="Workflows\StartWorkflowInstance.cs" />
716721
<Compile Include="Workflows\StopWorkflowInstance.cs" />
717722
<Compile Include="Workflows\RemoveWorkflowDefinition.cs" />
718723
<Compile Include="Workflows\RemoveWorkflowSubscription.cs" />

0 commit comments

Comments
 (0)