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

Commit

Permalink
Merge pull request #1064 from SharePoint/dev
Browse files Browse the repository at this point in the history
September 2017 Release
  • Loading branch information
erwinvanhunen authored Sep 8, 2017
2 parents a9013d4 + c87c956 commit 5f01dc2
Show file tree
Hide file tree
Showing 165 changed files with 4,857 additions and 1,264 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ The verb of a cmdlet (get-, add-, etc.) should follow acceptable cmdlet standard

## Documentation contributions
If you want to contribute to cmdlet documentation, please do not make a pull request to modify the actual files in the Documentation folder itself. Those files
are automatically generated based upon comments in the actual classes. So if you want to modify documentation and or add an example of a cmdlet, navigate to the
are automatically generated based upon comments in the actual classes. So if you want to modify documentation or add an example of a cmdlet, navigate to the
corresponding class where the cmdlet is being implemented and add the comments there. An example can for instance be found in

https://github.com/OfficeDev/PnP-PowerShell/blob/dev/Commands/Fields/AddField.cs
Expand Down
61 changes: 23 additions & 38 deletions Commands/Admin/GetTenantSite.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
#if !ONPREMISES
using System.Linq;
using System.Management.Automation;
using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.SharePoint.Client;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base;
using SharePointPnP.PowerShell.Commands.Enums;
using Resources = SharePointPnP.PowerShell.Commands.Properties.Resources;

