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

Commit 9e25c0c

Browse files
Merge pull request #650 from SharePoint/dev
January 2017 Release
2 parents 90f3aff + 3c45a5d commit 9e25c0c

File tree

62 files changed

+1983
-164
lines changed

Some content is hidden

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

62 files changed

+1983
-164
lines changed

CmdletHelpGenerator/Program.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,13 @@ static void Main(string[] args)
437437
foreach (var exampleAttr in examples.OrderBy(e => e.SortOrder))
438438
{
439439
var example = new XElement(command + "example");
440-
var title = string.Format("------------------EXAMPLE {0}---------------------", exampleCount);
440+
var title = $"------------------EXAMPLE {exampleCount}---------------------";
441441
example.Add(new XElement(maml + "title", title));
442442
example.Add(new XElement(maml + "introduction", new XElement(maml + "para", exampleAttr.Introduction)));
443443
example.Add(new XElement(dev + "code", exampleAttr.Code));
444-
example.Add(new XElement(maml + "remarks", new XElement(maml + "para", exampleAttr.Remarks)));
444+
var remarksElement = new XElement(maml + "remarks", new XElement(maml + "para", exampleAttr.Remarks));
445+
remarksElement.Add(new XElement(maml + "para",""));
446+
example.Add(remarksElement);
445447
example.Add(new XElement(command + "commandLines",
446448
new XElement(command + "commandLine",
447449
new XElement(command + "commandText"))));

Commands/Admin/NewTenantSite.cs

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
1-
using System.Management.Automation;
1+
using System;
2+
using System.Management.Automation;
23
using Microsoft.SharePoint.Client;
4+
using OfficeDevPnP.Core;
35
using SharePointPnP.PowerShell.CmdletHelpAttributes;
46
using SharePointPnP.PowerShell.Commands.Base;
57
using OfficeDevPnP.Core.Entities;
8+
using Resources = SharePointPnP.PowerShell.Commands.Properties.Resources;
9+
610

711
namespace SharePointPnP.PowerShell.Commands
812
{
913
[Cmdlet(VerbsCommon.New, "PnPTenantSite")]
1014
[CmdletAlias("New-SPOTenantSite")]
11-
[CmdletHelp("Creates a new site collection for the current tenant",
15+
[CmdletHelp("Creates a new site collection for the current tenant",
1216
DetailedDescription = @"The New-PnPTenantSite cmdlet creates a new site collection for the current company. However, creating a new SharePoint
13-
Online site collection fails if a deleted site with the same URL exists in the Recycle Bin. If you want to use this command for an on-premises farm, please refer to http://blogs.msdn.com/b/vesku/archive/2014/06/09/provisioning-site-collections-using-sp-app-model-in-on-premises-with-just-csom.aspx ",
17+
Online site collection fails if a deleted site with the same URL exists in the Recycle Bin. If you want to use this command for an on-premises farm, please refer to http://blogs.msdn.com/b/vesku/archive/2014/06/09/provisioning-site-collections-using-sp-app-model-in-on-premises-with-just-csom.aspx ",
1418
Category = CmdletHelpCategory.TenantAdmin)]
1519
[CmdletExample(
16-
Code = @"PS:> New-PnPTenantSite -Title Contoso -Url https://tenant.sharepoint.com/sites/contoso -Owner [email protected] -TimeZone 4",
17-
Remarks = @"This will add a site collection with the title 'Contoso', the url 'https://tenant.sharepoint.com/sites/contoso', the timezone 'UTC+01:00' and the owner '[email protected]'", SortOrder = 1)]
20+
Code = @"PS:> New-PnPTenantSite -Title Contoso -Url https://tenant.sharepoint.com/sites/contoso -Owner [email protected] -TimeZone 4 -Template STS#0",
21+
Remarks = @"This will add a site collection with the title 'Contoso', the url 'https://tenant.sharepoint.com/sites/contoso', the timezone 'UTC+01:00',the owner '[email protected]' and the template used will be STS#0, a TeamSite",
22+
SortOrder = 1)]
23+
[CmdletExample(
24+
Code = @"PS:> New-PnPTenantSite -Title Contoso -Url /sites/contososite -Owner [email protected] -TimeZone 4 -Template STS#0",
25+
Remarks = @"This will add a site collection with the title 'Contoso', the url 'https://tenant.sharepoint.com/sites/contososite' of which the base part will be picked up from your current connection, the timezone 'UTC+01:00', the owner '[email protected]' and the template used will be STS#0, a TeamSite",
26+
SortOrder = 2)]
1827
[CmdletRelatedLink(
19-
Text ="Locale IDs",
28+
Text = "Locale IDs",
2029
Url = "http://go.microsoft.com/fwlink/p/?LinkId=242911Id=242911")]
2130
[CmdletRelatedLink(
22-
Text = "Resource Usage Limits on Sandboxed Solutions in SharePoint 2010",
31+
Text = "Resource Usage Limits on Sandboxed Solutions in SharePoint 2010",
2332
Url = "http://msdn.microsoft.com/en-us/library/gg615462.aspx.")]
2433
[CmdletRelatedLink(
2534
Text = "Creating on-premises site collections using CSOM",
@@ -66,26 +75,54 @@ public class NewTenantSite : SPOAdminCmdlet
6675
[Parameter(Mandatory = false)]
6776
public SwitchParameter Wait;
6877

78+
[Parameter(Mandatory = false, HelpMessage = "Do not ask for confirmation.")]
79+
public SwitchParameter Force;
80+
6981
protected override void ExecuteCmdlet()
7082
{
83+
bool shouldContinue = true;
84+
if (!Url.ToLower().StartsWith("https://") && !Url.ToLower().StartsWith("http://"))
85+
{
86+
Uri uri = BaseUri;
87+
Url = $"{uri.ToString().TrimEnd('/')}/{Url.TrimStart('/')}";
88+
shouldContinue = ShouldContinue(string.Format(Resources.CreateSiteWithUrl0, Url), Resources.Confirm);
89+
}
90+
if (Force || shouldContinue)
91+
{
7192
#if ONPREMISES
72-
var entity = new SiteEntity();
73-
entity.Url = Url;
74-
entity.Title = Title;
75-
entity.SiteOwnerLogin = Owner;
76-
entity.Template = Template;
77-
entity.StorageMaximumLevel = StorageQuota;
78-
entity.StorageWarningLevel = StorageQuotaWarningLevel;
79-
entity.TimeZoneId = TimeZone;
80-
entity.UserCodeMaximumLevel = ResourceQuota;
81-
entity.UserCodeWarningLevel = ResourceQuotaWarningLevel;
82-
entity.Lcid = Lcid;
83-
84-
Tenant.CreateSiteCollection(entity);
93+
var entity = new SiteEntity();
94+
entity.Url = Url;
95+
entity.Title = Title;
96+
entity.SiteOwnerLogin = Owner;
97+
entity.Template = Template;
98+
entity.StorageMaximumLevel = StorageQuota;
99+
entity.StorageWarningLevel = StorageQuotaWarningLevel;
100+
entity.TimeZoneId = TimeZone;
101+
entity.UserCodeMaximumLevel = ResourceQuota;
102+
entity.UserCodeWarningLevel = ResourceQuotaWarningLevel;
103+
entity.Lcid = Lcid;
104+
105+
Tenant.CreateSiteCollection(entity);
85106
#else
86-
Tenant.CreateSiteCollection(Url, Title, Owner, Template, (int)StorageQuota, (int)StorageQuotaWarningLevel, TimeZone, (int)ResourceQuota, (int)ResourceQuotaWarningLevel, Lcid, RemoveDeletedSite, Wait);
107+
Func<TenantOperationMessage, bool> timeoutFunction = TimeoutFunction;
108+
109+
110+
Tenant.CreateSiteCollection(Url, Title, Owner, Template, (int)StorageQuota,
111+
(int)StorageQuotaWarningLevel, TimeZone, (int)ResourceQuota, (int)ResourceQuotaWarningLevel, Lcid,
112+
RemoveDeletedSite, Wait, Wait == true ? timeoutFunction : null);
87113
#endif
114+
}
88115
}
89116

117+
#if !ONPREMISES
118+
private bool TimeoutFunction(TenantOperationMessage message)
119+
{
120+
if (message == TenantOperationMessage.CreatingSiteCollection)
121+
{
122+
Host.UI.Write(".");
123+
}
124+
return Stopping;
125+
}
126+
#endif
90127
}
91128
}

Commands/Admin/RemoveTenantSite.cs

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,35 @@
55
using SharePointPnP.PowerShell.Commands.Base;
66
using Resources = SharePointPnP.PowerShell.Commands.Properties.Resources;
77
using System;
8+
using OfficeDevPnP.Core;
89

910
namespace SharePointPnP.PowerShell.Commands
1011
{
1112
[Cmdlet(VerbsCommon.Remove, "PnPTenantSite", ConfirmImpact = ConfirmImpact.High, SupportsShouldProcess = true)]
1213
[CmdletAlias("Remove-SPOTenantSite")]
1314
[CmdletHelp("Office365 only: Removes a site collection from the current tenant",
14-
Category = CmdletHelpCategory.TenantAdmin)]
15+
Category = CmdletHelpCategory.TenantAdmin)]
1516
[CmdletExample(
16-
Code = @"PS:> Remove-PnPTenantSite -Url https://tenant.sharepoint.com/sites/contoso",
17-
Remarks = @"This will remove the site collection with the url 'https://tenant.sharepoint.com/sites/contoso' and put it in the recycle bin.", SortOrder = 1)]
17+
Code = @"PS:> Remove-PnPTenantSite -Url https://tenant.sharepoint.com/sites/contoso",
18+
Remarks =
19+
@"This will remove the site collection with the url 'https://tenant.sharepoint.com/sites/contoso' and put it in the recycle bin.",
20+
SortOrder = 1)]
1821
[CmdletExample(
19-
Code = @"PS:> Remove-PnPTenantSite -Url https://tenant.sharepoint.com/sites/contoso -Force -SkipRecycleBin",
20-
Remarks = @"This will remove the site collection with the url 'https://tenant.sharepoint.com/sites/contoso' with force and it will skip the recycle bin.", SortOrder = 2)]
22+
Code = @"PS:> Remove-PnPTenantSite -Url https://tenant.sharepoint.com/sites/contoso -Force -SkipRecycleBin",
23+
Remarks =
24+
@"This will remove the site collection with the url 'https://tenant.sharepoint.com/sites/contoso' with force and it will skip the recycle bin.",
25+
SortOrder = 2)]
2126
[CmdletExample(
22-
Code = @"PS:> Remove-PnPTenantSite -Url https://tenant.sharepoint.com/sites/contoso -FromRecycleBin",
23-
Remarks = @"This will remove the site collection with the url 'https://tenant.sharepoint.com/sites/contoso' from the recycle bin.", SortOrder = 3)]
27+
Code = @"PS:> Remove-PnPTenantSite -Url https://tenant.sharepoint.com/sites/contoso -FromRecycleBin",
28+
Remarks =
29+
@"This will remove the site collection with the url 'https://tenant.sharepoint.com/sites/contoso' from the recycle bin.",
30+
SortOrder = 3)]
2431
public class RemoveSite : SPOAdminCmdlet
2532
{
2633
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, HelpMessage = "Specifies the full URL of the site collection that needs to be deleted")]
2734
public string Url;
2835

