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

Commit fb01372

Browse files
Merge pull request #741 from SharePoint/dev
February 2017 Release
2 parents 9e25c0c + b606ae2 commit fb01372

File tree

427 files changed

+9390
-2466
lines changed

Some content is hidden

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

427 files changed

+9390
-2466
lines changed

CmdletHelpGenerator/App.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

CmdletHelpGenerator/Program.cs

Lines changed: 0 additions & 781 deletions
This file was deleted.

Commands/Admin/GetTenantSite.cs

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#if !ONPREMISES
2-
using System;
3-
using System.ComponentModel;
42
using System.Linq;
53
using System.Management.Automation;
64
using Microsoft.SharePoint.Client;
@@ -22,18 +20,22 @@ namespace SharePointPnP.PowerShell.Commands
2220
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -Url http://tenant.sharepoint.com/sites/projects", Remarks = "Returns information about the project site.",SortOrder = 2)]
2321
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -Detailed", Remarks = "Returns all sites with the full details of these sites", SortOrder = 3)]
2422
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -IncludeOneDriveSites", Remarks = "Returns all sites including all OneDrive 4 Business sites", SortOrder = 4)]
25-
public class GetTenantSite : SPOAdminCmdlet
23+
public class GetTenantSite : PnPAdminCmdlet
2624
{
2725
[Parameter(Mandatory = false, HelpMessage = "The URL of the site", Position = 0, ValueFromPipeline = true)]
2826
[Alias("Identity")]
2927
public string Url;
3028

29+
[Parameter(Mandatory = false, HelpMessage = "By default, all sites will be return. Specify a template value alike 'STS#0' here to filter on the template")]
30+
public string Template;
31+
3132
[Parameter(Mandatory = false, HelpMessage = "By default, not all returned attributes are populated. This switch populates all attributes. It can take several seconds to run. Without this, some attributes will show default values that may not be correct.")]
3233
public SwitchParameter Detailed;
3334

3435
[Parameter(Mandatory = false, HelpMessage = "By default, the OneDrives are not returned. This switch includes all OneDrives. This can take some extra time to run")]
3536
public SwitchParameter IncludeOneDriveSites;
3637

38+
3739
[Parameter(Mandatory = false, HelpMessage = "When the switch IncludeOneDriveSites is used, this switch ignores the question shown that the command can take a long time to execute")]
3840
public SwitchParameter Force;
3941

@@ -54,10 +56,28 @@ protected override void ExecuteCmdlet()
5456
}
5557
else
5658
{
59+
60+
5761
var list = Tenant.GetSiteProperties(0, Detailed);
58-
list.Context.Load(list);
59-
list.Context.ExecuteQueryRetry();
62+
63+
Tenant.Context.Load(list);
64+
Tenant.Context.ExecuteQueryRetry();
6065
var siteProperties = list.ToList();
66+
var returnedEntries = list.Count;
67+
68+
var startIndex = 0;
69+
while (returnedEntries > 299)
70+
{
71+
startIndex = startIndex + 300;
72+
var nextList = Tenant.GetSiteProperties(startIndex, Detailed);
73+
Tenant.Context.Load(nextList);
74+
Tenant.Context.ExecuteQueryRetry();
75+
siteProperties.AddRange(nextList);
76+
returnedEntries = nextList.Count;
77+
}
78+
79+
80+
6181
if (IncludeOneDriveSites)
6282
{
6383
if (Force || ShouldContinue(Resources.GetTenantSite_ExecuteCmdlet_This_request_can_take_a_long_time_to_execute__Continue_, Resources.Confirm))
@@ -74,7 +94,14 @@ protected override void ExecuteCmdlet()
7494
}
7595
}
7696
}
77-
WriteObject(siteProperties.OrderBy(x => x.Url), true);
97+
if (Template != null)
98+
{
99+
WriteObject(siteProperties.Where(t => t.Template == Template).OrderBy(x => x.Url), true);
100+
}
101+
else
102+
{
103+
WriteObject(siteProperties.OrderBy(x => x.Url), true);
104+
}
78105
}
79106
}
80107
}