namespace SharePointPnP.PowerShell.Commands
{

[Cmdlet(VerbsCommon.Get, "PnPTenantSite", SupportsShouldProcess = true)]
[CmdletHelp(@"Office365 only: Uses the tenant API to retrieve site information.",
[CmdletHelp(@"Uses the tenant API to retrieve site information.",
Category = CmdletHelpCategory.TenantAdmin,
SupportedPlatform = CmdletSupportedPlatform.Online,
OutputType = typeof(Microsoft.Online.SharePoint.TenantAdministration.SiteProperties),
OutputTypeLink = "https://msdn.microsoft.com/en-us/library/microsoft.online.sharepoint.tenantadministration.siteproperties.aspx")]
[CmdletExample(Code = @"PS:> Get-PnPTenantSite", Remarks = "Returns all site collections", SortOrder = 1)]
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -Url http://tenant.sharepoint.com/sites/projects", Remarks = "Returns information about the project site.",SortOrder = 2)]
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -Url http://tenant.sharepoint.com/sites/projects", Remarks = "Returns information about the project site.", SortOrder = 2)]
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -Detailed", Remarks = "Returns all sites with the full details of these sites", SortOrder = 3)]
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -IncludeOneDriveSites", Remarks = "Returns all sites including all OneDrive 4 Business sites", SortOrder = 4)]
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -IncludeOneDriveSites -Filter ""Url -like '-my.sharepoint.com/personal/'""", Remarks = "Returns all OneDrive for Business sites.", SortOrder = 5)]
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -WebTemplate SITEPAGEPUBLISHING#0", Remarks = "Returns all Communication sites", SortOrder = 6)]
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -Filter ""Url -like 'sales'"" ", Remarks = "Returns all sites including 'sales' in the url.", SortOrder = 7)]
public class GetTenantSite : PnPAdminCmdlet
{
[Parameter(Mandatory = false, HelpMessage = "The URL of the site", Position = 0, ValueFromPipeline = true)]
Expand All @@ -31,13 +34,18 @@ public class GetTenantSite : PnPAdminCmdlet
[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.")]
public SwitchParameter Detailed;

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


[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")]
public SwitchParameter Force;

[Parameter(Mandatory = false, HelpMessage = "Limit results to a specific web template name.")]
public string WebTemplate;

[Parameter(Mandatory = false, HelpMessage = "Specifies the script block of the server-side filter to apply. See https://technet.microsoft.com/en-us/library/fp161380.aspx")]
public string Filter;

protected override void ExecuteCmdlet()
{
if (SPOnlineConnection.CurrentConnection.ConnectionType == ConnectionType.OnPrem)
Expand All @@ -55,44 +63,21 @@ protected override void ExecuteCmdlet()
}
else
{
SPOSitePropertiesEnumerableFilter filter = new SPOSitePropertiesEnumerableFilter()
{
IncludePersonalSite = IncludeOneDriveSites.IsPresent ? PersonalSiteFilter.Include : PersonalSiteFilter.UseServerDefault,
StartIndex = null,
IncludeDetail = true,
Template = WebTemplate,
Filter = Filter,
};

var list = Tenant.GetSitePropertiesFromSharePointByFilters(filter);

var list = Tenant.GetSiteProperties(0, Detailed);

Tenant.Context.Load(list);
Tenant.Context.ExecuteQueryRetry();
var siteProperties = list.ToList();
var returnedEntries = list.Count;

var startIndex = 0;
while (returnedEntries > 299)
{
startIndex = startIndex + 300;
var nextList = Tenant.GetSiteProperties(startIndex, Detailed);
Tenant.Context.Load(nextList);
Tenant.Context.ExecuteQueryRetry();
siteProperties.AddRange(nextList);
returnedEntries = nextList.Count;
}



if (IncludeOneDriveSites)
{
if (Force || ShouldContinue(Resources.GetTenantSite_ExecuteCmdlet_This_request_can_take_a_long_time_to_execute__Continue_, Resources.Confirm))
{
var onedriveSites = Tenant.GetOneDriveSiteCollections();

var personalUrl = ClientContext.Url.ToLower().Replace("-admin", "-my");
foreach (var site in onedriveSites)
{
var siteprops = Tenant.GetSitePropertiesByUrl($"{personalUrl.TrimEnd('/')}/{site.Url.Trim('/')}", Detailed);
ClientContext.Load(siteprops);
ClientContext.ExecuteQueryRetry();
siteProperties.Add(siteprops);
}
}
}
if (Template != null)
{
WriteObject(siteProperties.Where(t => t.Template == Template).OrderBy(x => x.Url), true);
Expand Down
3 changes: 1 addition & 2 deletions Commands/Admin/GetTimeZoneId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ namespace SharePointPnP.PowerShell.Commands
public class GetTimeZoneId : PSCmdlet
{
[Parameter(Mandatory = false, Position = 0, HelpMessage = "A string to search for like 'Stockholm'")]
public
string Match;
public string Match;

protected override void ProcessRecord()
{
Expand Down
5 changes: 3 additions & 2 deletions Commands/Admin/GetWebTemplates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
namespace SharePointPnP.PowerShell.Commands
{
[Cmdlet(VerbsCommon.Get, "PnPWebTemplates")]
[CmdletHelp(@"Office365 only: Returns the available web templates.",
[CmdletHelp(@"Returns the available web templates.",
Category = CmdletHelpCategory.TenantAdmin,
OutputType=typeof(Microsoft.Online.SharePoint.TenantAdministration.SPOTenantWebTemplateCollection),
SupportedPlatform = CmdletSupportedPlatform.Online,
OutputType =typeof(Microsoft.Online.SharePoint.TenantAdministration.SPOTenantWebTemplateCollection),
OutputTypeLink = "https://msdn.microsoft.com/en-us/library/microsoft.online.sharepoint.tenantadministration.spotenantwebtemplatecollection.aspx")]
[CmdletExample(Code = @"PS:> Get-PnPWebTemplates", SortOrder = 1)]
[CmdletExample(Code = @"PS:> Get-PnPWebTemplates -LCID 1033", Remarks = @"Returns all webtemplates for the Locale with ID 1033 (English)", SortOrder = 2)]
Expand Down
2 changes: 1 addition & 1 deletion Commands/Admin/NewTenantSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class NewTenantSite : PnPAdminCmdlet
[Parameter(Mandatory = true, HelpMessage = @"Specifies the user name of the site collection's primary owner. The owner must be a user instead of a security group or an email-enabled security group.")]
public string Owner = string.Empty;

[Parameter(Mandatory = false, HelpMessage = @"Specifies the language of this site collection. For more information, see Locale IDs Assigned by Microsoft: http://go.microsoft.com/fwlink/p/?LinkId=242911Id=242911.")]
[Parameter(Mandatory = false, HelpMessage = @"Specifies the language of this site collection. For more information, see Locale IDs Assigned by Microsoft: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splanguage.lcid.aspx")]
public uint Lcid = 1033;

[Parameter(Mandatory = false, HelpMessage = @"Specifies the site collection template type. Use the Get-PnPWebTemplate cmdlet to get the list of valid templates. If no template is specified, one can be added later. The Template and LocaleId parameters must be a valid combination as returned from the Get-PnPWebTemplates cmdlet.")]
Expand Down
7 changes: 4 additions & 3 deletions Commands/Admin/RemoveTenantSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
namespace SharePointPnP.PowerShell.Commands
{
[Cmdlet(VerbsCommon.Remove, "PnPTenantSite", ConfirmImpact = ConfirmImpact.High, SupportsShouldProcess = true)]
[CmdletHelp("Office365 only: Removes a site collection from the current tenant",
[CmdletHelp("Removes a site collection from the current tenant",
SupportedPlatform = CmdletSupportedPlatform.Online,
Category = CmdletHelpCategory.TenantAdmin)]
[CmdletExample(
Code = @"PS:> Remove-PnPTenantSite -Url https://tenant.sharepoint.com/sites/contoso",
Expand Down Expand Up @@ -43,7 +44,7 @@ public class RemoveSite : PnPAdminCmdlet
[Parameter(Mandatory = false, HelpMessage = "If specified, will search for the site in the Recycle Bin and remove it from there.")]
[Obsolete("Use Clear-PnPTenantRecycleBinItem instead.")]
public SwitchParameter FromRecycleBin;

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

protected override void ExecuteCmdlet()
Expand All @@ -62,7 +63,7 @@ protected override void ExecuteCmdlet()
if (!FromRecycleBin)
#pragma warning restore 618
{

Tenant.DeleteSiteCollection(Url, !MyInvocation.BoundParameters.ContainsKey("SkipRecycleBin"), timeoutFunction);
}
else
Expand Down
18 changes: 11 additions & 7 deletions Commands/Admin/SetTenantSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,24 @@
namespace SharePointPnP.PowerShell.Commands
{
[Cmdlet(VerbsCommon.Set, "PnPTenantSite")]
[CmdletHelp(@"Office365 only: Uses the tenant API to set site information.",
[CmdletHelp(@"Uses the tenant API to set site information.",
SupportedPlatform = CmdletSupportedPlatform.Online,
Category = CmdletHelpCategory.TenantAdmin)]
[CmdletExample(
Code = @"PS:> Set-PnPTenantSite -Url https://contoso.sharepoint.com -Title 'Contoso Website' -Sharing Disabled",
Code = @"PS:> Set-PnPTenantSite -Url https://contoso.sharepoint.com -Title ""Contoso Website"" -Sharing Disabled",
Remarks = @"This will set the title of the site collection with the URL 'https://contoso.sharepoint.com' to 'Contoso Website' and disable sharing on this site collection.", SortOrder = 1)]
[CmdletExample(
Code = @"PS:> Set-PnPTenantSite -Url https://contoso.sharepoint.com -Title 'Contoso Website' -StorageWarningLevel 8000 -StorageMaximumLevel 10000",
Code = @"PS:> Set-PnPTenantSite -Url https://contoso.sharepoint.com -Title ""Contoso Website"" -StorageWarningLevel 8000 -StorageMaximumLevel 10000",
Remarks = @"This will set the title of the site collection with the URL 'https://contoso.sharepoint.com' to 'Contoso Website', set the storage warning level to 8GB and set the storage maximum level to 10GB.", SortOrder = 2)]
[CmdletExample(
Code = @"PS:> Set-PnPTenantSite -Url https://contoso.sharepoint.com/sites/sales -Owners 'user@contoso.onmicrosoft.com'",
Remarks = @"This will set user@contoso.onmicrosoft.com as a site collection owner at 'https://contoso.sharepoint.com/sites/sales'.", SortOrder = 3)]
Code = @"PS:> Set-PnPTenantSite -Url https://contoso.sharepoint.com/sites/sales -Owners ""user@contoso.onmicrosoft.com""",
Remarks = @"This will add user@contoso.onmicrosoft.com as an additional site collection owner at 'https://contoso.sharepoint.com/sites/sales'.", SortOrder = 3)]
[CmdletExample(
Code = @"PS:> Set-PnPTenantSite -Url https://contoso.sharepoint.com/sites/sales -Owners @(""user1@contoso.onmicrosoft.com"", ""user2@contoso.onmicrosoft.com"")",
Remarks = @"This will add user1@contoso.onmicrosoft.com and user2@contoso.onmicrosoft.com as additional site collection owners at 'https://contoso.sharepoint.com/sites/sales'.", SortOrder = 4)]
[CmdletExample(
Code = @"PS:> Set-PnPTenantSite -Url https://contoso.sharepoint.com/sites/sales -NoScriptSite:$false",
Remarks = @"This will enable script support for the site 'https://contoso.sharepoint.com/sites/sales' if disabled.", SortOrder = 4)]
Remarks = @"This will enable script support for the site 'https://contoso.sharepoint.com/sites/sales' if disabled.", SortOrder = 5)]
public class SetTenantSite : PnPAdminCmdlet
{
[Parameter(Mandatory = true, HelpMessage = "Specifies the URL of the site", Position = 0, ValueFromPipeline = true)]
Expand All @@ -52,7 +56,7 @@ public class SetTenantSite : PnPAdminCmdlet
[Parameter(Mandatory = false, HelpMessage = "Specifies if the site administrator can upgrade the site collection")]
public SwitchParameter? AllowSelfServiceUpgrade = null;

[Parameter(Mandatory = false, HelpMessage = "Specifies owners to add as site collection adminstrators. Can be both users and groups.")]
[Parameter(Mandatory = false, HelpMessage = "Specifies owner(s) to add as site collection adminstrators. They will be added as additional site collection administrators. Existing administrators will stay. Can be both users and groups.")]
public List<string> Owners;

[Parameter(Mandatory = false, HelpMessage = "Sets the lockstate of a site")]
Expand Down
Loading

0 comments on commit 5f01dc2

Please sign in to comment.