29-
[Parameter(Mandatory = false, HelpMessage = "Do not add to the trashcan when selected.")]
36+
[Parameter(Mandatory = false, HelpMessage = "Do not add to the tenant scoped recycle bin when selected.")]
3037
[Alias("SkipTrash")]
3138
public SwitchParameter SkipRecycleBin;
3239

@@ -35,27 +42,49 @@ public class RemoveSite : SPOAdminCmdlet
3542
public SwitchParameter Wait;
3643

3744
[Parameter(Mandatory = false, HelpMessage = "If specified, will search for the site in the Recycle Bin and remove it from there.")]
45+
[Obsolete("Use Clear-PnPTenantRecycleBinItem instead.")]
3846
public SwitchParameter FromRecycleBin;
39-
40-
41-
[Parameter(Mandatory = false, HelpMessage = "Do not ask for confirmation.")]
42-
public SwitchParameter Force;
47+
48+
[Parameter(Mandatory = false, HelpMessage = "Do not ask for confirmation.")] public SwitchParameter Force;
4349

4450
protected override void ExecuteCmdlet()
4551
{
52+
if (!Url.ToLower().StartsWith("https://") && !Url.ToLower().StartsWith("http://"))
53+
{
54+
Uri uri = BaseUri;
55+
Url = $"{uri.ToString().TrimEnd('/')}/{Url.TrimStart('/')}";
56+
}
57+
4658
if (Force || ShouldContinue(string.Format(Resources.RemoveSiteCollection0, Url), Resources.Confirm))
4759
{
60+
Func<TenantOperationMessage, bool> timeoutFunction = TimeoutFunction;
61+
62+
#pragma warning disable 618
4863
if (!FromRecycleBin)
64+
#pragma warning restore 618
4965
{
50-
Tenant.DeleteSiteCollection(Url, !SkipRecycleBin);
66+
67+
Tenant.DeleteSiteCollection(Url, !MyInvocation.BoundParameters.ContainsKey("SkipRecycleBin"), timeoutFunction);
5168
}
5269
else
5370
{
54-
Tenant.DeleteSiteCollectionFromRecycleBin(Url);
71+
Tenant.DeleteSiteCollectionFromRecycleBin(Url, true, timeoutFunction);
5572
}
73+
5674
}
5775
}
5876