Commands/Admin/GetWebTemplates.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#if !ONPREMISES
2-
using System;
32
using SharePointPnP.PowerShell.CmdletHelpAttributes;
43
using Microsoft.SharePoint.Client;
54
using SharePointPnP.PowerShell.Commands.Base;
@@ -17,7 +16,7 @@ namespace SharePointPnP.PowerShell.Commands
1716
[CmdletExample(Code = @"PS:> Get-PnPWebTemplates -LCID 1033", Remarks = @"Returns all webtemplates for the Locale with ID 1033 (English)", SortOrder = 2)]
1817
[CmdletExample(Code = @"PS:> Get-PnPWebTemplates -CompatibilityLevel 15", Remarks = @"Returns all webtemplates for the compatibility level 15", SortOrder = 2)]
1918
[CmdletRelatedLink(Text = "Locale IDs", Url = "http://go.microsoft.com/fwlink/p/?LinkId=242911Id=242911")]
20-
public class GetWebTemplates : SPOAdminCmdlet
19+
public class GetWebTemplates : PnPAdminCmdlet
2120
{
2221
[Parameter(Mandatory = false, HelpMessage = "The language ID. For instance: 1033 for English")]
2322
public uint Lcid;

Commands/Admin/NewTenantSite.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
using System.Management.Automation;
33
using Microsoft.SharePoint.Client;
44
using OfficeDevPnP.Core;
5+
using OfficeDevPnP.Core.Entities;
56
using SharePointPnP.PowerShell.CmdletHelpAttributes;
67
using SharePointPnP.PowerShell.Commands.Base;
7-
using OfficeDevPnP.Core.Entities;
88
using Resources = SharePointPnP.PowerShell.Commands.Properties.Resources;
99

1010

@@ -33,7 +33,7 @@ namespace SharePointPnP.PowerShell.Commands
3333
[CmdletRelatedLink(
3434
Text = "Creating on-premises site collections using CSOM",
3535
Url = "http://blogs.msdn.com/b/vesku/archive/2014/06/09/provisioning-site-collections-using-sp-app-model-in-on-premises-with-just-csom.aspx")]
36-
public class NewTenantSite : SPOAdminCmdlet
36+
public class NewTenantSite : PnPAdminCmdlet
3737
{
3838
[Parameter(Mandatory = true, HelpMessage = @"Specifies the title of the new site collection")]
3939
public string Title;

Commands/Admin/RemoveTenantSite.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace SharePointPnP.PowerShell.Commands
2828
Remarks =
2929
@"This will remove the site collection with the url 'https://tenant.sharepoint.com/sites/contoso' from the recycle bin.",
3030
SortOrder = 3)]
31-
public class RemoveSite : SPOAdminCmdlet
31+
public class RemoveSite : PnPAdminCmdlet
3232
{
3333
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, HelpMessage = "Specifies the full URL of the site collection that needs to be deleted")]
3434
public string Url;

Commands/Admin/SetTenantSite.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using SharePointPnP.PowerShell.CmdletHelpAttributes;
77
using SharePointPnP.PowerShell.Commands.Base;
88
using System.Collections.Generic;
9-
using System.Threading;
109
using OfficeDevPnP.Core;
1110
using OfficeDevPnP.Core.Entities;
1211

