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

Commit 3331e8c

Browse files
Merge pull request #402 from OfficeDev/dev
August 2016 Release
2 parents d8635bc + 55a0ca6 commit 3331e8c

Some content is hidden

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

41 files changed

+597
-53
lines changed
80 KB
Binary file not shown.
80 KB
Binary file not shown.
88 KB
Binary file not shown.

Commands/Admin/GetWebTemplates.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace SharePointPnP.PowerShell.Commands
1414
[CmdletRelatedLink(Text = "Locale IDs", Url = "http://go.microsoft.com/fwlink/p/?LinkId=242911Id=242911")]
1515
public class GetWebTemplates : SPOAdminCmdlet
1616
{
17-
[Parameter(Mandatory = false, HelpMessage = "The language id like 1033 for English")]
17+
[Parameter(Mandatory = false, HelpMessage = "The language ID. For instance: 1033 for English")]
1818
public uint Lcid;
1919

2020
[Parameter(Mandatory = false, HelpMessage = "The version of SharePoint")]

Commands/Admin/RemoveTenantSite.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class RemoveSite : SPOAdminCmdlet
2525
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, HelpMessage = "Specifies the full URL of the site collection that needs to be deleted")]
2626
public string Url;
2727

28-
[Parameter(Mandatory = false, HelpMessage = "Do not add to the trashcan if selected.")]
28+
[Parameter(Mandatory = false, HelpMessage = "Do not add to the trashcan when selected.")]
2929
[Alias("SkipTrash")]
3030
public SwitchParameter SkipRecycleBin;
3131

Commands/Admin/SetTenantSite.cs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
#if !ONPREMISES
2+
using System;
23
using System.Management.Automation;
34
using Microsoft.Online.SharePoint.TenantManagement;
45
using Microsoft.SharePoint.Client;
56
using SharePointPnP.PowerShell.CmdletHelpAttributes;
67
using SharePointPnP.PowerShell.Commands.Base;
8+
using System.Collections.Generic;
9+
using OfficeDevPnP.Core.Entities;
710

811
namespace SharePointPnP.PowerShell.Commands
912
{
1013
[Cmdlet(VerbsCommon.Set, "SPOTenantSite")]
11-
[CmdletHelp(@"Office365 only: Uses the tenant API to set site information.",
14+
[CmdletHelp(@"Office365 only: Uses the tenant API to set site information.",
1215
Category = CmdletHelpCategory.TenantAdmin)]
1316
[CmdletExample(
1417
Code = @"PS:> Set-SPOTenantSite -Url https://contoso.sharepoint.com -Title 'Contoso Website' -Sharing Disabled",
15-
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)]
18+
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)]
19+
[CmdletExample(
20+
Code = @"PS:> Set-SPOTenantSite -Url https://contoso.sharepoint.com -Title 'Contoso Website' -StorageWarningLevel 8000 -StorageMaximumLevel 10000",
21+
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)]
22+
[CmdletExample(
23+
Code = @"PS:> Set-SPOTenantSite -Url https://contoso.sharepoint.com/sites/sales -Owners 'i:0#.f|membership|[email protected]'",
24+
Remarks = @"This will set [email protected] as a site collection owner at 'https://contoso.sharepoint.com/sites/sales'.", SortOrder = 3)]
1625
public class SetTenantSite : SPOAdminCmdlet
1726
{
18-
[Parameter(Mandatory = false, HelpMessage = "Specifies the URL of the site", Position=0, ValueFromPipeline=true)]
27+
[Parameter(Mandatory = false, HelpMessage = "Specifies the URL of the site", Position = 0, ValueFromPipeline = true)]
1928
public string Url;
2029

2130
[Parameter(Mandatory = false, HelpMessage = "Specifies the title of the site")]
@@ -39,11 +48,24 @@ public class SetTenantSite : SPOAdminCmdlet
3948
[Parameter(Mandatory = false, HelpMessage = "Specifies if the site administrator can upgrade the site collection")]
4049
public SwitchParameter? AllowSelfServiceUpgrade = null;
4150

51+
[Parameter(Mandatory = false, HelpMessage = "Specifies owners to add as site collection adminstrators. Can be both users and groups.")]
52+
public List<string> Owners;
53+
4254
protected override void ExecuteCmdlet()
4355
{
44-
Tenant.SetSiteProperties(Url, title:Title, sharingCapability: Sharing, storageMaximumLevel: StorageMaximumLevel, allowSelfServiceUpgrade: AllowSelfServiceUpgrade, userCodeMaximumLevel: UserCodeMaximumLevel, userCodeWarningLevel: UserCodeWarningLevel);
56+
Tenant.SetSiteProperties(Url, title: Title, sharingCapability: Sharing, storageMaximumLevel: StorageMaximumLevel, allowSelfServiceUpgrade: AllowSelfServiceUpgrade, userCodeMaximumLevel: UserCodeMaximumLevel, userCodeWarningLevel: UserCodeWarningLevel);
57+
58+
if (Owners != null && Owners.Count > 0)
59+
{
60+
var admins = new List<UserEntity>();
61+
foreach (string owner in Owners)
62+
{
63+
var userEntity = new UserEntity { LoginName = owner };
64+
admins.Add(userEntity);
65+
}
66+
Tenant.AddAdministrators(admins, new Uri(Url));
67+
}
4568
}
4669
}
47-
4870
}
4971
#endif