77+
private bool TimeoutFunction(TenantOperationMessage message)
78+
{
79+
switch (message)
80+
{
81+
case TenantOperationMessage.DeletingSiteCollection:
82+
case TenantOperationMessage.RemovingDeletedSiteCollectionFromRecycleBin:
83+
Host.UI.Write(".");
84+
break;
85+
}
86+
return Stopping;
87+
}
5988
}
6089
}
6190
#endif

Commands/Admin/SetTenantSite.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
using SharePointPnP.PowerShell.CmdletHelpAttributes;
77
using SharePointPnP.PowerShell.Commands.Base;
88
using System.Collections.Generic;
9+
using System.Threading;
10+
using OfficeDevPnP.Core;
911
using OfficeDevPnP.Core.Entities;
1012

1113
namespace SharePointPnP.PowerShell.Commands
@@ -25,7 +27,7 @@ namespace SharePointPnP.PowerShell.Commands
2527
Remarks = @"This will set [email protected] as a site collection owner at 'https://contoso.sharepoint.com/sites/sales'.", SortOrder = 3)]
2628
public class SetTenantSite : SPOAdminCmdlet
2729
{
28-
[Parameter(Mandatory = false, HelpMessage = "Specifies the URL of the site", Position = 0, ValueFromPipeline = true)]
30+
[Parameter(Mandatory = true, HelpMessage = "Specifies the URL of the site", Position = 0, ValueFromPipeline = true)]
2931
public string Url;
3032

3133
[Parameter(Mandatory = false, HelpMessage = "Specifies the title of the site")]
@@ -52,9 +54,16 @@ public class SetTenantSite : SPOAdminCmdlet
5254
[Parameter(Mandatory = false, HelpMessage = "Specifies owners to add as site collection adminstrators. Can be both users and groups.")]
5355
public List<string> Owners;
5456

57+
[Parameter(Mandatory = false, HelpMessage = "Sets the lockstate of a site")]
58+
public SiteLockState LockState;
59+
60+
[Parameter(Mandatory = false, HelpMessage = "Wait for the operation to complete")]
61+
public SwitchParameter Wait;
5562
protected override void ExecuteCmdlet()
5663
{
57-
Tenant.SetSiteProperties(Url, title: Title, sharingCapability: Sharing, storageMaximumLevel: StorageMaximumLevel, allowSelfServiceUpgrade: AllowSelfServiceUpgrade, userCodeMaximumLevel: UserCodeMaximumLevel, userCodeWarningLevel: UserCodeWarningLevel);
64+
Func<TenantOperationMessage, bool> timeoutFunction = TimeoutFunction;
65+
66+
Tenant.SetSiteProperties(Url, title: Title, sharingCapability: Sharing, storageMaximumLevel: StorageMaximumLevel, allowSelfServiceUpgrade: AllowSelfServiceUpgrade, userCodeMaximumLevel: UserCodeMaximumLevel, userCodeWarningLevel: UserCodeWarningLevel, wait: Wait, timeoutFunction: Wait ? timeoutFunction : null );
5867

5968
if (Owners != null && Owners.Count > 0)
6069
{
@@ -66,7 +75,21 @@ protected override void ExecuteCmdlet()
6675
}
6776
Tenant.AddAdministrators(admins, new Uri(Url));
6877
}
78+
if (MyInvocation.BoundParameters.ContainsKey("LockState"))
79+
{
80+
Tenant.SetSiteLockState(Url, LockState, Wait, Wait ? timeoutFunction : null);
81+
}
82+
}
83+
84+
private bool TimeoutFunction(TenantOperationMessage message)
85+
{
86+
if (message == TenantOperationMessage.SettingSiteProperties ||message == TenantOperationMessage.SettingSiteLockState)
87+
{
88+
Host.UI.Write(".");
89+
}
90+
return Stopping;
6991
}
92+
7093
}
7194
}
7295
#endif