@@ -25,7 +24,7 @@ namespace SharePointPnP.PowerShell.Commands
2524
[CmdletExample(
2625
Code = @"PS:> Set-PnPTenantSite -Url https://contoso.sharepoint.com/sites/sales -Owners '[email protected]'",
2726
Remarks = @"This will set [email protected] as a site collection owner at 'https://contoso.sharepoint.com/sites/sales'.", SortOrder = 3)]
28-
public class SetTenantSite : SPOAdminCmdlet
27+
public class SetTenantSite : PnPAdminCmdlet
2928
{
3029
[Parameter(Mandatory = true, HelpMessage = "Specifies the URL of the site", Position = 0, ValueFromPipeline = true)]
3130
public string Url;

Commands/Apps/GetAppInstance.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
11
using System.Collections.Generic;
2+
using System.Linq;
23
using System.Management.Automation;
34
using Microsoft.SharePoint.Client;
45
using SharePointPnP.PowerShell.CmdletHelpAttributes;
56
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
67

7-
namespace SharePointPnP.PowerShell.Commands
8+
namespace SharePointPnP.PowerShell.Commands.Apps
89
{
910
[Cmdlet(VerbsCommon.Get, "PnPAppInstance")]
1011
[CmdletAlias("Get-SPOAppInstance")]
11-
[CmdletHelp("Returns a SharePoint AddIn Instance in the site",
12+
[CmdletHelp("Returns a SharePoint AddIn Instance in the site",
1213
Category = CmdletHelpCategory.Apps,
13-
OutputType= typeof(List<AppInstance>),
14+
OutputType = typeof(List<AppInstance>),
1415
OutputTypeLink = "https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.appinstance.aspx")]
1516
[CmdletExample(Code = @"PS:> Get-PnPAppInstance", Remarks = @"This will return all addin instances in the site.", SortOrder = 1)]
1617
[CmdletExample(Code = @"PS:> Get-PnPAppInstance -Identity 99a00f6e-fb81-4dc7-8eac-e09c6f9132fe", Remarks = @"This will return an addin instance with the specified id.", SortOrder = 2)]
17-
public class GetAppInstance : SPOWebCmdlet
18+
public class GetAppInstance : PnPWebRetrievalsCmdlet<AppInstance>
1819
{
1920
[Parameter(Mandatory = false, Position=0, ValueFromPipeline = true, HelpMessage = "Specifies the Id of the App Instance")]
20-
public GuidPipeBind Identity;
21+
public AppPipeBind Identity;
2122

2223
protected override void ExecuteCmdlet()
2324
{
24-
25+
2526
if (Identity != null)
2627
{
27-
var instance = SelectedWeb.GetAppInstanceById(Identity.Id);
28-
ClientContext.Load(instance);
29-
ClientContext.ExecuteQueryRetry();
28+
var instance = Identity.GetAppInstance(SelectedWeb);
3029
WriteObject(instance);
3130
}
3231
else
3332
{
3433
var instances = SelectedWeb.GetAppInstances();
3534
if (instances.Count > 1)
3635
{
37-
WriteObject(instances,true);
36+
WriteObject(instances, true);
3837
}
3938
else if (instances.Count == 1)
4039
{

Commands/Apps/ImportAppPackage.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
using System.IO;
1+
using System.Globalization;
2+
using System.IO;
23
using System.Management.Automation;
3-
using System.Globalization;
4-
using SharePointPnP.PowerShell.CmdletHelpAttributes;
54
using Microsoft.SharePoint.Client;
65
using OfficeDevPnP.Core;
6+
using SharePointPnP.PowerShell.CmdletHelpAttributes;
77

8-
namespace SharePointPnP.PowerShell.Commands
8+
namespace SharePointPnP.PowerShell.Commands.Apps
99
{
1010
[Cmdlet(VerbsData.Import, "PnPAppPackage")]
1111
[CmdletAlias("Import-SPOAppPackage")]
1212
[CmdletHelp("Adds a SharePoint Addin to a site",
13-
DetailedDescription = "This commands requires that you have an addin package to deploy",
13+
DetailedDescription = "This commands requires that you have an addin package to deploy",
1414
Category = CmdletHelpCategory.Apps,
15-
OutputType= typeof(AppInstance),
15+
OutputType = typeof(AppInstance),
1616
OutputTypeLink = "https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.appinstance.aspx")]
1717
[CmdletExample(
1818
Code = @"PS:> Import-PnPAppPackage -Path c:\files\demo.app -LoadOnly",
@@ -22,7 +22,7 @@ namespace SharePointPnP.PowerShell.Commands
2222
Code = @"PS:> Import-PnPAppPackage -Path c:\files\demo.app -Force",
2323
Remarks = @"This load first activate the addin sideloading feature, upload and install the addin, and deactivate the addin sideloading feature.
2424
", SortOrder = 2)]
25-
public class ImportAppPackage : SPOWebCmdlet
25+
public class ImportAppPackage : PnPWebCmdlet
2626
{
2727
[Parameter(Mandatory = true, HelpMessage = "Path pointing to the .app file")]
2828
public string Path = string.Empty;
@@ -50,7 +50,7 @@ protected override void ExecuteCmdlet()
5050
ClientContext.Site.ActivateFeature(Constants.FeatureId_Site_AppSideLoading);
5151
}
5252
AppInstance instance;
53-
53+
5454

5555
var appPackageStream = new FileStream(Path, FileMode.Open, FileAccess.Read);
5656
if (Locale == -1)
@@ -77,7 +77,7 @@ protected override void ExecuteCmdlet()
7777
}
7878
ClientContext.Load(instance);
7979
ClientContext.ExecuteQueryRetry();
80-
80+
8181

8282
if (Force)
8383
{
@@ -87,7 +87,7 @@ protected override void ExecuteCmdlet()
8787
}
8888
else
8989
{
90-
WriteError(new ErrorRecord(new IOException(Properties.Resources.FileDoesNotExist), "1", ErrorCategory.InvalidArgument, null));
90+
ThrowTerminatingError(new ErrorRecord(new IOException(Properties.Resources.FileDoesNotExist), "1", ErrorCategory.InvalidArgument, null));
9191
}
9292
}
9393
}

Commands/Apps/UninstallAppInstance.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
using Microsoft.SharePoint.Client;
2-
using System.Management.Automation;
3-
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
1+
using System.Management.Automation;
2+
using Microsoft.SharePoint.Client;
43
using SharePointPnP.PowerShell.CmdletHelpAttributes;
4+
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;
55

6-
namespace SharePointPnP.PowerShell.Commands
6+
namespace SharePointPnP.PowerShell.Commands.Apps
77
{
88
[Cmdlet(VerbsLifecycle.Uninstall, "PnPAppInstance", SupportsShouldProcess = true)]
99
[CmdletAlias("Uninstall-SPOAppInstance")]
1010
[CmdletHelp("Removes an app from a site", Category = CmdletHelpCategory.Apps)]
1111
[CmdletExample(Code = @"PS:> Uninstall-PnPAppInstance -Identity $appinstance", Remarks = "Uninstalls the app instance which was retrieved with the command Get-PnPAppInstance", SortOrder = 1)]
1212
[CmdletExample(Code = @"PS:> Uninstall-PnPAppInstance -Identity 99a00f6e-fb81-4dc7-8eac-e09c6f9132fe", Remarks = "Uninstalls the app instance with the ID '99a00f6e-fb81-4dc7-8eac-e09c6f9132fe'", SortOrder = 2)]
1313
[CmdletExample(Code = @"PS:> Uninstall-PnPAppInstance -Identity 99a00f6e-fb81-4dc7-8eac-e09c6f9132fe -force", Remarks = "Uninstalls the app instance with the ID '99a00f6e-fb81-4dc7-8eac-e09c6f9132fe' and do not ask for confirmation", SortOrder = 3)]
14-
public class UninstallAppInstance : SPOWebCmdlet
14+
public class UninstallAppInstance : PnPWebCmdlet
1515
{
1616
[Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "Appinstance or Id of the addin to remove.")]
1717
public AppPipeBind Identity;
@@ -23,15 +23,8 @@ protected override void ExecuteCmdlet()
2323
{
2424
AppInstance instance;
2525

26-
if (Identity.Instance != null)
27-
{
28-
instance = Identity.Instance;
29-
}
30-
else
31-
{
32-
instance = SelectedWeb.GetAppInstanceById(Identity.Id);
33-
}
34-
26+
instance = Identity.GetAppInstance(SelectedWeb);
27+
3528
if(instance != null)
3629
{
3730
if(!instance.IsObjectPropertyInstantiated("Title"))

0 commit comments

Comments
 (0)