Commands/Base/ConnectSPOnline.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using System.Net;
88
using System.Security;
99
using System.Linq;
10+
using Microsoft.SharePoint.Client;
11+
using File = System.IO.File;
1012
#if !ONPREMISES
1113
using Microsoft.SharePoint.Client.CompliancePolicy;
1214
#endif
@@ -43,6 +45,10 @@ namespace SharePointPnP.PowerShell.Commands.Base
4345
dir",
4446
Remarks = @"This will prompt you for credentials and creates a context for the other PowerShell commands to use. It will also create a SPO:\\ drive you can use to navigate around the site",
4547
SortOrder = 6)]
48+
[CmdletExample(
49+
Code = @"PS:> Connect-SPOnline -Url https://yourserver -Credentials (Get-Credential) -AuthenticationMode FormsAuthentication",
50+
Remarks = @"This will prompt you for credentials and creates a context for the other PowerShell commands to use. It assumes your server is configured for Forms Based Authentication (FBA)",
51+
SortOrder = 7)]
4652
public class ConnectSPOnline : PSCmdlet
4753
{
4854
[Parameter(Mandatory = true, Position = 0, ParameterSetName = ParameterAttribute.AllParameterSets, ValueFromPipeline = true, HelpMessage = "The Url of the site collection to connect to.")]
@@ -81,6 +87,9 @@ public class ConnectSPOnline : PSCmdlet
8187
[Parameter(Mandatory = true, ParameterSetName = "Weblogin", HelpMessage = "If you want to connect to SharePoint with browser based login")]
8288
public SwitchParameter UseWebLogin;
8389

90+
[Parameter(Mandatory = false, ParameterSetName = "Main", HelpMessage = "Specify to use for instance use forms based authentication (FBA)")]
91+
public ClientAuthenticationMode AuthenticationMode = ClientAuthenticationMode.Default;
92+
8493
[Parameter(Mandatory = false, HelpMessage = "If you want to create a PSDrive connected to the URL")]
8594
public SwitchParameter CreateDrive;
8695

@@ -164,7 +173,7 @@ protected override void ProcessRecord()
164173
creds = Host.UI.PromptForCredential(Properties.Resources.EnterYourCredentials, "", "", "");
165174
}
166175
}
167-
SPOnlineConnection.CurrentConnection = SPOnlineConnectionHelper.InstantiateSPOnlineConnection(new Uri(Url), creds, Host, CurrentCredentials, MinimalHealthScore, RetryCount, RetryWait, RequestTimeout, SkipTenantAdminCheck);
176+
SPOnlineConnection.CurrentConnection = SPOnlineConnectionHelper.InstantiateSPOnlineConnection(new Uri(Url), creds, Host, CurrentCredentials, MinimalHealthScore, RetryCount, RetryWait, RequestTimeout, SkipTenantAdminCheck, AuthenticationMode);
168177
}
169178
WriteVerbose(string.Format("PnP PowerShell Cmdlets ({0}): Connected to {1}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), Url));
170179

Commands/Base/ExecuteQuery.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ namespace SharePointPnP.PowerShell.Commands.Base
77
[Cmdlet("Execute", "SPOQuery")]
88
[CmdletHelp("Executes any queued actions / changes on the SharePoint Client Side Object Model Context",
99
Category = CmdletHelpCategory.Base)]
10+
[CmdletExample(
11+
Code = @"PS:> Execute-SPOQuery -RetryCount 5",
12+
Remarks = @"This will execute any queued actions / changes on the SharePoint Client Side Object Model Context and will retry 5 times in case of throttling.", SortOrder = 1)]
1013

1114
public class ExecuteSPOQuery : SPOCmdlet
1215
{

Commands/Base/SPOnlineConnectionHelper.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ internal static SPOnlineConnection InstantiateWebloginConnection(Uri url, int mi
145145
throw new Exception("Error establishing a connection, context is null");
146146
}
147147

148-
internal static SPOnlineConnection InstantiateSPOnlineConnection(Uri url, PSCredential credentials, PSHost host, bool currentCredentials, int minimalHealthScore, int retryCount, int retryWait, int requestTimeout, bool skipAdminCheck = false)
148+
internal static SPOnlineConnection InstantiateSPOnlineConnection(Uri url, PSCredential credentials, PSHost host, bool currentCredentials, int minimalHealthScore, int retryCount, int retryWait, int requestTimeout, bool skipAdminCheck = false, ClientAuthenticationMode authenticationMode = ClientAuthenticationMode.Default)
149149
{
150150
var context = new PnPClientContext(url.AbsoluteUri);
151151
context.RetryCount = retryCount;
@@ -157,6 +157,15 @@ internal static SPOnlineConnection InstantiateSPOnlineConnection(Uri url, PSCred
157157
context.DisableReturnValueCache = true;
158158
#endif
159159
context.RequestTimeout = requestTimeout;
160+
161+
context.AuthenticationMode = authenticationMode;
162+
163+
if (authenticationMode == ClientAuthenticationMode.FormsAuthentication)
164+
{
165+
var formsAuthInfo = new FormsAuthenticationLoginInfo(credentials.UserName, EncryptionUtility.ToInsecureString(credentials.Password));
166+
context.FormsAuthenticationLoginInfo = formsAuthInfo;
167+
}
168+
160169
if (!currentCredentials)
161170
{
162171
try
@@ -219,7 +228,7 @@ internal static SPOnlineConnection InstantiateSPOnlineConnection(Uri url, PSCred
219228

220229
internal static SPOnlineConnection InstantiateAdfsConnection(Uri url, PSCredential credentials, PSHost host, int minimalHealthScore, int retryCount, int retryWait, int requestTimeout, bool skipAdminCheck = false)
221230
{
222-
var authManager = new OfficeDevPnP.Core.AuthenticationManager();
231+
var authManager = new OfficeDevPnP.Core.AuthenticationManager();
223232

224233
var networkCredentials = credentials.GetNetworkCredential();
225234

Commands/Branding/AddNavigationNode.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.SharePoint.Client;
1+
using Microsoft.SharePoint.Client;
22
using SharePointPnP.PowerShell.Commands.Enums;
33
using System;
44
using System.Management.Automation;
@@ -18,6 +18,14 @@ namespace SharePointPnP.PowerShell.Commands
1818
Code = @"PS:> Add-SPONavigationNode -Title ""Contoso USA"" -Url ""http://contoso.sharepoint.com/sites/contoso/usa/"" -Location ""QuickLaunch"" -Header ""Contoso""",
1919
Remarks = @"Adds a navigation node to the quicklaunch. The navigation node will have the title ""Contoso USA"", will link to the url ""http://contoso.sharepoint.com/sites/contoso/usa/"" and will have ""Contoso"" as a parent navigation node.",
2020
SortOrder = 2)]
21+
[CmdletExample(
22+
Code = @"PS:> Add-SPONavigationNode -Title ""Contoso"" -Url ""http://contoso.sharepoint.com/sites/contoso/"" -Location ""QuickLaunch"" -First",
23+
Remarks = @"Adds a navigation node to the quicklaunch, as the first item. The navigation node will have the title ""Contoso"" and will link to the url ""http://contoso.sharepoint.com/sites/contoso/""",
24+
SortOrder = 3)]
25+
[CmdletExample(
26+
Code = @"PS:> Add-SPONavigationNode -Title ""Contoso Pharmaceuticals"" -Url ""http://contoso.sharepoint.com/sites/contosopharma/"" -Location ""QuickLaunch"" -External",
27+
Remarks = @"Adds a navigation node to the quicklaunch. The navigation node will have the title ""Contoso Pharmaceuticals"" and will link to the external url ""http://contoso.sharepoint.com/sites/contosopharma/""",
28+
SortOrder = 4)]
2129
public class AddNavigationNode : SPOWebCmdlet
2230
{
2331
[Parameter(Mandatory = true, HelpMessage = "The location of the node to add. Either TopNavigationBar, QuickLaunch or SearchNav")]
@@ -31,6 +39,12 @@ public class AddNavigationNode : SPOWebCmdlet
3139

3240
[Parameter(Mandatory = false, HelpMessage = "Optionally value of a header entry to add the menu item to.")]
3341
public string Header;
42+
43+
[Parameter(Mandatory = false, HelpMessage = "Add the new menu item to beginning of the collection.")]
44+
public SwitchParameter First;
45+
46+
[Parameter(Mandatory = false, HelpMessage = "Indicates the destination URL is outside of the site collection.")]
47+
public SwitchParameter External;
3448

3549
protected override void ExecuteCmdlet()
3650
{
@@ -40,10 +54,7 @@ protected override void ExecuteCmdlet()
4054
ClientContext.ExecuteQueryRetry();
4155
Url = SelectedWeb.Url;
4256
}
43-
SelectedWeb.AddNavigationNode(Title, new Uri(Url), Header, Location);
57+
SelectedWeb.AddNavigationNode(Title, new Uri(Url), Header, Location, External.IsPresent, !First.IsPresent);
4458
}
45-
4659
}
47-
48-
4960
}

Commands/Branding/ApplyProvisioningTemplate.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers;
1010
using System.Collections;
1111
using System.Linq;
12+
using OfficeDevPnP.Core.Framework.Provisioning.Providers;
1213

1314
namespace SharePointPnP.PowerShell.Commands.Branding
1415
{
@@ -79,6 +80,9 @@ public class ApplyProvisioningTemplate : SPOWebCmdlet
7980
[Parameter(Mandatory = false, HelpMessage = "Allows you to specify ExtensbilityHandlers to execute while applying a template")]
8081
public ExtensibilityHandler[] ExtensibilityHandlers;
8182

83+
[Parameter(Mandatory = false, HelpMessage = "Allows you to specify ITemplateProviderExtension to execute while applying a template.")]
84+
public ITemplateProviderExtension[] TemplateProviderExtensions;
85+
8286
protected override void ExecuteCmdlet()
8387
{
8488
SelectedWeb.EnsureProperty(w => w.Url);
@@ -133,7 +137,7 @@ protected override void ExecuteCmdlet()
133137
throw new NotSupportedException("Only .pnp package files are supported from a SharePoint library");
134138
}
135139
}
136-
provisioningTemplate = provider.GetTemplate(templateFileName);
140+
provisioningTemplate = provider.GetTemplate(templateFileName, TemplateProviderExtensions);
137141

138142
if (provisioningTemplate == null) return;
139143

Commands/Branding/ConvertProvisioningTemplate.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,21 @@ protected override void BeginProcessing()
8888
}
8989
case XMLPnPSchemaVersion.V201508:
9090
{
91+
#pragma warning disable CS0618 // Type or member is obsolete
9192
formatter = XMLPnPSchemaFormatter.GetSpecificFormatter(XMLConstants.PROVISIONING_SCHEMA_NAMESPACE_2015_08);
93+
#pragma warning restore CS0618 // Type or member is obsolete
9294
break;
9395
}
9496
case XMLPnPSchemaVersion.V201512:
9597
{
9698
formatter = XMLPnPSchemaFormatter.GetSpecificFormatter(XMLConstants.PROVISIONING_SCHEMA_NAMESPACE_2015_12);
9799
break;
98100
}
101+
case XMLPnPSchemaVersion.V201605:
102+
{
103+
formatter = XMLPnPSchemaFormatter.GetSpecificFormatter(XMLConstants.PROVISIONING_SCHEMA_NAMESPACE_2016_05);
104+
break;
105+
}
99106
}
100107

101108
if (!string.IsNullOrEmpty(Out))

0 commit comments

Comments
 (0)