Commands/Apps/ImportAppPackage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected override void ExecuteCmdlet()
4747
{
4848
if (Force)
4949
{
50-
ClientContext.Site.ActivateFeature(Constants.APPSIDELOADINGFEATUREID);
50+
ClientContext.Site.ActivateFeature(Constants.FeatureId_Site_AppSideLoading);
5151
}
5252
AppInstance instance;
5353

@@ -81,7 +81,7 @@ protected override void ExecuteCmdlet()
8181

8282
if (Force)
8383
{
84-
ClientContext.Site.DeactivateFeature(Constants.APPSIDELOADINGFEATUREID);
84+
ClientContext.Site.DeactivateFeature(Constants.FeatureId_Site_AppSideLoading);
8585
}
8686
WriteObject(instance);
8787
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System;
2+
using System.Linq;
3+
using Microsoft.SharePoint.Client;
4+
using Microsoft.SharePoint.Client.Publishing;
5+
6+
namespace SharePointPnP.PowerShell.Commands.Base.PipeBinds
7+
{
8+
public sealed class ImageRenditionPipeBind
9+
{
10+
private ImageRendition _item;
11+
private readonly int? _id;
12+
private readonly string _name;
13+
public ImageRenditionPipeBind()
14+
{
15+
_item = null;
16+
_id = null;
17+
}
18+
19+
public ImageRenditionPipeBind(ImageRendition item)
20+
{
21+
_item = item;
22+
}
23+
24+
public ImageRenditionPipeBind(string idorname)
25+
{
26+
int id;
27+
28+
if (int.TryParse(idorname, out id))
29+
{
30+
_id = id;
31+
_name = null;
32+
}
33+
else
34+
{
35+
_id = null;
36+
_name = idorname;
37+
}
38+
}
39+
40+
public ImageRendition Item => _item;
41+
42+
public int? Id => _id;
43+
44+
internal ImageRendition GetImageRendition(Web web)
45+
{
46+
if (Item != null) return Item;
47+
var items = web.GetPublishingImageRenditions();
48+
if (_id.HasValue)
49+
{
50+
return items.FirstOrDefault(i => i.Id == _id);
51+
}
52+
53+
return items.FirstOrDefault(i => i.Name == _name);
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)