From ffdd1f89df28b046a050f375ab3af8da3e2f88c1 Mon Sep 17 00:00:00 2001 From: Kevin McDonnell Date: Thu, 7 Sep 2017 15:57:20 +0100 Subject: [PATCH 01/30] Added tests for Files starting with Get and Copy. Changed Copy to use local upload method instead of extension. Extended tests to allow for multiple site collections. --- Commands/Files/CopyFile.cs | 41 +++- Tests/FilesTest.cs | 257 ++++++++++++++++++++ Tests/PSTestScope.cs | 2 +- Tests/SharePointPnP.PowerShell.Tests.csproj | 1 + Tests/TestCommon.cs | 15 +- 5 files changed, 310 insertions(+), 6 deletions(-) create mode 100644 Tests/FilesTest.cs diff --git a/Commands/Files/CopyFile.cs b/Commands/Files/CopyFile.cs index 4216ac76e..41e47f2ba 100644 --- a/Commands/Files/CopyFile.cs +++ b/Commands/Files/CopyFile.cs @@ -255,8 +255,47 @@ private void UploadFile(File srcFile, Folder targetFolder, string filename = "") var binaryStream = srcFile.OpenBinaryStream(); _sourceContext.ExecuteQueryRetry(); if (string.IsNullOrWhiteSpace(filename)) filename = srcFile.Name; - targetFolder.UploadFile(filename, binaryStream.Value, OverwriteIfAlreadyExists); + this.UploadFileWithInvalidCharacters(targetFolder, filename, binaryStream.Value, OverwriteIfAlreadyExists); _targetContext.ExecuteQueryRetry(); } + + + private File UploadFileWithInvalidCharacters(Folder folder, string fileName, System.IO.Stream stream, bool overwriteIfExists) + { + if (fileName == null) + { + throw new ArgumentNullException(nameof(fileName)); + } + + if (stream == null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (string.IsNullOrWhiteSpace(fileName)) + { + throw new ArgumentException("Filename is required"); + } + /* + if (Regex.IsMatch(fileName, REGEX_INVALID_FILE_NAME_CHARS)) + { + throw new ArgumentException(CoreResources.FileFolderExtensions_UploadFile_The_argument_must_be_a_single_file_name_and_cannot_contain_path_characters_, nameof(fileName)); + } + */ + + // Create the file + var newFileInfo = new FileCreationInformation() + { + ContentStream = stream, + Url = fileName, + Overwrite = overwriteIfExists + }; + + var file = folder.Files.Add(newFileInfo); + folder.Context.Load(file); + folder.Context.ExecuteQueryRetry(); + + return file; + } } } diff --git a/Tests/FilesTest.cs b/Tests/FilesTest.cs new file mode 100644 index 000000000..379546b82 --- /dev/null +++ b/Tests/FilesTest.cs @@ -0,0 +1,257 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.SharePoint.Client; +using System.Management.Automation.Runspaces; +using System.Collections; +using System.Linq; +using System.Management.Automation; +using System.Text; + +namespace SharePointPnP.PowerShell.Tests +{ + [TestClass] + public class FilesTests + { + private const string targetLibraryRelativeUrl = "/sites/dev/Shared%20Documents"; + private const string targetLibraryName = "Documents"; + private const string targetLibraryDesc = "Documents library for Files testing"; + private const string targetFileName = "Testfile.txt"; + private const string targetFileContents = "Some random file contents"; + private const string targetCopyFolderName = "CopyDestination"; + private const string targetFileNameWithAmpersand = "Test & file.txt"; + private const string targetSite2LibraryRelativeUrl = "/sites/dev2/Shared%20Documents"; + + [TestInitialize] + public void Initialize() + { + //With thanks to Paolo Pialorsi https://piasys.com/blog/uploading-a-file-into-a-library-via-csom-even-if-the-library-does-not-exist/ + using (var ctx = TestCommon.CreateClientContext()) + { + ExceptionHandlingScope scope = new ExceptionHandlingScope(ctx); + using (scope.StartScope()) + { + using (scope.StartTry()) + { + Folder folder = ctx.Web.GetFolderByServerRelativeUrl(targetLibraryRelativeUrl); + } + using (scope.StartCatch()) + { + // Create the library, in case it doesn’t exist + ListCreationInformation lci = new ListCreationInformation(); + lci.Title = targetLibraryName; + lci.Description = targetLibraryDesc; + lci.TemplateType = (Int32)ListTemplateType.DocumentLibrary; + lci.QuickLaunchOption = QuickLaunchOptions.On; + List library = ctx.Web.Lists.Add(lci); + } + using (scope.StartFinally()) + { + Folder folder = ctx.Web.GetFolderByServerRelativeUrl(targetLibraryRelativeUrl); + FileCreationInformation fci = new FileCreationInformation(); + fci.Content = Encoding.ASCII.GetBytes(targetFileContents); + fci.Url = targetFileName; + fci.Overwrite = true; + File fileToUpload = folder.Files.Add(fci); + ctx.Load(fileToUpload); + + fci.Url = targetFileNameWithAmpersand; + fci.Overwrite = true; + fileToUpload = folder.Files.Add(fci); + ctx.Load(fileToUpload); + + folder.Folders.Add(targetCopyFolderName); + } + } + ctx.ExecuteQuery(); + } + } + + + [TestCleanup] + public void Cleanup() + { + using (var ctx = TestCommon.CreateClientContext()) + { + ExceptionHandlingScope scope = new ExceptionHandlingScope(ctx); + using (scope.StartScope()) + { + using (scope.StartTry()) + { + File initialFile = ctx.Web.GetFileByServerRelativeUrl(targetLibraryRelativeUrl + "/" + targetFileName); + if (initialFile != null) + { + initialFile.DeleteObject(); + } + Folder copyFolder = ctx.Web.GetFolderByServerRelativeUrl(targetLibraryRelativeUrl + "/" + targetCopyFolderName); + if (copyFolder != null) + { + copyFolder.DeleteObject(); + } + } + using (scope.StartCatch()) + { + // Ignore as file not created or already deleted + } + } + ctx.ExecuteQuery(); + } + + using (var ctx = TestCommon.CreateClientContextDev2()) + { + ExceptionHandlingScope scope = new ExceptionHandlingScope(ctx); + using (scope.StartScope()) + { + using (scope.StartTry()) + { + File initialFile = ctx.Web.GetFileByServerRelativeUrl(targetSite2LibraryRelativeUrl + "/" + targetFileName); + if (initialFile != null) + { + initialFile.DeleteObject(); + } + File ampersandFile = ctx.Web.GetFileByServerRelativeUrl(targetSite2LibraryRelativeUrl + "/" + targetFileNameWithAmpersand); + if (ampersandFile != null) + { + ampersandFile.DeleteObject(); + } + } + using (scope.StartCatch()) + { + // Ignore as file not created or already deleted + } + } + ctx.ExecuteQuery(); + } + } + + [TestMethod] + public void GetFile_AsListItem_Test() + { + using (var scope = new PSTestScope(true)) + { + var values = new Hashtable(); + values.Add("Title", "Test"); + //Get-PnPFile -Url /sites/project/_catalogs/themes/15/company.spcolor -AsFile", + var results = scope.ExecuteCommand("Get-PnPFile", + new CommandParameter("Url", System.IO.Path.Combine(targetLibraryRelativeUrl,targetFileName)), + new CommandParameter("AsListItem")); + + Assert.IsTrue(results.Any()); + + Assert.IsTrue(results[0].BaseObject.GetType() == typeof(Microsoft.SharePoint.Client.ListItem)); + } + } + + [TestMethod] + public void GetFile_AsFile_Test() + { + using (var scope = new PSTestScope(true)) + { + var results = scope.ExecuteCommand("Get-PnPFile", + new CommandParameter("Url", System.IO.Path.Combine(targetLibraryRelativeUrl, targetFileName)), + new CommandParameter("AsFile")); + + Assert.IsTrue(results.Any()); + + Assert.IsTrue(results[0].BaseObject.GetType() == typeof(Microsoft.SharePoint.Client.File)); + } + } + + [TestMethod] + public void CopyFileTest() + { + using (var scope = new PSTestScope(true)) + { + string sourceUrl = targetLibraryRelativeUrl + "/" + targetFileName; + string destinationUrl = targetLibraryRelativeUrl + "/" + targetCopyFolderName + "/" + targetFileName; + var results = scope.ExecuteCommand("Copy-PnPFile", + new CommandParameter("SourceUrl", sourceUrl), + new CommandParameter("TargetUrl", destinationUrl), + new CommandParameter("Force")); + + using (var ctx = TestCommon.CreateClientContext()) + { + File initialFile = ctx.Web.GetFileByServerRelativeUrl(destinationUrl); + if (initialFile == null) + { + Assert.Fail("Copied file cannot be found"); + } + } + } + } + + [TestMethod] + public void CopyFile_WithAmpersand_Test() + { + using (var scope = new PSTestScope(true)) + { + string sourceUrl = targetLibraryRelativeUrl + "/" + targetFileNameWithAmpersand; + string destinationUrl = targetLibraryRelativeUrl + "/" + targetCopyFolderName + "/" + targetFileNameWithAmpersand; + var results = scope.ExecuteCommand("Copy-PnPFile", + new CommandParameter("SourceUrl", sourceUrl), + new CommandParameter("TargetUrl", destinationUrl), + new CommandParameter("Force")); + + using (var ctx = TestCommon.CreateClientContext()) + { + File initialFile = ctx.Web.GetFileByServerRelativeUrl(destinationUrl); + if (initialFile == null) + { + Assert.Fail("Copied file cannot be found"); + } + } + } + } + + [TestMethod] + public void CopyFile_BetweenSiteCollections_Test() + { + using (var scope = new PSTestScope(true)) + { + string sourceUrl = targetLibraryRelativeUrl + "/" + targetFileName; + string destinationFolderUrl = targetSite2LibraryRelativeUrl; + string destinationFileUrl = targetSite2LibraryRelativeUrl + "/" + targetFileName; + var results = scope.ExecuteCommand("Copy-PnPFile", + new CommandParameter("SourceUrl", sourceUrl), + new CommandParameter("TargetUrl", destinationFolderUrl), + new CommandParameter("Force")); + + using (var ctx = TestCommon.CreateClientContextDev2()) + { + File initialFile = ctx.Web.GetFileByServerRelativeUrl(destinationFileUrl); + ctx.Load(initialFile); + ctx.ExecuteQuery(); + if (!initialFile.Exists) + { + Assert.Fail("Copied file cannot be found"); + } + } + } + } + + [TestMethod] + public void CopyFile_BetweenSiteCollectionsWithAmpersand_Test() + { + using (var scope = new PSTestScope(true)) + { + string sourceUrl = targetLibraryRelativeUrl + "/" + targetFileNameWithAmpersand; + string destinationFolderUrl = targetSite2LibraryRelativeUrl; + string destinationFileUrl = targetSite2LibraryRelativeUrl + "/" + targetFileNameWithAmpersand; + var results = scope.ExecuteCommand("Copy-PnPFile", + new CommandParameter("SourceUrl", sourceUrl), + new CommandParameter("TargetUrl", destinationFolderUrl), + new CommandParameter("Force")); + + using (var ctx = TestCommon.CreateClientContextDev2()) + { + File initialFile = ctx.Web.GetFileByServerRelativeUrl(destinationFileUrl); + ctx.Load(initialFile); + ctx.ExecuteQuery(); + if (!initialFile.Exists) + { + Assert.Fail("Copied file cannot be found"); + } + } + } + } + } +} diff --git a/Tests/PSTestScope.cs b/Tests/PSTestScope.cs index 6390cadb9..38ddc4f81 100644 --- a/Tests/PSTestScope.cs +++ b/Tests/PSTestScope.cs @@ -57,7 +57,7 @@ public PSTestScope(bool connect = true) } else { - if (!string.IsNullOrEmpty("AppId") && !string.IsNullOrEmpty("AppSecret")) + if (!string.IsNullOrEmpty(AppId) && !string.IsNullOrEmpty(AppSecret)) { // Use oAuth Token to authenticate if (!string.IsNullOrEmpty(Realm)) diff --git a/Tests/SharePointPnP.PowerShell.Tests.csproj b/Tests/SharePointPnP.PowerShell.Tests.csproj index b42b56bb7..16fd502aa 100644 --- a/Tests/SharePointPnP.PowerShell.Tests.csproj +++ b/Tests/SharePointPnP.PowerShell.Tests.csproj @@ -275,6 +275,7 @@ + diff --git a/Tests/TestCommon.cs b/Tests/TestCommon.cs index 98fc4cc87..de6f7e135 100644 --- a/Tests/TestCommon.cs +++ b/Tests/TestCommon.cs @@ -17,6 +17,7 @@ static TestCommon() // Read configuration data TenantUrl = ConfigurationManager.AppSettings["SPOTenantUrl"]; DevSiteUrl = ConfigurationManager.AppSettings["SPODevSiteUrl"]; + Dev2SiteUrl = ConfigurationManager.AppSettings["SPODev2SiteUrl"]; if (string.IsNullOrEmpty(TenantUrl) || string.IsNullOrEmpty(DevSiteUrl)) { @@ -77,6 +78,7 @@ static TestCommon() #region Properties public static string TenantUrl { get; set; } public static string DevSiteUrl { get; set; } + public static string Dev2SiteUrl { get; set; } static string UserName { get; set; } static SecureString Password { get; set; } static ICredentials Credentials { get; set; } @@ -107,6 +109,11 @@ public static ClientContext CreateClientContext() return CreateContext(DevSiteUrl, Credentials); } + public static ClientContext CreateClientContextDev2() + { + return CreateContext(Dev2SiteUrl, Credentials); + } + public static ClientContext CreateTenantClientContext() { return CreateContext(TenantUrl, Credentials); @@ -138,18 +145,18 @@ private static ClientContext CreateContext(string contextUrl, ICredentials crede { OfficeDevPnP.Core.AuthenticationManager am = new OfficeDevPnP.Core.AuthenticationManager(); - if (new Uri(DevSiteUrl).DnsSafeHost.Contains("spoppe.com")) + if (new Uri(contextUrl).DnsSafeHost.Contains("spoppe.com")) { - context = am.GetAppOnlyAuthenticatedContext(DevSiteUrl, SPOnlineConnectionHelper.GetRealmFromTargetUrl(new Uri(DevSiteUrl)), AppId, AppSecret, acsHostUrl: "windows-ppe.net", globalEndPointPrefix: "login"); + context = am.GetAppOnlyAuthenticatedContext(contextUrl, SPOnlineConnectionHelper.GetRealmFromTargetUrl(new Uri(contextUrl)), AppId, AppSecret, acsHostUrl: "windows-ppe.net", globalEndPointPrefix: "login"); } else { - context = am.GetAppOnlyAuthenticatedContext(DevSiteUrl, AppId, AppSecret); + context = am.GetAppOnlyAuthenticatedContext(contextUrl, AppId, AppSecret); } } else { - context = new ClientContext(DevSiteUrl); + context = new ClientContext(contextUrl); context.Credentials = Credentials; } From 40eb843642247a0b8fb58a849db0e5b5271d2c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Cat?= Date: Mon, 1 Oct 2018 15:56:21 -0700 Subject: [PATCH 02/30] Expand Aliases, Add explicit parameters --- .../Install-PowerShellPackageMangement.ps1 | 2 +- .../Install-SharePointPnPPowerShell.ps1 | 4 +- ...ll-SharePointPnPPowerShellHelperModule.ps1 | 18 ++-- .../CreateSites.ps1 | 6 +- .../DevRampUp-Demo-PnP-ProvisioningEngine.ps1 | Bin 2602 -> 2644 bytes .../DevRampUp-Demo-PnP-PSProvisioning.ps1 | Bin 5042 -> 5084 bytes .../ProvisionModernPagesAndWebParts.ps1 | 42 ++++----- .../Engine/mrgovernance.ps1 | 6 +- .../Engine/mrprovision.ps1 | 80 +++++++++--------- .../Engine/shared.ps1 | 24 +++--- 10 files changed, 91 insertions(+), 91 deletions(-) diff --git a/Samples/Modules.Install/Install-PowerShellPackageMangement.ps1 b/Samples/Modules.Install/Install-PowerShellPackageMangement.ps1 index 1934b4b67..5be565cf2 100644 --- a/Samples/Modules.Install/Install-PowerShellPackageMangement.ps1 +++ b/Samples/Modules.Install/Install-PowerShellPackageMangement.ps1 @@ -29,7 +29,7 @@ if (!(Get-command -Module PowerShellGet).count -gt 0) $URL = $Request.GetResponse() $Filename = $URL.ResponseUri.OriginalString.Split("/")[-1] $url.close() - $WC = New-Object System.Net.WebClient + $WC = New-Object -TypeName System.Net.WebClient $WC.DownloadFile($version,"$env:TEMP\$Filename") $WC.Dispose() diff --git a/Samples/Modules.Install/Install-SharePointPnPPowerShell.ps1 b/Samples/Modules.Install/Install-SharePointPnPPowerShell.ps1 index 17adfedca..682d23063 100644 --- a/Samples/Modules.Install/Install-SharePointPnPPowerShell.ps1 +++ b/Samples/Modules.Install/Install-SharePointPnPPowerShell.ps1 @@ -1,2 +1,2 @@ -Invoke-Expression (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/officedev/PnP-PowerShell/master/Samples/Modules.Install/Install-PowerShellPackageMangement.ps1') # We use this to install the PowerShell Package Manager for the PowerShell Gallery -Invoke-Expression (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/officedev/PnP-PowerShell/master/Samples/Modules.Install/Install-SharePointPnPPowerShellHelperModule.ps1') \ No newline at end of file +Invoke-Expression (New-Object -TypeName Net.WebClient).DownloadString('https://raw.githubusercontent.com/officedev/PnP-PowerShell/master/Samples/Modules.Install/Install-PowerShellPackageMangement.ps1') # We use this to install the PowerShell Package Manager for the PowerShell Gallery +Invoke-Expression (New-Object -TypeName Net.WebClient).DownloadString('https://raw.githubusercontent.com/officedev/PnP-PowerShell/master/Samples/Modules.Install/Install-SharePointPnPPowerShellHelperModule.ps1') \ No newline at end of file diff --git a/Samples/Modules.Install/Install-SharePointPnPPowerShellHelperModule.ps1 b/Samples/Modules.Install/Install-SharePointPnPPowerShellHelperModule.ps1 index cde094f52..de4b68c45 100644 --- a/Samples/Modules.Install/Install-SharePointPnPPowerShellHelperModule.ps1 +++ b/Samples/Modules.Install/Install-SharePointPnPPowerShellHelperModule.ps1 @@ -39,11 +39,11 @@ param ( if (!(Get-command -Module $moduleName).count -gt 0) { - Install-Module $moduleName -Force -SkipPublisherCheck + Install-Module -Name $moduleName -Force -SkipPublisherCheck } - Write-Output "The modules for $moduleVersion have been installed and can now be used" - Write-Output 'On the next release you can just run Update-Module -force to update this and other installed modules' + Write-Output -InputObject "The modules for $moduleVersion have been installed and can now be used" + Write-Output -InputObject 'On the next release you can just run Update-Module -force to update this and other installed modules' } function Request-SPOOrOnPremises @@ -51,9 +51,9 @@ function Request-SPOOrOnPremises [string]$title="Confirm" [string]$message="Which version of the Modules do you want to install?" - $SPO = New-Object System.Management.Automation.Host.ChoiceDescription "SharePoint &Online", "SharePoint Online" - $SP2016 = New-Object System.Management.Automation.Host.ChoiceDescription "SharePoint 201&6", "SharePoint 2016" - $SP2013 = New-Object System.Management.Automation.Host.ChoiceDescription "SharePoint 201&3", "SharePoint 2013" + $SPO = New-Object -TypeName System.Management.Automation.Host.ChoiceDescription -ArgumentList "SharePoint &Online", "SharePoint Online" + $SP2016 = New-Object -TypeName System.Management.Automation.Host.ChoiceDescription -ArgumentList "SharePoint 201&6", "SharePoint 2016" + $SP2013 = New-Object -TypeName System.Management.Automation.Host.ChoiceDescription -ArgumentList "SharePoint 201&3", "SharePoint 2013" $options = [System.Management.Automation.Host.ChoiceDescription[]]($SPO, $SP2016, $SP2013) $result = $host.ui.PromptForChoice($title, $message, $options, 0) @@ -69,12 +69,12 @@ function Request-SPOOrOnPremises if ((Get-command -Module PowerShellGet).count -gt 0) { - Write-Output 'PowerShellPackageManagement now installed we will now run the next command in 10 Seconds' + Write-Output -InputObject 'PowerShellPackageManagement now installed we will now run the next command in 10 Seconds' Start-Sleep -Seconds 10 Install-SharePointPnPPowerShellModule -ModuleToInstall (Request-SPOOrOnPremises) } else { - Write-Output "PowerShellPackageManagement is not installed on this Machine - Please run the below to install - you will need to Copy and Paste it as i'm not doing everything for you ;-)" - Write-Output "Invoke-Expression (New-Object Net.WebClient).DownloadString('http://bit.ly/PSPackManInstall')" + Write-Output -InputObject "PowerShellPackageManagement is not installed on this Machine - Please run the below to install - you will need to Copy and Paste it as i'm not doing everything for you ;-)" + Write-Output -InputObject "Invoke-Expression (New-Object -TypeName Net.WebClient).DownloadString('http://bit.ly/PSPackManInstall')" } diff --git a/Samples/Provisioning.CreateSitesFromCsv/CreateSites.ps1 b/Samples/Provisioning.CreateSitesFromCsv/CreateSites.ps1 index c8b915bb9..03c567de7 100644 --- a/Samples/Provisioning.CreateSitesFromCsv/CreateSites.ps1 +++ b/Samples/Provisioning.CreateSitesFromCsv/CreateSites.ps1 @@ -46,7 +46,7 @@ else # Prompts for credentials, if not found in the Windows Credential Manager. $email = Read-Host -Prompt "Please enter tenant admin email" $pass = Read-host -AsSecureString "Please enter tenant admin password" - $credentials = New-Object –TypeName "System.Management.Automation.PSCredential" –ArgumentList $email, $pass + $credentials = New-Object -TypeName "System.Management.Automation.PSCredential" –ArgumentList $email, $pass } if($credentials -eq $null -or $csvConfig -eq $null) @@ -67,7 +67,7 @@ foreach ($item in $csvConfig) Write-Host "Provisioning site collection $siteUrl" -ForegroundColor Yellow - if(Get-PnPTenantSite | where {$_.Url -eq $siteUrl}) + if(Get-PnPTenantSite | where-Object -FilterScript {$_.Url -eq $siteUrl}) { Write-Host "Site collection $siteUrl exists. Moving to the next one." -ForegroundColor Yellow continue @@ -87,7 +87,7 @@ foreach ($item in $csvConfig) Write-Host "Provisioning sub web $siteUrl." -ForegroundColor Yellow - if(Get-PnPSubWebs | where {$_.Url -eq $siteUrl}) + if(Get-PnPSubWebs | where-Object -FilterScript {$_.Url -eq $siteUrl}) { Write-Host "Sub web $siteUrl exists. Moving to the next one." -ForegroundColor Yellow continue diff --git a/Samples/Provisioning.CreateWithEngine/DevRampUp-Demo-PnP-ProvisioningEngine.ps1 b/Samples/Provisioning.CreateWithEngine/DevRampUp-Demo-PnP-ProvisioningEngine.ps1 index 9a4ab6fa8f60ece2c9a52e686356f2add998b1db..5a7c825f7f4eb86ae2a687a8c2625db7a292d4c7 100644 GIT binary patch delta 53 zcmZ1_az$hTr=~80KSL5j7DFmSGD8W20)sAt8$%{T4v?M7P{a@n6fFYs3m8f^|L4$V F1OP$j3=04N delta 11 Scmca2vPxtD=VmQVEk*ztwgX`R diff --git a/Samples/Provisioning.CreateWithPowerShell/DevRampUp-Demo-PnP-PSProvisioning.ps1 b/Samples/Provisioning.CreateWithPowerShell/DevRampUp-Demo-PnP-PSProvisioning.ps1 index b2cfb4d8d18c907f84f2de312f8e19041a06bb92..986ca121b8afb69f2370058bb17121920d2e7a24 100644 GIT binary patch delta 54 zcmdm_en)*nmyo6|gFizOLl#3SLo!1Ng93vtgBwF8Lk^Ig%231*3=}N_@(UPBHg^hX GG6Dc>vJ7?r delta 12 TcmcbkzDa#Um(b=dLK=(!B;*9k diff --git a/Samples/Provisioning.ModernListLibraryWebPartsFromXlsx/ProvisionModernPagesAndWebParts.ps1 b/Samples/Provisioning.ModernListLibraryWebPartsFromXlsx/ProvisionModernPagesAndWebParts.ps1 index 914dbb2b8..f9a674495 100644 --- a/Samples/Provisioning.ModernListLibraryWebPartsFromXlsx/ProvisionModernPagesAndWebParts.ps1 +++ b/Samples/Provisioning.ModernListLibraryWebPartsFromXlsx/ProvisionModernPagesAndWebParts.ps1 @@ -106,12 +106,12 @@ function Add-PnPModernListWebPart() { } If (($Section -eq 0) -and ($Column -eq 0)) { - Write-Warning "The Section and Column fields for the [$WebPartTitle] web part have been left blank or have zero values" + Write-Warning -Message "The Section and Column fields for the [$WebPartTitle] web part have been left blank or have zero values" try { Add-PnPClientSideWebPart -Page $PageName -DefaultWebPartType List -WebPartProperties $webPartProperties } catch { - Write-Error "Unable to add [$WebPartTitle] web part to the [$PageName] page. Check that that there is a section [$Section] with [$Column] columns" + Write-Error -Message "Unable to add [$WebPartTitle] web part to the [$PageName] page. Check that that there is a section [$Section] with [$Column] columns" } } Else { @@ -119,45 +119,45 @@ function Add-PnPModernListWebPart() { Add-PnPClientSideWebPart -Page $PageName -DefaultWebPartType List -WebPartProperties $webPartProperties -Section $Section -Column $Column -ErrorAction Stop #-Order $Order } catch { - Write-Error "Unable to add [$WebPartTitle] web part to the [$PageName] page. Check that that there is a section [$Section] with [$Column] columns" + Write-Error -Message "Unable to add [$WebPartTitle] web part to the [$PageName] page. Check that that there is a section [$Section] with [$Column] columns" } } } #Import 'Site' worksheet from the excel configuration spreadsheet try { - Write-Verbose "Importing site worksheet from the excel configuration file: [$configFilePath]" + Write-Verbose -Message "Importing site worksheet from the excel configuration file: [$configFilePath]" $xlSiteSheet = Import-Excel -Path $configFilePath -WorkSheetname Site #Opens the excel file and imports the Site worksheet } catch { - Write-Error "Unable to open spreadsheet from [$configFilePath] or 'Site' worksheet does not exist" + Write-Error -Message "Unable to open spreadsheet from [$configFilePath] or 'Site' worksheet does not exist" EXIT } #Save site url to a variable and connect to the site try { - Write-Verbose "Importing site url from the site worksheet." + Write-Verbose -Message "Importing site url from the site worksheet." $site = $xlSiteSheet[0].'TargetSiteUrl' #gets the first site url value from the TargetSiteUrl column - Write-Verbose "Connecting to site: $site" + Write-Verbose -Message "Connecting to site: $site" Connect-PnPOnline -Url $site } catch { - Write-Error "Unable to open site at [$site]" + Write-Error -Message "Unable to open site at [$site]" EXIT } #Import 'ModernPages' worksheet from the excel configuration spreadsheet try { - Write-Verbose "Importing ModernPages worksheet from the excel configuration file." + Write-Verbose -Message "Importing ModernPages worksheet from the excel configuration file." $xlPagesSheet = Import-Excel -Path $configFilePath -WorkSheetname ModernPages #Imports the Libraries worksheet } catch { - Write-Error "Unable to open spreadsheet from [$configFilePath] or 'ModernPages' worksheet does not exist." + Write-Error -Message "Unable to open spreadsheet from [$configFilePath] or 'ModernPages' worksheet does not exist." EXIT } -Write-Verbose "Begin adding ModernPages to the site." +Write-Verbose -Message "Begin adding ModernPages to the site." #Import each worksheet row and add modern site pages and relevant sections to the site ForEach ($row in $xlPagesSheet) { @@ -167,11 +167,11 @@ ForEach ($row in $xlPagesSheet) { #Add new modern site page try { - Write-Verbose "Adding the $page page with $layout layout." + Write-Verbose -Message "Adding the $page page with $layout layout." Add-PnPClientSidePage -Name $page -LayoutType $layout } catch { - Write-Warning "Unable to add [$page] page." + Write-Warning -Message "Unable to add [$page] page." } #Add sections to the new page (in the order specified in the worksheet) @@ -181,12 +181,12 @@ ForEach ($row in $xlPagesSheet) { $sectionOrder = 1 ForEach ($section in $arraySections) { - Write-Verbose "Adding the $section section to the $page page. Section order is $sectionOrder." + Write-Verbose -Message "Adding the $section section to the $page page. Section order is $sectionOrder." try { Add-PnPClientSidePageSection -Page $page -SectionTemplate $section -Order $sectionOrder } catch { - Write-Warning "Unable to add [$section] section to [$page] page. Ensure [$section] is a valid Section Template value (e.g. OneColumn, TwoColumn, ThreeColumn etc)" + Write-Warning -Message "Unable to add [$section] section to [$page] page. Ensure [$section] is a valid Section Template value (e.g. OneColumn, TwoColumn, ThreeColumn etc)" } $sectionOrder++ } @@ -194,15 +194,15 @@ ForEach ($row in $xlPagesSheet) { } try { - Write-Verbose "Importing ModernListLibraryWebParts worksheet from the excel configuration file." + Write-Verbose -Message "Importing ModernListLibraryWebParts worksheet from the excel configuration file." $xlWebPartsSheet = Import-Excel -Path $configFilePath -WorkSheetname ModernListLibraryWebParts #Imports the Libraries worksheet } catch { - Write-Error "Unable to open spreadsheet from [$configFilePath] or 'ModernListLibraryWebParts' worksheet does not exist." + Write-Error -Message "Unable to open spreadsheet from [$configFilePath] or 'ModernListLibraryWebParts' worksheet does not exist." EXIT } -Write-Verbose "Begin adding Modern List / Library web parts to pages:" +Write-Verbose -Message "Begin adding Modern List / Library web parts to pages:" #iterate through the worksheet rows and add web parts to the pages ForEach ($row in $xlWebPartsSheet) { @@ -216,9 +216,9 @@ ForEach ($row in $xlWebPartsSheet) { $wpTitle = $row.'WebPartTitle'; #saves value in WebPartTitle column to a variable $wpHeight = $row.'WebPartHeight'; #saves value in WebPartHeight column to a variable - Write-Verbose "Adding web part to the '$page' page with title [$wpTitle]" - Write-Verbose "web part will be added with '$viewName' view for the '$listLibraryName' $wpType" - Write-Verbose "web part will be added to column $column in section $section height is set to $wpHeight" #order is: $order + Write-Verbose -Message "Adding web part to the '$page' page with title [$wpTitle]" + Write-Verbose -Message "web part will be added with '$viewName' view for the '$listLibraryName' $wpType" + Write-Verbose -Message "web part will be added to column $column in section $section height is set to $wpHeight" #order is: $order Add-PnPModernListWebPart -PageName $page -WebPartType $wpType -ListName $listLibraryName -ViewName $viewName -WebPartHeight $wpHeight -WebPartTitle $wpTitle -Section $section -Column $column #-Order $order } diff --git a/Samples/Provisioning.SelfHostedWithAzureWebJob/Engine/mrgovernance.ps1 b/Samples/Provisioning.SelfHostedWithAzureWebJob/Engine/mrgovernance.ps1 index ef187f2c8..0353ccb20 100644 --- a/Samples/Provisioning.SelfHostedWithAzureWebJob/Engine/mrgovernance.ps1 +++ b/Samples/Provisioning.SelfHostedWithAzureWebJob/Engine/mrgovernance.ps1 @@ -4,7 +4,7 @@ param( . $PSScriptRoot/shared.ps1 -Write-Output @" +Write-Output -InputObject @" ___ ___ _____ | \/ | | __ \ | . . |_ __ | | \/ _____ _____ _ __ _ __ __ _ _ __ ___ ___ @@ -18,7 +18,7 @@ Write-Output @" $variablesSet = CheckEnvironmentalVariables if ($variablesSet -eq $false) { - Write-Output "Missing one of the following environmental variables: TenantURL, PrimarySiteCollectionOwnerEmail, SiteDirectoryUrl, AppId, AppSecret" + Write-Output -InputObject "Missing one of the following environmental variables: TenantURL, PrimarySiteCollectionOwnerEmail, SiteDirectoryUrl, AppId, AppSecret" exit } Connect -Url "$tenantURL$siteDirectorySiteUrl" @@ -32,7 +32,7 @@ foreach ($site in $res.ResultRows) { Connect -Url "$tenantURL$siteDirectorySiteUrl" $siteItem = Get-PnPListItem -List $siteDirectoryList -Id $itemId - Write-Output "Processing $url - $itemId" + Write-Output -InputObject "Processing $url - $itemId" if ($syncPermissions) { SyncPermissions -siteUrl $url -item $siteItem } diff --git a/Samples/Provisioning.SelfHostedWithAzureWebJob/Engine/mrprovision.ps1 b/Samples/Provisioning.SelfHostedWithAzureWebJob/Engine/mrprovision.ps1 index 1d8e8537f..8e9a4ef9e 100644 --- a/Samples/Provisioning.SelfHostedWithAzureWebJob/Engine/mrprovision.ps1 +++ b/Samples/Provisioning.SelfHostedWithAzureWebJob/Engine/mrprovision.ps1 @@ -46,27 +46,27 @@ function EnsureSite { Connect -Url $tenantAdminUrl $site = Get-PnPTenantSite -Url $siteUrl -ErrorAction SilentlyContinue if ( $? -eq $false) { - Write-Output "Site at $siteUrl does not exist - let's create it" + Write-Output -InputObject "Site at $siteUrl does not exist - let's create it" $site = New-PnPTenantSite -Title $title -Url $siteUrl -Owner $siteCollectionAdmin -TimeZone 3 -Description $description -Lcid 1033 -Template "STS#0" -RemoveDeletedSite:$true -Wait if ($? -eq $false) { # send e-mail $mailHeadBody = GetMailContent -email $owner.Email -mailFile "fail" - Write-Output "Sending fail mail to $ownerAddresses" + Write-Output -InputObject "Sending fail mail to $ownerAddresses" Send-PnPMail -To $ownerAddresses -Subject $mailHeadBody[0] -Body ($mailHeadBody[1] -f $siteUrl) - Write-Error "Something happened" + Write-Error -Message "Something happened" UpdateStatus -id $siteEntryId -status 'Failed' return; } } elseif ($site.Status -ne "Active") { - Write-Output "Site at $siteUrl already exist" + Write-Output -InputObject "Site at $siteUrl already exist" while ($true) { # Wait for site to be ready $site = Get-PnPTenantSite -Url $siteUrl if ( $site.Status -eq "Active" ) { break; } - Write-Output "Site not ready" + Write-Output -InputObject "Site not ready" Start-Sleep -s 20 } } @@ -77,50 +77,50 @@ function EnsureSecurityGroups([string]$siteUrl, [string]$title, [string[]]$owner $visitorsGroup = Get-PnPGroup -AssociatedVisitorGroup -ErrorAction SilentlyContinue if ( $? -eq $false) { - Write-Output "Creating visitors group" + Write-Output -InputObject "Creating visitors group" $visitorsGroup = New-PnPGroup -Title "$title Visitors" -Owner $siteCollectionAdmin Set-PnPGroup -Identity $visitorsGroup -SetAssociatedGroup Visitors } $membersGroup = Get-PnPGroup -AssociatedMemberGroup -ErrorAction SilentlyContinue if ( $? -eq $false) { - Write-Output "Creating members group" + Write-Output -InputObject "Creating members group" $membersGroup = New-PnPGroup -Title "$title Members" -Owner $siteCollectionAdmin Set-PnPGroup -Identity $membersGroup -SetAssociatedGroup Members } $ownersGroup = Get-PnPGroup -AssociatedOwnerGroup -ErrorAction SilentlyContinue if ( $? -eq $false) { - Write-Output "Creating owners group" + Write-Output -InputObject "Creating owners group" $ownersGroup = New-PnPGroup -Title "$title Owners" -Owner $siteCollectionAdmin Set-PnPGroup -Identity $ownersGroup -SetAssociatedGroup Owners } if ($owners -ne $null) { - $existingOwners = @($ownersGroup.Users | select -ExpandProperty LoginName) + $existingOwners = @($ownersGroup.Users | Select-Object -ExpandProperty LoginName) foreach ($login in $owners) { if (-not $existingOwners.Contains($login)) { - Write-Output "`tAdding owner: $login" + Write-Output -InputObject "`tAdding owner: $login" Add-PnPUserToGroup -Identity $ownersGroup -LoginName $login } } } if ($members -ne $null) { - $existingMembers = @($membersGroup.Users | select -ExpandProperty LoginName) + $existingMembers = @($membersGroup.Users | Select-Object -ExpandProperty LoginName) foreach ($login in $members) { if (-not $existingOwners.Contains($login)) { - Write-Output "`tAdding member: $login" + Write-Output -InputObject "`tAdding member: $login" Add-PnPUserToGroup -Identity $membersGroup -LoginName $login } } } if ($visitors -ne $null) { - $existingVisitors = @($visitorsGroup.Users | select -ExpandProperty LoginName) + $existingVisitors = @($visitorsGroup.Users | Select-Object -ExpandProperty LoginName) foreach ($login in $visitors) { if (-not $existingOwners.Contains($login)) { - Write-Output "`tAdding visitor: $login" + Write-Output -InputObject "`tAdding visitor: $login" Add-PnPUserToGroup -Identity $visitorsGroup -LoginName $login } } @@ -132,7 +132,7 @@ function ApplyTemplate([string]$siteUrl, [string]$templateUrl, [string]$template $appliedTemplates = Get-PnPPropertyBag -Key $propBagTemplateInfoStampKey if ((-not $appliedTemplates.Contains("|$templateName|") -or $Force)) { - Write-Output "`tApplying template $templateName to $siteUrl" + Write-Output -InputObject "`tApplying template $templateName to $siteUrl" Apply-PnPProvisioningTemplate -Path $templateUrl if ($? -eq $true) { $appliedTemplates = "$appliedTemplates|$templateName|" @@ -140,13 +140,13 @@ function ApplyTemplate([string]$siteUrl, [string]$templateUrl, [string]$template } } else { - Write-Output "`tTemplate $templateName already applied to $siteUrl" + Write-Output -InputObject "`tTemplate $templateName already applied to $siteUrl" } } function SetSiteUrl($siteItem, $siteUrl, $title) { Connect -Url "$tenantURL$siteDirectorySiteUrl" - Write-Output "`tSetting site URL to $siteUrl" + Write-Output -InputObject "`tSetting site URL to $siteUrl" Set-PnPListItem -List $siteDirectoryList -Identity $siteItem["ID"] -Values @{"$($columnPrefix)SiteURL" = "$siteUrl, $title"} -ErrorAction SilentlyContinue >$null 2>&1 } @@ -166,7 +166,7 @@ function SendReadyEmail() { if ( -not [string]::IsNullOrWhiteSpace($toEmail) ) { $mailHeadBody = GetMailContent -email $toEmail -mailFile "welcome" - Write-Output "Sending ready mail to $toEmail and $ccEmails" + Write-Output -InputObject "Sending ready mail to $toEmail and $ccEmails" Send-PnPMail -To $toEmail -Cc $ccEmails -Subject ($mailHeadBody[0] -f $title) -Body ($mailHeadBody[1] -f $title, $siteUrl) } } @@ -179,7 +179,7 @@ function Apply-TemplateConfigurations($siteUrl, $siteItem, $templateConfiguratio $subModules = $siteItem["$($columnPrefix)SubModules"] if ($templateConfig -ne $null) { - $chosenTemplateConfig = $templateConfigurationItems |? Id -eq $templateConfig.LookupId + $chosenTemplateConfig = $templateConfigurationItems | Where-Object -Property Id -eq $templateConfig.LookupId $hasTemplate = Get-PnPPropertyBag -Key $propBagTemplateNameStampKey if (-not $hasTemplate) { @@ -190,7 +190,7 @@ function Apply-TemplateConfigurations($siteUrl, $siteItem, $templateConfiguratio $chosenSubModules = $chosenTemplateConfig["$($columnPrefix)SubModules"] if ($chosenBaseTemplate -ne $null) { - $pnpTemplate = $baseModuleItems |? Id -eq $chosenBaseTemplate.LookupId + $pnpTemplate = $baseModuleItems | Where-Object -Property Id -eq $chosenBaseTemplate.LookupId $pnpUrl = $tenantUrl + $pnpTemplate["FileRef"] $templateName = $pnpTemplate["FileLeafRef"] ApplyTemplate -siteUrl $siteUrl -templateUrl $pnpUrl -templateName $templateName @@ -202,7 +202,7 @@ function Apply-TemplateConfigurations($siteUrl, $siteItem, $templateConfiguratio } if ($chosenSubModules -ne $null) { foreach ($module in $chosenSubModules) { - $pnpTemplate = $subModuleItems |? Id -eq $module.LookupId + $pnpTemplate = $subModuleItems | Where-Object -Property Id -eq $module.LookupId $pnpUrl = $tenantUrl + $pnpTemplate["FileRef"] $templateName = $pnpTemplate["FileLeafRef"] ApplyTemplate -siteUrl $siteUrl -templateUrl $pnpUrl -templateName $templateName @@ -214,24 +214,24 @@ function Apply-TemplateConfigurations($siteUrl, $siteItem, $templateConfiguratio } } if ($allGood) { - Write-Output "`tTemplate $($chosenTemplateConfig["Title"]) applied" + Write-Output -InputObject "`tTemplate $($chosenTemplateConfig["Title"]) applied" Set-PnPPropertyBagValue -Key $propBagTemplateNameStampKey -Value $chosenTemplateConfig["Title"] } } } foreach ($module in $subModules) { - $pnpTemplate = $subModuleItems |? Id -eq $module.LookupId + $pnpTemplate = $subModuleItems | Where-Object -Property Id -eq $module.LookupId $pnpUrl = $tenantUrl + $pnpTemplate["FileRef"] ApplyTemplate -siteUrl $siteUrl -templateUrl $pnpUrl -templateName $pnpTemplate["FileLeafRef"] } # Ensure list is updated with all applied modules Connect -Url $siteUrl - $appliedTemplates = (Get-PnPPropertyBag -Key $propBagTemplateInfoStampKey).Split('|') |? {$_} #remove empty lines - $ids = $appliedTemplates | % { + $appliedTemplates = (Get-PnPPropertyBag -Key $propBagTemplateInfoStampKey).Split('|') | Where-Object -FilterScript {$_} #remove empty lines + $ids = $appliedTemplates | Foreach-Object -Process { $name = $_ - $subModuleItems |? {$_["FileLeafRef"] -eq $name} | select -ExpandProperty Id + $subModuleItems | Where-Object -FilterScript {$_["FileLeafRef"] -eq $name} | Select-Object -ExpandProperty Id } Connect -Url "$tenantURL$siteDirectorySiteUrl" Set-PnPListItem -List $siteDirectoryList -Identity $siteItem["ID"] -Values @{"$($columnPrefix)SubModules" = $ids} -ErrorAction SilentlyContinue >$null 2>&1 @@ -242,7 +242,7 @@ function SyncMetadata($siteUrl, $title, $description) { Connect -Url $siteUrl $web = Get-PnPWeb -Includes Description if ($web.Title -ne $title -or $web.Description -ne $description) { - Write-Output "`tSync title/description to $siteUrl" + Write-Output -InputObject "`tSync title/description to $siteUrl" Set-PnPWeb -Title $title -Description $description } } @@ -276,7 +276,7 @@ function GetRecentlyUpdatedItems($IntervalMinutes) { } } -Write-Output @" +Write-Output -InputObject @" ___ ___ ______ _ _ | \/ | | ___ \ (_) (_) | . . |_ __ | |_/ / __ _____ ___ ___ _ ___ _ __ @@ -290,7 +290,7 @@ Write-Output @" $variablesSet = CheckEnvironmentalVariables if ($variablesSet -eq $false) { - Write-Output "Missing one of the following environmental variables: TenantURL, PrimarySiteCollectionOwnerEmail, SiteDirectoryUrl, AppId, AppSecret" + Write-Output -InputObject "Missing one of the following environmental variables: TenantURL, PrimarySiteCollectionOwnerEmail, SiteDirectoryUrl, AppId, AppSecret" exit } @@ -301,7 +301,7 @@ $subModuleItems = @(Get-PnPListItem -List $subModulesLibrary) $siteDirectoryItems = GetRecentlyUpdatedItems -Interval $timerIntervalMinutes if (!$siteDirectoryItems -or ($siteDirectoryItems -ne $null -and (0 -eq $siteDirectoryItems.Count))) { - Write-Output "No site requests detected last $timerIntervalMinutes minutes" + Write-Output -InputObject "No site requests detected last $timerIntervalMinutes minutes" } foreach ($siteItem in $siteDirectoryItems) { @@ -313,19 +313,19 @@ foreach ($siteItem in $siteDirectoryItems) { $title = $siteItem["Title"] $description = $siteItem["$($columnPrefix)ProjectDescription"] - $ownerEmailAddresses = @(@($siteItem["$($columnPrefix)SiteOwners"]) |? {-not [String]::IsNullOrEmpty($_.Email)} | select -ExpandProperty Email) + $ownerEmailAddresses = @(@($siteItem["$($columnPrefix)SiteOwners"]) | Where-Object -FilterScript {-not [String]::IsNullOrEmpty($_.Email)} | Select-Object -ExpandProperty Email) $siteStatus = $siteItem["$($columnPrefix)SiteStatus"] - $ownerEmailAddresses = $ownerEmailAddresses | select -uniq | sort + $ownerEmailAddresses = $ownerEmailAddresses | Select-Object -Unique | Sort-Object - $businessOwnerEmailAddress = @($siteItem["$($columnPrefix)BusinessOwner"] |? {-not [String]::IsNullOrEmpty($_.Email)} | select -ExpandProperty Email) + $businessOwnerEmailAddress = @($siteItem["$($columnPrefix)BusinessOwner"] | Where-Object -FilterScript {-not [String]::IsNullOrEmpty($_.Email)} | Select-Object -ExpandProperty Email) - $owners = @($siteItem["$($columnPrefix)SiteOwners"]) | select -ExpandProperty LookupId - $owners = @($owners | % { GetLoginName -lookupId $_ }) - $members = @($siteItem["$($columnPrefix)SiteMembers"]) | select -ExpandProperty LookupId - $members = @($members | % { GetLoginName -lookupId $_ }) - $visitors = @($siteItem["$($columnPrefix)SiteVisitors"]) | select -ExpandProperty LookupId - $visitors = @($visitors | % { GetLoginName -lookupId $_ }) + $owners = @($siteItem["$($columnPrefix)SiteOwners"]) | Select-Object -ExpandProperty LookupId + $owners = @($owners | Foreach-Object -Process { GetLoginName -lookupId $_ }) + $members = @($siteItem["$($columnPrefix)SiteMembers"]) | Select-Object -ExpandProperty LookupId + $members = @($members | Foreach-Object -Process { GetLoginName -lookupId $_ }) + $visitors = @($siteItem["$($columnPrefix)SiteVisitors"]) | Select-Object -ExpandProperty LookupId + $visitors = @($visitors | Foreach-Object -Process { GetLoginName -lookupId $_ }) $ownerAccount = GetLoginName -lookupId $siteItem["$($columnPrefix)BusinessOwner"].LookupId $ownerAccount = New-PnPUser -LoginName $ownerAccount @@ -337,7 +337,7 @@ foreach ($siteItem in $siteDirectoryItems) { $siteUrl = $siteItem["$($columnPrefix)SiteURL"].Url } - Write-Output "`nProcessing $siteUrl" + Write-Output -InputObject "`nProcessing $siteUrl" Connect -Url "$tenantURL$siteDirectorySiteUrl" $urlToSiteDirectory = "$tenantURL$siteDirectorySiteUrl$siteDirectoryList" diff --git a/Samples/Provisioning.SelfHostedWithAzureWebJob/Engine/shared.ps1 b/Samples/Provisioning.SelfHostedWithAzureWebJob/Engine/shared.ps1 index ae6796a40..8c5349c6a 100644 --- a/Samples/Provisioning.SelfHostedWithAzureWebJob/Engine/shared.ps1 +++ b/Samples/Provisioning.SelfHostedWithAzureWebJob/Engine/shared.ps1 @@ -74,7 +74,7 @@ function SetRequestAccessEmail([string]$siteUrl, [string]$ownersEmail) { Connect -Url $siteUrl $emails = Get-PnPRequestAccessEmails if ($emails -ne $ownersEmail) { - Write-Output "`tSetting site request e-mail to $ownersEmail" + Write-Output -InputObject "`tSetting site request e-mail to $ownersEmail" Set-PnPRequestAccessEmails -Emails $ownersEmail } } @@ -85,32 +85,32 @@ function SyncPermissions { [Microsoft.SharePoint.Client.ListItem]$item ) - Write-Output "`tSyncing owners/members/visitors from site to directory list" + Write-Output -InputObject "`tSyncing owners/members/visitors from site to directory list" Connect -Url $siteUrl $visitorsGroup = Get-PnPGroup -AssociatedVisitorGroup -ErrorAction SilentlyContinue $membersGroup = Get-PnPGroup -AssociatedMemberGroup -ErrorAction SilentlyContinue $ownersGroup = Get-PnPGroup -AssociatedOwnerGroup -ErrorAction SilentlyContinue - $visitors = @($visitorsGroup.Users | select -ExpandProperty LoginName) - $members = @($membersGroup.Users | select -ExpandProperty LoginName) - $owners = @($ownersGroup.Users | select -ExpandProperty LoginName) + $visitors = @($visitorsGroup.Users | Select-Object -ExpandProperty LoginName) + $members = @($membersGroup.Users | Select-Object -ExpandProperty LoginName) + $owners = @($ownersGroup.Users | Select-Object -ExpandProperty LoginName) Connect -Url "$tenantURL$siteDirectorySiteUrl" - $owners = @($owners -notlike 'SHAREPOINT\system' | % {New-PnPUser -LoginName $_ | select -ExpandProperty ID} | sort) - $members = @($members -notlike 'SHAREPOINT\system' | % {New-PnPUser -LoginName $_ | select -ExpandProperty ID} | sort) - $visitors = @($visitors -notlike 'SHAREPOINT\system' | % {New-PnPUser -LoginName $_ | select -ExpandProperty ID} | sort) + $owners = @($owners -notlike 'SHAREPOINT\system' | Foreach-Object -Process {New-PnPUser -LoginName $_ | Select-Object -ExpandProperty ID} | Sort-Object) + $members = @($members -notlike 'SHAREPOINT\system' | Foreach-Object -Process {New-PnPUser -LoginName $_ | Select-Object -ExpandProperty ID} | Sort-Object) + $visitors = @($visitors -notlike 'SHAREPOINT\system' | Foreach-Object -Process {New-PnPUser -LoginName $_ | Select-Object -ExpandProperty ID} | Sort-Object) - $existingOwners = @($item["$($columnPrefix)SiteOwners"] | select -ExpandProperty LookupId | sort) - $existingMembers = @($item["$($columnPrefix)SiteMembers"] | select -ExpandProperty LookupId | sort) - $existingVisitors = @($item["$($columnPrefix)SiteVisitors"] | select -ExpandProperty LookupId | sort) + $existingOwners = @($item["$($columnPrefix)SiteOwners"] | Select-Object -ExpandProperty LookupId | Sort-Object) + $existingMembers = @($item["$($columnPrefix)SiteMembers"] | Select-Object -ExpandProperty LookupId | Sort-Object) + $existingVisitors = @($item["$($columnPrefix)SiteVisitors"] | Select-Object -ExpandProperty LookupId | Sort-Object) $diffOwner = Compare-Object -ReferenceObject $owners -DifferenceObject $existingOwners -PassThru $diffMember = Compare-Object -ReferenceObject $members -DifferenceObject $existingMembers -PassThru $diffVisitor = Compare-Object -ReferenceObject $visitors -DifferenceObject $existingVisitors -PassThru if ($diffOwner -or $diffMember -or $diffVisitor) { - Write-Output "`tUpdating changed owners/members/visitors" + Write-Output -InputObject "`tUpdating changed owners/members/visitors" $siteItem = Set-PnPListItem -List $siteDirectoryList -Identity $itemId -Values @{"$($columnPrefix)SiteOwners" = $owners; "$($columnPrefix)SiteMembers" = $members; "$($columnPrefix)SiteVisitors" = $visitors} } } From 0f839802fcbf13d8f657eb23e1b02c60d64d9af5 Mon Sep 17 00:00:00 2001 From: Paul Bullock Date: Tue, 9 Oct 2018 17:27:38 +0100 Subject: [PATCH 03/30] Updated documentation to get the LocaleIds from SharePoint --- Commands/Admin/NewTenantSite.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Commands/Admin/NewTenantSite.cs b/Commands/Admin/NewTenantSite.cs index cff1d74d1..18dab78a1 100644 --- a/Commands/Admin/NewTenantSite.cs +++ b/Commands/Admin/NewTenantSite.cs @@ -46,10 +46,10 @@ 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: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splanguage.lcid.aspx")] + [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. To get the list of supported languages use: (Get-PnPWeb -Includes RegionalSettings.InstalledLanguages).RegionalSettings.InstalledLanguages ")] 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.")] + [Parameter(Mandatory = false, HelpMessage = @"Specifies the site collection template type. Use the Get-PnPWebTemplates 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.")] public string Template = "STS#0"; [Parameter(Mandatory = true, HelpMessage = "Use Get-PnPTimeZoneId to retrieve possible timezone values")] From 0f5fd96723867527e6c6a1fdb0c28da7d3012c43 Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Tue, 9 Oct 2018 23:27:14 +0200 Subject: [PATCH 04/30] Fixed incorrect sample --- Commands/Diagnostic/MeasurePnPWeb.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Commands/Diagnostic/MeasurePnPWeb.cs b/Commands/Diagnostic/MeasurePnPWeb.cs index be68e7d34..c5261f14d 100644 --- a/Commands/Diagnostic/MeasurePnPWeb.cs +++ b/Commands/Diagnostic/MeasurePnPWeb.cs @@ -19,8 +19,8 @@ namespace SharePointPnP.PowerShell.Commands.Diagnostic Remarks = @"Gets statistics on the current web", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Measure-PnPList $web -Recursive", - Remarks = @"Gets statistics on the chosen including all sub webs", + Code = @"PS:> Measure-PnPWeb $web -Recursive", + Remarks = @"Gets statistics on the provided web including all its subwebs", SortOrder = 2)] public class MeasurePnPWeb : PnPCmdlet From 0b0bb2a4568e1c4dc0474542e40847754695f04d Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Wed, 10 Oct 2018 13:07:24 +0200 Subject: [PATCH 05/30] added lcid settings --- Commands/Admin/NewSite.cs | 40 ++++++++++++++++++++--------- Commands/Properties/AssemblyInfo.cs | 4 +-- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/Commands/Admin/NewSite.cs b/Commands/Admin/NewSite.cs index 17c4fc725..f62e9a139 100644 --- a/Commands/Admin/NewSite.cs +++ b/Commands/Admin/NewSite.cs @@ -1,15 +1,10 @@ #if !ONPREMISES -using System; -using System.Management.Automation; using Microsoft.SharePoint.Client; -using OfficeDevPnP.Core; -using OfficeDevPnP.Core.Entities; using SharePointPnP.PowerShell.CmdletHelpAttributes; -using SharePointPnP.PowerShell.Commands.Base; -using Resources = SharePointPnP.PowerShell.Commands.Properties.Resources; -using System.Threading.Tasks; using SharePointPnP.PowerShell.Commands.Base.PipeBinds; using SharePointPnP.PowerShell.Commands.Enums; +using System; +using System.Management.Automation; namespace SharePointPnP.PowerShell.Commands { @@ -36,17 +31,25 @@ namespace SharePointPnP.PowerShell.Commands Remarks = @"This will create a new Communications Site collection with the title 'Contoso' and the url 'https://tenant.sharepoint.com/sites/contoso'. The classification for the site will be set to ""HBI""", SortOrder = 4)] [CmdletExample( - Code = @"PS:> New-PnPSite -Type CommunicationSite -Title Contoso -Url https://tenant.sharepoint.com/sites/contoso -AllowFileSharingForGuestUsers", - Remarks = @"This will create a new Communications Site collection with the title 'Contoso' and the url 'https://tenant.sharepoint.com/sites/contoso'. File sharing for guest users will be enabled.", + Code = @"PS:> New-PnPSite -Type CommunicationSite -Title Contoso -Url https://tenant.sharepoint.com/sites/contoso -ShareByEmailEnabled", + Remarks = @"This will create a new Communications Site collection with the title 'Contoso' and the url 'https://tenant.sharepoint.com/sites/contoso'. Allows owners to invite users outside of the organization.", SortOrder = 5)] + [CmdletExample( + Code = @"PS:> New-PnPSite -Type CommunicationSite -Title Contoso -Url https://tenant.sharepoint.com/sites/contoso -Lcid 1044", + Remarks = @"This will create a new Communications Site collection with the title 'Contoso' and the url 'https://tenant.sharepoint.com/sites/contoso' and sets the default language to Italian.", + SortOrder = 6)] [CmdletExample( Code = @"PS:> New-PnPSite -Type TeamSite -Title 'Team Contoso' -Alias contoso", Remarks = @"This will create a new Modern Team Site collection with the title 'Team Contoso' and the url 'https://tenant.sharepoint.com/sites/contoso' or 'https://tenant.sharepoint.com/teams/contoso' based on the managed path configuration in the SharePoint Online Admin portal.", - SortOrder = 6)] + SortOrder = 7)] [CmdletExample( Code = @"PS:> New-PnPSite -Type TeamSite -Title 'Team Contoso' -Alias contoso -IsPublic", Remarks = @"This will create a new Modern Team Site collection with the title 'Team Contoso' and the url 'https://tenant.sharepoint.com/sites/contoso' or 'https://tenant.sharepoint.com/teams/contoso' based on the managed path configuration in the SharePoint Online Admin portal and sets the site to public.", - SortOrder = 7)] + SortOrder = 8)] + [CmdletExample( + Code = @"PS:> New-PnPSite -Type TeamSite -Title 'Team Contoso' -Alias contoso -Lcid 1040", + Remarks = @"This will create a new Modern Team Site collection with the title 'Team Contoso' and the url 'https://tenant.sharepoint.com/sites/contoso' or 'https://tenant.sharepoint.com/teams/contoso' based on the managed path configuration in the SharePoint Online Admin portal and sets the default language of the site to Italian.", + SortOrder = 9)] [CmdletAdditionalParameter(ParameterType = typeof(string), ParameterName = "Title", Mandatory = true, HelpMessage = @"Specifies the title of the new site collection", ParameterSetName = ParameterSet_COMMUNICATIONBUILTINDESIGN)] [CmdletAdditionalParameter(ParameterType = typeof(string), ParameterName = "Title", Mandatory = true, HelpMessage = @"Specifies the title of the new site collection", ParameterSetName = ParameterSet_COMMUNICATIONCUSTOMDESIGN)] [CmdletAdditionalParameter(ParameterType = typeof(string), ParameterName = "Url", Mandatory = true, HelpMessage = @"Specifies the full url of the new site collection", ParameterSetName = ParameterSet_COMMUNICATIONBUILTINDESIGN)] @@ -61,6 +64,7 @@ namespace SharePointPnP.PowerShell.Commands [CmdletAdditionalParameter(ParameterType = typeof(GuidPipeBind), ParameterName = "SiteDesignId", Mandatory = true, HelpMessage = @"Specifies the site design id to use for the new site collection. If specified will override SiteDesign", ParameterSetName = ParameterSet_COMMUNICATIONCUSTOMDESIGN)] [CmdletAdditionalParameter(ParameterType = typeof(uint), ParameterName = "Lcid", Mandatory = false, HelpMessage = @"Specifies the language of the new site collection. Defaults to the current language of the web connected to.", ParameterSetName = ParameterSet_COMMUNICATIONBUILTINDESIGN)] [CmdletAdditionalParameter(ParameterType = typeof(uint), ParameterName = "Lcid", Mandatory = false, HelpMessage = @"Specifies the language of the new site collection. Defaults to the current language of the web connected to.", ParameterSetName = ParameterSet_COMMUNICATIONCUSTOMDESIGN)] + [CmdletAdditionalParameter(ParameterType = typeof(uint), ParameterName = "Lcid", Mandatory = false, HelpMessage = @"Specifies the language of the new site collection. Defaults to the current language of the web connected to.", ParameterSetName = ParameterSet_TEAM)] [CmdletAdditionalParameter(ParameterType = typeof(string), ParameterName = "Title", Mandatory = true, HelpMessage = @"Specifies the title of the new site collection", ParameterSetName = ParameterSet_TEAM)] [CmdletAdditionalParameter(ParameterType = typeof(string), ParameterName = "Alias", Mandatory = true, HelpMessage = @"Specifies the alias of the new site collection which represents the part of the URL that will be assigned to the site behind 'https://tenant.sharepoint.com/sites/' or 'https://tenant.sharepoint.com/teams/' based on the managed path configuration in the SharePoint Online Admin portal", ParameterSetName = ParameterSet_TEAM)] [CmdletAdditionalParameter(ParameterType = typeof(string), ParameterName = "Description", Mandatory = false, HelpMessage = @"Specifies the description of the new site collection", ParameterSetName = ParameterSet_TEAM)] @@ -110,7 +114,9 @@ protected override void ExecuteCmdlet() creationInformation.Url = _communicationSiteParameters.Url; creationInformation.Description = _communicationSiteParameters.Description; creationInformation.Classification = _communicationSiteParameters.Classification; - creationInformation.AllowFileSharingForGuestUsers = _communicationSiteParameters.AllowFileSharingForGuestUsers; +#pragma warning disable CS0618 // Type or member is obsolete + creationInformation.ShareByEmailEnabled = _communicationSiteParameters.AllowFileSharingForGuestUsers || _communicationSiteParameters.ShareByEmailEnabled; +#pragma warning restore CS0618 // Type or member is obsolete creationInformation.Lcid = _communicationSiteParameters.Lcid; if (ParameterSetName == "CommunicationCustomInDesign") { @@ -132,6 +138,7 @@ protected override void ExecuteCmdlet() creationInformation.Classification = _teamSiteParameters.Classification; creationInformation.Description = _teamSiteParameters.Description; creationInformation.IsPublic = _teamSiteParameters.IsPublic; + creationInformation.Lcid = _teamSiteParameters.Lcid; var results = ClientContext.CreateSiteAsync(creationInformation); var returnedContext = results.GetAwaiter().GetResult(); @@ -157,10 +164,16 @@ public class CommunicationSiteParameters [Parameter(Mandatory = false, ParameterSetName = ParameterSet_COMMUNICATIONCUSTOMDESIGN)] public string Classification; + [Parameter(Mandatory = false, ParameterSetName = ParameterSet_COMMUNICATIONBUILTINDESIGN)] [Parameter(Mandatory = false, ParameterSetName = ParameterSet_COMMUNICATIONCUSTOMDESIGN)] + [Obsolete("Use ShareByEmailEnabled instead.")] public SwitchParameter AllowFileSharingForGuestUsers; + [Parameter(Mandatory = false, ParameterSetName = ParameterSet_COMMUNICATIONBUILTINDESIGN)] + [Parameter(Mandatory = false, ParameterSetName = ParameterSet_COMMUNICATIONCUSTOMDESIGN)] + public SwitchParameter ShareByEmailEnabled; + [Parameter(Mandatory = false, ParameterSetName = ParameterSet_COMMUNICATIONBUILTINDESIGN)] public OfficeDevPnP.Core.Sites.CommunicationSiteDesign SiteDesign = OfficeDevPnP.Core.Sites.CommunicationSiteDesign.Topic; @@ -188,6 +201,9 @@ public class TeamSiteParameters [Parameter(Mandatory = false, ParameterSetName = ParameterSet_TEAM)] public SwitchParameter IsPublic; + + [Parameter(Mandatory = false, ParameterSetName = ParameterSet_TEAM)] + public uint Lcid; } } } diff --git a/Commands/Properties/AssemblyInfo.cs b/Commands/Properties/AssemblyInfo.cs index 727af4580..7fdd7e484 100644 --- a/Commands/Properties/AssemblyInfo.cs +++ b/Commands/Properties/AssemblyInfo.cs @@ -44,6 +44,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.2.1810.0")] -[assembly: AssemblyFileVersion("3.2.1810.0")] +[assembly: AssemblyVersion("3.3.1811.0")] +[assembly: AssemblyFileVersion("3.3.1811.0")] [assembly: InternalsVisibleTo("SharePointPnP.PowerShell.Tests")] \ No newline at end of file From 7d9ade6f4774bab7e0314c14e16cd067337eace6 Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Wed, 10 Oct 2018 17:18:30 +0200 Subject: [PATCH 06/30] updated changelog --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 211bcf726..6d2befa02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). -## [3.2.1810.0] Unreleased +## [3.3.1811.0] Unreleased +### Added + +### Changed +- Updated New-PnPSite to support language/locale for new sites. + +### Contributors +## [3.2.1810.0] Released ### Added - Add-PnPProvisioningSequence : Adds an in-memory sequence to an in-memory provisioning hierarchy - Add-PnPProvisioningSite : Adds an in-memory site definition to a in-memory sequence From c422c89c37ed1ad6298339ffa8903cd117ceee2c Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Thu, 11 Oct 2018 13:04:16 +0200 Subject: [PATCH 07/30] updated changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d2befa02..222c02382 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Changed - Updated New-PnPSite to support language/locale for new sites. +- Updated documentation for New-PnPTenantSite +- Updated samples ### Contributors +- Paul Bullock (pkbullock) +- François-Xavier Cat (lazywinadmin) + ## [3.2.1810.0] Released ### Added - Add-PnPProvisioningSequence : Adds an in-memory sequence to an in-memory provisioning hierarchy From 803da21cdb5ac4643083de5a1be0d40c70cf09e2 Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Wed, 24 Oct 2018 13:07:41 +0200 Subject: [PATCH 08/30] Fixes issue #1938 --- .../ConvertFolderToProvisioningTemplate.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Commands/Provisioning/ConvertFolderToProvisioningTemplate.cs b/Commands/Provisioning/ConvertFolderToProvisioningTemplate.cs index 9ca412ff5..ef71bd320 100644 --- a/Commands/Provisioning/ConvertFolderToProvisioningTemplate.cs +++ b/Commands/Provisioning/ConvertFolderToProvisioningTemplate.cs @@ -1,11 +1,11 @@ -using System; +using OfficeDevPnP.Core.Framework.Provisioning.Connectors.OpenXML; +using OfficeDevPnP.Core.Framework.Provisioning.Connectors.OpenXML.Model; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Management.Automation; -using OfficeDevPnP.Core.Framework.Provisioning.Connectors.OpenXML; -using OfficeDevPnP.Core.Framework.Provisioning.Connectors.OpenXML.Model; -using SharePointPnP.PowerShell.CmdletHelpAttributes; namespace SharePointPnP.PowerShell.Commands.Provisioning { @@ -96,6 +96,8 @@ private byte[] CreatePnPPackageFile() bool templateFileMissing = dirInfo.GetFiles(templateFileName, SearchOption.TopDirectoryOnly).Length == 0; if (templateFileMissing) throw new InvalidOperationException("You need an xml template file (" + templateFileName + ") with the same name as the .pnp outfile in order to pack a folder to a .pnp package file."); + info.Properties.TemplateFileName = templateFileName; + foreach (var currentFile in dirInfo.GetFiles("*.*", SearchOption.AllDirectories)) { var folder = GetFolderName(currentFile, dirInfo); From 767d518f41ec0d27030f44402d86ff6562b1a4d1 Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Wed, 24 Oct 2018 13:08:05 +0200 Subject: [PATCH 09/30] Renamed cmdlets --- .../Provisioning/Tenant/AddTenantSequence.cs | 45 +++ .../Tenant/AddTenantSequenceSite.cs | 32 +++ .../Tenant/AddTenantSequenceSubSite.cs | 39 +++ .../Tenant/ApplyTenantTemplate.cs | 268 ++++++++++++++++++ .../Provisioning/Tenant/GetTenantSequence.cs | 40 +++ .../Tenant/GetTenantSequenceSite.cs | 40 +++ .../Provisioning/Tenant/NewTenantSequence.cs | 39 +++ .../NewTenantSequenceCommunicationSite.cs | 74 +++++ .../NewTenantSequenceTeamNoGroupSite.cs | 63 ++++ .../NewTenantSequenceTeamNoGroupSubSite.cs | 65 +++++ .../Tenant/NewTenantSequenceTeamSite.cs | 64 +++++ .../Provisioning/Tenant/NewTenantTemplate.cs | 41 +++ .../Provisioning/Tenant/ReadTenantTemplate.cs | 80 ++++++ .../Provisioning/Tenant/SaveTenantTemplate.cs | 171 +++++++++++ .../Provisioning/Tenant/TestTenantTemplate.cs | 93 ++++++ 15 files changed, 1154 insertions(+) create mode 100644 Commands/Provisioning/Tenant/AddTenantSequence.cs create mode 100644 Commands/Provisioning/Tenant/AddTenantSequenceSite.cs create mode 100644 Commands/Provisioning/Tenant/AddTenantSequenceSubSite.cs create mode 100644 Commands/Provisioning/Tenant/ApplyTenantTemplate.cs create mode 100644 Commands/Provisioning/Tenant/GetTenantSequence.cs create mode 100644 Commands/Provisioning/Tenant/GetTenantSequenceSite.cs create mode 100644 Commands/Provisioning/Tenant/NewTenantSequence.cs create mode 100644 Commands/Provisioning/Tenant/NewTenantSequenceCommunicationSite.cs create mode 100644 Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSite.cs create mode 100644 Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSubSite.cs create mode 100644 Commands/Provisioning/Tenant/NewTenantSequenceTeamSite.cs create mode 100644 Commands/Provisioning/Tenant/NewTenantTemplate.cs create mode 100644 Commands/Provisioning/Tenant/ReadTenantTemplate.cs create mode 100644 Commands/Provisioning/Tenant/SaveTenantTemplate.cs create mode 100644 Commands/Provisioning/Tenant/TestTenantTemplate.cs diff --git a/Commands/Provisioning/Tenant/AddTenantSequence.cs b/Commands/Provisioning/Tenant/AddTenantSequence.cs new file mode 100644 index 000000000..74c893f7a --- /dev/null +++ b/Commands/Provisioning/Tenant/AddTenantSequence.cs @@ -0,0 +1,45 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using System; +using System.Linq; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet(VerbsCommon.Add, "PnPTenantSequence", SupportsShouldProcess = true)] + [Alias("Add-PnPProvisioningSequence")] + [CmdletHelp("Adds a tenant sequence object to a tenant template", + Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> Add-PnPTenantSequence -Template $mytemplate -Sequence $mysequence", + Remarks = "Adds an existing sequence object to an existing hierarchy object", + SortOrder = 1)] + [CmdletExample( + Code = @"PS:> New-PnPTenantSequence -Id ""MySequence"" | Add-PnPTenantSequence -Template $template", + Remarks = "Creates a new instance of a provisioning sequence object and sets the Id to the value specified, then the sequence is added to an existing hierarchy object", + SortOrder = 2)] + public class AddTenantSequence : PSCmdlet + { + [Parameter(Mandatory = true, HelpMessage = "The template to add the sequence to", ParameterSetName = ParameterAttribute.AllParameterSets)] + [Alias("Hierarchy")] + public ProvisioningHierarchy Template; + + [Parameter(Mandatory = true, HelpMessage = "Optional Id of the sequence", ParameterSetName = ParameterAttribute.AllParameterSets, ValueFromPipeline = true)] + public ProvisioningSequence Sequence; + + protected override void ProcessRecord() + { + if (Template.Sequences.FirstOrDefault(s => s.ID == Sequence.ID) == null) + { + Template.Sequences.Add(Sequence); + WriteObject(Template); + } + else + { + WriteError(new ErrorRecord(new Exception($"Sequence with ID {Sequence.ID} already exists in template"), "DUPLICATESEQUENCEID", ErrorCategory.InvalidData, Sequence)); + } + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Provisioning/Tenant/AddTenantSequenceSite.cs b/Commands/Provisioning/Tenant/AddTenantSequenceSite.cs new file mode 100644 index 000000000..e01e3d512 --- /dev/null +++ b/Commands/Provisioning/Tenant/AddTenantSequenceSite.cs @@ -0,0 +1,32 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using SharePointPnP.PowerShell.Commands.Base.PipeBinds; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet(VerbsCommon.Add, "PnPTenantSequenceSite", SupportsShouldProcess = true)] + [Alias("Add-PnPProvisioningSite")] + [CmdletHelp("Adds a existing tenant sequence site object to a tenant template", + Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> Add-PnPTenantSequenceSite -Site $myteamsite -Sequence $mysequence", + Remarks = "Adds an existing site object to an existing hierarchy sequence", + SortOrder = 1)] + public class AddTenantSequenceSite : PSCmdlet + { + [Parameter(Mandatory = true, ValueFromPipeline = true)] + public ProvisioningSitePipeBind Site; + + [Parameter(Mandatory = true, HelpMessage = "The sequence to add the site to", ValueFromPipeline = true)] + public ProvisioningSequence Sequence; + + protected override void ProcessRecord() + { + Sequence.SiteCollections.Add(Site.Site); + WriteObject(Sequence); + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Provisioning/Tenant/AddTenantSequenceSubSite.cs b/Commands/Provisioning/Tenant/AddTenantSequenceSubSite.cs new file mode 100644 index 000000000..558db7642 --- /dev/null +++ b/Commands/Provisioning/Tenant/AddTenantSequenceSubSite.cs @@ -0,0 +1,39 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using System; +using System.Linq; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet(VerbsCommon.Add, "PnPTenantSequenceSubSite", SupportsShouldProcess = true)] + [Alias("Add-PnPPnPProvisioningSubSite")] + [CmdletHelp("Adds a tenant sequence sub site object to a tenant sequence site object", + Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> Add-PnPTenantSequenceSubSite -Site $mysite -SubSite $mysubsite", + Remarks = "Adds an existing subsite object to an existing sequence site object", + SortOrder = 1)] + public class AddTenantSequenceSubSite : PSCmdlet + { + [Parameter(Mandatory = true, HelpMessage = "The subsite to add")] + public TeamNoGroupSubSite SubSite; + + [Parameter(Mandatory = true, HelpMessage = "The site to add the subsite to", ValueFromPipeline = true)] + public SiteCollection Site; + + protected override void ProcessRecord() + { + if (Site.Sites.Cast().FirstOrDefault(s => s.Url == SubSite.Url) == null) + { + Site.Sites.Add(SubSite); + } + else + { + WriteError(new ErrorRecord(new Exception($"Site with URL {SubSite.Url} already exists in sequence"), "DUPLICATEURL", ErrorCategory.InvalidData, SubSite)); + } + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Provisioning/Tenant/ApplyTenantTemplate.cs b/Commands/Provisioning/Tenant/ApplyTenantTemplate.cs new file mode 100644 index 000000000..504dec6c1 --- /dev/null +++ b/Commands/Provisioning/Tenant/ApplyTenantTemplate.cs @@ -0,0 +1,268 @@ +#if !ONPREMISES +using Microsoft.SharePoint.Client; +using OfficeDevPnP.Core.Framework.Provisioning.Connectors; +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers; +using OfficeDevPnP.Core.Framework.Provisioning.Providers; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using SharePointPnP.PowerShell.Commands.Base; +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet("Apply", "PnPTenantTemplate", SupportsShouldProcess = true)] + [Alias("Apply-PnPProvisioningHierarchy")] + [CmdletHelp("Applies a tenant template to the current tenant.", + Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> Apply-PnPTenantTemplate -Path myfile.pnp", + Remarks = "Will read the tenant template from the filesystem and will apply the sequences in the template", + SortOrder = 1)] + [CmdletExample( + Code = @"PS:> Apply-PnPTenantTemplate -Path myfile.pnp -SequenceId ""mysequence""", + Remarks = "Will read the tenant template from the filesystem and will apply the specified sequence in the template", + SortOrder = 1)] + [CmdletExample( + Code = @"PS:> Apply-PnPTenantTemplate -Path myfile.pnp -Parameters @{""ListTitle""=""Projects"";""parameter2""=""a second value""}", + Remarks = @"Applies a tenant template to the current tenant. It will populate the parameter in the template the values as specified and in the template you can refer to those values with the {parameter:} token. + +For instance with the example above, specifying {parameter:ListTitle} in your template will translate to 'Projects' when applying the template. These tokens can be used in most string values in a template.", + SortOrder = 3)] + public class ApplyTenantTemplate : PnPAdminCmdlet + { + private const string ParameterSet_PATH = "By Path"; + private const string ParameterSet_OBJECT = "By Object"; + + private ProgressRecord progressRecord = new ProgressRecord(0, "Activity", "Status"); + private ProgressRecord subProgressRecord = new ProgressRecord(1, "Activity", "Status"); + + [Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true, HelpMessage = "Path to the xml or pnp file containing the provisioning hierarchy.", ParameterSetName = ParameterSet_PATH)] + public string Path; + + [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ParameterSetName = ParameterSet_OBJECT)] + [Alias("Hierarchy")] + public ProvisioningHierarchy Template; + + [Parameter(Mandatory = false)] + public string SequenceId; + + [Parameter(Mandatory = false, HelpMessage = "Root folder where resources/files that are being referenced in the template are located. If not specified the same folder as where the tenant template is located will be used.", ParameterSetName = ParameterAttribute.AllParameterSets)] + public string ResourceFolder; + + [Parameter(Mandatory = false, HelpMessage = "Allows you to only process a specific part of the template. Notice that this might fail, as some of the handlers require other artifacts in place if they are not part of what your applying.", ParameterSetName = ParameterAttribute.AllParameterSets)] + public Handlers Handlers; + + [Parameter(Mandatory = false, HelpMessage = "Allows you to run all handlers, excluding the ones specified.", ParameterSetName = ParameterAttribute.AllParameterSets)] + public Handlers ExcludeHandlers; + + [Parameter(Mandatory = false, HelpMessage = "Allows you to specify ExtensbilityHandlers to execute while applying a template", ParameterSetName = ParameterAttribute.AllParameterSets)] + public ExtensibilityHandler[] ExtensibilityHandlers; + + [Parameter(Mandatory = false, HelpMessage = "Allows you to specify ITemplateProviderExtension to execute while applying a template.", ParameterSetName = ParameterAttribute.AllParameterSets)] + public ITemplateProviderExtension[] TemplateProviderExtensions; + + [Parameter(Mandatory = false, HelpMessage = "Allows you to specify parameters that can be referred to in the hierarchy by means of the {parameter:} token. See examples on how to use this parameter.", ParameterSetName = ParameterAttribute.AllParameterSets)] + public Hashtable Parameters; + + [Parameter(Mandatory = false, HelpMessage = "Specify this parameter if you want to overwrite and/or create properties that are known to be system entries (starting with vti_, dlc_, etc.)", ParameterSetName = ParameterAttribute.AllParameterSets)] + public SwitchParameter OverwriteSystemPropertyBagValues; + + [Parameter(Mandatory = false, HelpMessage = "Ignore duplicate data row errors when the data row in the template already exists.", ParameterSetName = ParameterAttribute.AllParameterSets)] + public SwitchParameter IgnoreDuplicateDataRowErrors; + + [Parameter(Mandatory = false, HelpMessage = "If set content types will be provisioned if the target web is a subweb.")] + public SwitchParameter ProvisionContentTypesToSubWebs; + + [Parameter(Mandatory = false, HelpMessage = "If set fields will be provisioned if the target web is a subweb.")] + public SwitchParameter ProvisionFieldsToSubWebs; + + [Parameter(Mandatory = false, HelpMessage = "Override the RemoveExistingNodes attribute in the Navigation elements of the template. If you specify this value the navigation nodes will always be removed before adding the nodes in the template")] + public SwitchParameter ClearNavigation; + + protected override void ExecuteCmdlet() + { + var applyingInformation = new ProvisioningTemplateApplyingInformation(); + + if (MyInvocation.BoundParameters.ContainsKey("Handlers")) + { + applyingInformation.HandlersToProcess = Handlers; + } + if (MyInvocation.BoundParameters.ContainsKey("ExcludeHandlers")) + { + foreach (var handler in (Handlers[])Enum.GetValues(typeof(Handlers))) + { + if (!ExcludeHandlers.Has(handler) && handler != Handlers.All) + { + Handlers = Handlers | handler; + } + } + applyingInformation.HandlersToProcess = Handlers; + } + + if (ExtensibilityHandlers != null) + { + applyingInformation.ExtensibilityHandlers = ExtensibilityHandlers.ToList(); + } + + applyingInformation.ProgressDelegate = (message, step, total) => + { + if (message != null) + { + var percentage = Convert.ToInt32((100 / Convert.ToDouble(total)) * Convert.ToDouble(step)); + progressRecord.Activity = $"Applying template to tenant"; + progressRecord.StatusDescription = message; + progressRecord.PercentComplete = percentage; + progressRecord.RecordType = ProgressRecordType.Processing; + WriteProgress(progressRecord); + } + }; + + var warningsShown = new List(); + + applyingInformation.MessagesDelegate = (message, type) => + { + switch (type) + { + case ProvisioningMessageType.Warning: + { + if (!warningsShown.Contains(message)) + { + WriteWarning(message); + warningsShown.Add(message); + } + break; + } + case ProvisioningMessageType.Progress: + { + if (message != null) + { + var activity = message; + if (message.IndexOf("|") > -1) + { + var messageSplitted = message.Split('|'); + if (messageSplitted.Length == 4) + { + var current = double.Parse(messageSplitted[2]); + var total = double.Parse(messageSplitted[3]); + subProgressRecord.RecordType = ProgressRecordType.Processing; + subProgressRecord.Activity = string.IsNullOrEmpty(messageSplitted[0]) ? "-" : messageSplitted[0]; + subProgressRecord.StatusDescription = string.IsNullOrEmpty(messageSplitted[1]) ? "-" : messageSplitted[1]; + subProgressRecord.PercentComplete = Convert.ToInt32((100 / total) * current); + WriteProgress(subProgressRecord); + } + else + { + subProgressRecord.Activity = "Processing"; + subProgressRecord.RecordType = ProgressRecordType.Processing; + subProgressRecord.StatusDescription = activity; + subProgressRecord.PercentComplete = 0; + WriteProgress(subProgressRecord); + } + } + else + { + subProgressRecord.Activity = "Processing"; + subProgressRecord.RecordType = ProgressRecordType.Processing; + subProgressRecord.StatusDescription = activity; + subProgressRecord.PercentComplete = 0; + WriteProgress(subProgressRecord); + } + } + break; + } + case ProvisioningMessageType.Completed: + { + + WriteProgress(new ProgressRecord(1, message, " ") { RecordType = ProgressRecordType.Completed }); + break; + } + } + }; + + applyingInformation.OverwriteSystemPropertyBagValues = OverwriteSystemPropertyBagValues; + applyingInformation.IgnoreDuplicateDataRowErrors = IgnoreDuplicateDataRowErrors; + applyingInformation.ClearNavigation = ClearNavigation; + applyingInformation.ProvisionContentTypesToSubWebs = ProvisionContentTypesToSubWebs; + applyingInformation.ProvisionFieldsToSubWebs = ProvisionFieldsToSubWebs; + + ProvisioningHierarchy hierarchyToApply = null; + + switch (ParameterSetName) + { + case ParameterSet_PATH: + { + hierarchyToApply = GetHierarchy(); + break; + } + case ParameterSet_OBJECT: + { + hierarchyToApply = Template; + if (ResourceFolder != null) + { + var fileSystemConnector = new FileSystemConnector(ResourceFolder, ""); + hierarchyToApply.Connector = fileSystemConnector; + } + else + { + if (Path != null) + { + if (!System.IO.Path.IsPathRooted(Path)) + { + Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path); + } + } + else + { + Path = SessionState.Path.CurrentFileSystemLocation.Path; + } + var fileInfo = new FileInfo(Path); + var fileConnector = new FileSystemConnector(fileInfo.DirectoryName, ""); + hierarchyToApply.Connector = fileConnector; + } + break; + } + } + if (Parameters != null) + { + foreach (var parameter in Parameters.Keys) + { + if (hierarchyToApply.Parameters.ContainsKey(parameter.ToString())) + { + hierarchyToApply.Parameters[parameter.ToString()] = Parameters[parameter].ToString(); + } + else + { + hierarchyToApply.Parameters.Add(parameter.ToString(), Parameters[parameter].ToString()); + } + } + } + if (!string.IsNullOrEmpty(SequenceId)) + { + Tenant.ApplyProvisionHierarchy(hierarchyToApply, SequenceId, applyingInformation); + } + else + { + foreach (var sequence in hierarchyToApply.Sequences) + { + Tenant.ApplyProvisionHierarchy(hierarchyToApply, sequence.ID, applyingInformation); + } + } + + } + + private ProvisioningHierarchy GetHierarchy() + { + if(!System.IO.Path.IsPathRooted(Path)) + { + Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path); + } + return ReadTenantTemplate.LoadProvisioningHierarchyFromFile(Path, TemplateProviderExtensions); + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Provisioning/Tenant/GetTenantSequence.cs b/Commands/Provisioning/Tenant/GetTenantSequence.cs new file mode 100644 index 000000000..2475a6aff --- /dev/null +++ b/Commands/Provisioning/Tenant/GetTenantSequence.cs @@ -0,0 +1,40 @@ +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using SharePointPnP.PowerShell.Commands.Base.PipeBinds; +using System; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet(VerbsCommon.Get, "PnPTenantSequence", SupportsShouldProcess = true)] + [Alias("Get-PnPProvisioningSequence")] + [CmdletHelp("Returns one ore more provisioning sequence object(s) from a tenant template", + Category = CmdletHelpCategory.Provisioning)] + [CmdletExample( + Code = @"PS:> Get-PnPTenantSequence -Template $myhierarchy", + Remarks = "Returns all sequences from the specified tenant template", + SortOrder = 1)] + [CmdletExample( + Code = @"PS:> Get-PnPTenantSequence -Template $myhierarchy -Identity ""mysequence""", + Remarks = "Returns the specified sequence from the specified tenant template", + SortOrder = 2)] + public class GetTenantSequence : PSCmdlet + { + [Parameter(Mandatory = true, HelpMessage = "The hierarchy to retrieve the sequence from", ParameterSetName = ParameterAttribute.AllParameterSets)] + public ProvisioningHierarchy Template; + + [Parameter(Mandatory = false, HelpMessage = "Optional Id of the sequence", ParameterSetName = ParameterAttribute.AllParameterSets, ValueFromPipeline = true)] + public ProvisioningSequencePipeBind Identity; + protected override void ProcessRecord() + { + if (!MyInvocation.BoundParameters.ContainsKey("Identity")) + { + WriteObject(Template.Sequences, true); + } + else + { + WriteObject(Identity.GetSequenceFromHierarchy(Template)); + } + } + } +} diff --git a/Commands/Provisioning/Tenant/GetTenantSequenceSite.cs b/Commands/Provisioning/Tenant/GetTenantSequenceSite.cs new file mode 100644 index 000000000..646659f1e --- /dev/null +++ b/Commands/Provisioning/Tenant/GetTenantSequenceSite.cs @@ -0,0 +1,40 @@ +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using SharePointPnP.PowerShell.Commands.Base.PipeBinds; +using System; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet(VerbsCommon.Get, "PnPTenantSequenceSite", SupportsShouldProcess = true)] + [Alias("Get-PnPProvisioningSite")] + [CmdletHelp("Returns one ore more sites from a tenant template", + Category = CmdletHelpCategory.Provisioning)] + [CmdletExample( + Code = @"PS:> Get-PnPTenantSequenceSite -Sequence $mysequence", + Remarks = "Returns all sites from the specified sequence", + SortOrder = 1)] + [CmdletExample( + Code = @"PS:> Get-PnPTenantSequenceSite -Sequence $mysequence -Identity 8058ea99-af7b-4bb7-b12a-78f93398041e", + Remarks = "Returns the specified site from the specified sequence", + SortOrder = 2)] + public class GetTenantSequenceSite : PSCmdlet + { + [Parameter(Mandatory = true, HelpMessage = "The sequence to retrieve the site from", ParameterSetName = ParameterAttribute.AllParameterSets)] + public ProvisioningSequence Sequence; + + [Parameter(Mandatory = false, HelpMessage = "Optional Id of the site", ParameterSetName = ParameterAttribute.AllParameterSets, ValueFromPipeline = true)] + public ProvisioningSitePipeBind Identity; + protected override void ProcessRecord() + { + if (!MyInvocation.BoundParameters.ContainsKey("Identity")) + { + WriteObject(Sequence.SiteCollections, true); + } + else + { + WriteObject(Identity.GetSiteFromSequence(Sequence)); + } + } + } +} diff --git a/Commands/Provisioning/Tenant/NewTenantSequence.cs b/Commands/Provisioning/Tenant/NewTenantSequence.cs new file mode 100644 index 000000000..d6e65f792 --- /dev/null +++ b/Commands/Provisioning/Tenant/NewTenantSequence.cs @@ -0,0 +1,39 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using System; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet(VerbsCommon.New, "PnPTenantSequence", SupportsShouldProcess = true)] + [Alias("New-PnPProvisioningSequence")] + [CmdletHelp("Creates a new tenant sequence object", + Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> $sequence = New-PnPTenantSequence", + Remarks = "Creates a new instance of a tenant sequence object.", + SortOrder = 1)] + [CmdletExample( + Code = @"PS:> $sequence = New-PnPTenantSequence -Id ""MySequence""", + Remarks = "Creates a new instance of a tenant sequence object and sets the Id to the value specified.", + SortOrder = 2)] + public class NewTenantSequence : PSCmdlet + { + [Parameter(Mandatory = false, HelpMessage = "Optional Id of the sequence", ParameterSetName = ParameterAttribute.AllParameterSets)] + public string Id; + protected override void ProcessRecord() + { + var result = new ProvisioningSequence(); + if (this.MyInvocation.BoundParameters.ContainsKey("Id")) + { + result.ID = Id; + } else + { + result.ID = $"sequence-{Guid.NewGuid()}"; + } + WriteObject(result); + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Provisioning/Tenant/NewTenantSequenceCommunicationSite.cs b/Commands/Provisioning/Tenant/NewTenantSequenceCommunicationSite.cs new file mode 100644 index 000000000..e9b5df5da --- /dev/null +++ b/Commands/Provisioning/Tenant/NewTenantSequenceCommunicationSite.cs @@ -0,0 +1,74 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using System.Linq; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet(VerbsCommon.New, "PnPTenantSequenceCommunicationSite", SupportsShouldProcess = true)] + [Alias("New-PnPProvisioningCommunicationSite")] + [CmdletHelp("Creates a communication site object", + Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> $site = New-PnPTenantSequenceCommunicationSite -Url ""/sites/mycommunicationsite"" -Title ""My Team Site""", + Remarks = "Creates a new communication site object with the specified variables", + SortOrder = 1)] + public class NewTenantSequenceCommunicationSite : PSCmdlet + { + [Parameter(Mandatory = true)] + public string Url; + + [Parameter(Mandatory = true)] + public string Title; + + [Parameter(Mandatory = false)] + public uint Language; + + [Parameter(Mandatory = false)] + public string Owner; + + [Parameter(Mandatory = false)] + public string Description; + + [Parameter(Mandatory = false)] + public string Classification; + + [Parameter(Mandatory = false)] + public string SiteDesignId; + + [Parameter(Mandatory = false)] + public SwitchParameter HubSite; + + [Parameter(Mandatory = false)] + public SwitchParameter AllowFileSharingForGuestUsers; + + [Parameter(Mandatory = false)] + public string[] TemplateIds; + + protected override void ProcessRecord() + { + var site = new CommunicationSiteCollection + { + Url = Url, + Language = (int)Language, + Owner = Owner, + AllowFileSharingForGuestUsers = AllowFileSharingForGuestUsers.IsPresent, + Classification = Classification, + Description = Description, + IsHubSite = HubSite.IsPresent, + Title = Title, + }; + if(MyInvocation.BoundParameters.ContainsKey("SiteDesignId")) + { + site.SiteDesign = SiteDesignId; + } + if (TemplateIds != null) + { + site.Templates.AddRange(TemplateIds.ToList()); + } + WriteObject(site); + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSite.cs b/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSite.cs new file mode 100644 index 000000000..bcc487db4 --- /dev/null +++ b/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSite.cs @@ -0,0 +1,63 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using System.Linq; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet(VerbsCommon.New, "PnPTenantSequenceTeamNoGroupSite", SupportsShouldProcess = true)] + [Alias("New-PnPProvisioningTeamNoGroupSite")] + [CmdletHelp("Creates a new team site without an Office 365 group in-memory object", + Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> $site = New-PnPTenantSequenceTeamNoGroupSite -Alias ""MyTeamSite"" -Title ""My Team Site""", + Remarks = "Creates a new team site object with the specified variables", + SortOrder = 1)] + public class NewTenantSequenceTeamNoGroupSite : PSCmdlet + { + [Parameter(Mandatory = true)] + public string Url; + + [Parameter(Mandatory = true)] + public string Title; + + [Parameter(Mandatory = true)] + public uint TimeZoneId; + + [Parameter(Mandatory = false)] + public uint Language; + + [Parameter(Mandatory = false)] + public string Owner; + + [Parameter(Mandatory = false)] + public string Description; + + [Parameter(Mandatory = false)] + public SwitchParameter HubSite; + + [Parameter(Mandatory = false)] + public string[] TemplateIds; + + protected override void ProcessRecord() + { + var site = new TeamNoGroupSiteCollection + { + Url = Url, + Language = (int)Language, + Owner = Owner, + TimeZoneId = (int)TimeZoneId, + Description = Description, + IsHubSite = HubSite.IsPresent, + Title = Title + }; + if (TemplateIds != null) + { + site.Templates.AddRange(TemplateIds.ToList()); + } + WriteObject(site); + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSubSite.cs b/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSubSite.cs new file mode 100644 index 000000000..b11b56042 --- /dev/null +++ b/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSubSite.cs @@ -0,0 +1,65 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using System.Linq; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet(VerbsCommon.New, "PnPTenantSequenceTeamNoGroupSubSite", SupportsShouldProcess = true)] + [Alias("New-PnPProvisioningTeamNoGroupSubSite")] + [CmdletHelp("Creates a team site subsite with no Office 365 group object", + Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> $site = New-PnPTenantSequenceTeamNoGroupSubSite -Url ""MyTeamSubsite"" -Title ""My Team Site"" -TimeZoneId 4", + Remarks = "Creates a new team site subsite object with the specified variables", + SortOrder = 1)] + public class NewTenantSequenceTeamNoGroupSubSite : PSCmdlet + { + + [Parameter(Mandatory = true)] + public string Url; + + [Parameter(Mandatory = true)] + public string Title; + + [Parameter(Mandatory = true)] + public uint TimeZoneId; + + [Parameter(Mandatory = false)] + public uint Language; + + [Parameter(Mandatory = false)] + public string Description; + + [Parameter(Mandatory = false)] + public string[] TemplateIds; + + [Parameter(Mandatory = false)] + public SwitchParameter QuickLaunchDisabled; + + [Parameter(Mandatory = false)] + public SwitchParameter UseDifferentPermissionsFromParentSite; + + protected override void ProcessRecord() + { + SiteCollection c; + var site = new TeamNoGroupSubSite() + { + Url = Url, + Language = (int)Language, + QuickLaunchEnabled = !QuickLaunchDisabled.IsPresent, + UseSamePermissionsAsParentSite = !UseDifferentPermissionsFromParentSite.IsPresent, + TimeZoneId = (int)TimeZoneId, + Description = Description, + Title = Title + }; + if (TemplateIds != null) + { + site.Templates.AddRange(TemplateIds.ToList()); + } + WriteObject(site); + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Provisioning/Tenant/NewTenantSequenceTeamSite.cs b/Commands/Provisioning/Tenant/NewTenantSequenceTeamSite.cs new file mode 100644 index 000000000..c86c524b0 --- /dev/null +++ b/Commands/Provisioning/Tenant/NewTenantSequenceTeamSite.cs @@ -0,0 +1,64 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using System.Linq; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet(VerbsCommon.New, "PnPTenantSequenceTeamSite", SupportsShouldProcess = true)] + [Alias("New-PnPProvisioningTeamSite")] + [CmdletHelp("Creates a team site object", + Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> $site = New-PnPTenantSequenceTeamSite -Alias ""MyTeamSite"" -Title ""My Team Site""", + Remarks = "Creates a new team site object with the specified variables", + SortOrder = 1)] + public class NewTenantSequenceTeamSite : PSCmdlet + { + + [Parameter(Mandatory = true)] + public string Alias; + + [Parameter(Mandatory = true)] + public string Title; + + [Parameter(Mandatory = false)] + public string Description = ""; + + [Parameter(Mandatory = false)] + public string DisplayName = ""; + + [Parameter(Mandatory = false)] + public string Classification; + + [Parameter(Mandatory = false)] + public SwitchParameter Public; + + [Parameter(Mandatory = false)] + public SwitchParameter HubSite; + + [Parameter(Mandatory = false)] + public string[] TemplateIds; + + protected override void ProcessRecord() + { + var site = new TeamSiteCollection + { + Alias = Alias, + Classification = Classification, + Description = Description, + DisplayName = DisplayName, + IsHubSite = HubSite.IsPresent, + IsPublic = Public.IsPresent, + Title = Title + }; + if (TemplateIds != null) + { + site.Templates.AddRange(TemplateIds.ToList()); + } + WriteObject(site); + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Provisioning/Tenant/NewTenantTemplate.cs b/Commands/Provisioning/Tenant/NewTenantTemplate.cs new file mode 100644 index 000000000..6c901965c --- /dev/null +++ b/Commands/Provisioning/Tenant/NewTenantTemplate.cs @@ -0,0 +1,41 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet(VerbsCommon.New, "PnPTenantTemplate", SupportsShouldProcess = true)] + [Alias("New-PnPProvisioningHierarchy")] + [CmdletHelp("Creates a new tenant template object", + Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> $template = New-PnPTenantTemplate", + Remarks = "Creates a new instance of a tenant template object.", + SortOrder = 1)] + public class NewTenantTemplate : PSCmdlet + { + [Parameter(Mandatory = false)] + public string Author; + + [Parameter(Mandatory = false)] + public string Description; + + [Parameter(Mandatory = false)] + public string DisplayName; + + [Parameter(Mandatory = false)] + public string Generator; + + protected override void ProcessRecord() + { + var result = new ProvisioningHierarchy(); + result.Author = Author; + result.Description = Description; + result.DisplayName = DisplayName; + result.Generator = Generator; + WriteObject(result); + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Provisioning/Tenant/ReadTenantTemplate.cs b/Commands/Provisioning/Tenant/ReadTenantTemplate.cs new file mode 100644 index 000000000..b0d699062 --- /dev/null +++ b/Commands/Provisioning/Tenant/ReadTenantTemplate.cs @@ -0,0 +1,80 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Framework.Provisioning.Connectors; +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using OfficeDevPnP.Core.Framework.Provisioning.Providers; +using OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using SharePointPnP.PowerShell.Commands.Utilities; +using System; +using System.IO; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet(VerbsCommunications.Read, "PnPTenantTemplate")] + [Alias("Read-PnPProvisioningHierarchy")] + [CmdletHelp("Loads/Reads a PnP tenant template from the file system and returns an in-memory instance of this template.", + Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> Read-PnPTenantTemplate -Path template.pnp", + Remarks = "Reads a PnP tenant templatey file from the file system and returns an in-memory instance", + SortOrder = 1)] + public class ReadTenantTemplate : PSCmdlet + { + [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename to read from, optionally including full path.")] + public string Path; + + [Parameter(Mandatory = false, HelpMessage = "Allows you to specify ITemplateProviderExtension to execute while loading the template.")] + public ITemplateProviderExtension[] TemplateProviderExtensions; + + protected override void ProcessRecord() + { + if (!System.IO.Path.IsPathRooted(Path)) + { + Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path); + } + WriteObject(LoadProvisioningHierarchyFromFile(Path, TemplateProviderExtensions)); + } + + internal static ProvisioningHierarchy LoadProvisioningHierarchyFromFile(string templatePath, ITemplateProviderExtension[] templateProviderExtensions) + { + // Prepare the File Connector + string templateFileName = System.IO.Path.GetFileName(templatePath); + + // Prepare the template path + var fileInfo = new FileInfo(templatePath); + FileConnectorBase fileConnector = new FileSystemConnector(fileInfo.DirectoryName, ""); + + // Load the provisioning template file + var isOpenOfficeFile = false; + using (var stream = fileConnector.GetFileStream(templateFileName)) + { + isOpenOfficeFile = FileUtilities.IsOpenOfficeFile(stream); + } + + XMLTemplateProvider provider; + if (isOpenOfficeFile) + { + provider = new XMLOpenXMLTemplateProvider(new OpenXMLConnector(templateFileName, fileConnector)); + templateFileName = templateFileName.Substring(0, templateFileName.LastIndexOf(".", StringComparison.Ordinal)) + ".xml"; + + var hierarchy = (provider as XMLOpenXMLTemplateProvider).GetHierarchy(); + if (hierarchy != null) + { + hierarchy.Connector = provider.Connector; + return hierarchy; + } + } + else + { + provider = new XMLFileSystemTemplateProvider(fileConnector.Parameters[FileConnectorBase.CONNECTIONSTRING] + "", ""); + } + + ProvisioningHierarchy provisioningHierarchy = provider.GetHierarchy(templateFileName); + provisioningHierarchy.Connector = provider.Connector; + // Return the result + return provisioningHierarchy; + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Provisioning/Tenant/SaveTenantTemplate.cs b/Commands/Provisioning/Tenant/SaveTenantTemplate.cs new file mode 100644 index 000000000..b2eb42636 --- /dev/null +++ b/Commands/Provisioning/Tenant/SaveTenantTemplate.cs @@ -0,0 +1,171 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Framework.Provisioning.Connectors; +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using OfficeDevPnP.Core.Framework.Provisioning.Providers; +using OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using System; +using System.IO; +using System.Linq; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet(VerbsData.Save, "PnPTenantTemplate")] + [Alias("Save-PnPProvisioningHierarchy")] + [CmdletHelp("Saves a PnP provisioning hierarchy to the file system", + Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> Save-PnPTenantTemplate -Template $template -Out .\hierarchy.pnp", + Remarks = "Saves a PnP tenant template to the file system", + SortOrder = 1)] + public class SaveTenantTemplate : PSCmdlet + { + [Parameter(Mandatory = true, HelpMessage = "Allows you to provide an in-memory instance of a Tenant Template. When using this parameter, the -Out parameter refers to the path for saving the template and storing any supporting file for the template.")] + [Alias("Hierarchy")] + public ProvisioningHierarchy Template; + + [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename to write to, optionally including full path.")] + public string Out; + + [Parameter(Mandatory = false, HelpMessage = "Specifying the Force parameter will skip the confirmation question.")] + public SwitchParameter Force; + + protected override void ProcessRecord() + { + // Determine the output file name and path + string outFileName = Path.GetFileName(Out); + + if (!Path.IsPathRooted(Out)) + { + Out = Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Out); + } + + bool proceed = false; + + if (System.IO.File.Exists(Out)) + { + if (Force || ShouldContinue(string.Format(Properties.Resources.File0ExistsOverwrite, Out), + Properties.Resources.Confirm)) + { + System.IO.File.Delete(Out); + proceed = true; + } + } + else + { + proceed = true; + } + + string outPath = new FileInfo(Out).DirectoryName; + + // Determine if it is an .XML or a .PNP file + var extension = ""; + if (proceed && outFileName != null) + { + if (outFileName.IndexOf(".", StringComparison.Ordinal) > -1) + { + extension = outFileName.Substring(outFileName.LastIndexOf(".", StringComparison.Ordinal)).ToLower(); + } + else + { + extension = ".pnp"; + } + } + + var fileSystemConnector = new FileSystemConnector(outPath, ""); + + ITemplateFormatter formatter = XMLPnPSchemaFormatter.LatestFormatter; + + if (extension == ".pnp") + { + // var connector = new OpenXMLConnector(Out, fileSystemConnector); + var templateFileName = outFileName.Substring(0, outFileName.LastIndexOf(".", StringComparison.Ordinal)) + ".xml"; + + XMLTemplateProvider provider = new XMLOpenXMLTemplateProvider( + Out, fileSystemConnector, templateFileName: templateFileName); + WriteObject("Processing template"); + provider.SaveAs(Template, templateFileName); + ProcessFiles(Out, fileSystemConnector, provider.Connector); + + //provider.SaveAs(Hierarchy, templateFileName); + //connector.Commit(); + } + else + { + XMLTemplateProvider provider = new XMLFileSystemTemplateProvider(outPath, ""); + provider.SaveAs(Template, Out); + } + } + + private void ProcessFiles(string templateFileName, FileConnectorBase fileSystemConnector, FileConnectorBase connector) + { + var hierarchy = ReadTenantTemplate.LoadProvisioningHierarchyFromFile(templateFileName, null); + if (Template.Tenant?.AppCatalog != null) + { + foreach (var app in Template.Tenant.AppCatalog.Packages) + { + WriteObject($"Processing {app.Src}"); + AddFile(app.Src, hierarchy, fileSystemConnector, connector); + } + } + if (Template.Tenant?.SiteScripts != null) + { + foreach (var siteScript in Template.Tenant.SiteScripts) + { + WriteObject($"Processing {siteScript.JsonFilePath}"); + AddFile(siteScript.JsonFilePath, hierarchy, fileSystemConnector, connector); + } + } + if (Template.Localizations != null && Template.Localizations.Any()) + { + foreach (var location in Template.Localizations) + { + WriteObject($"Processing {location.ResourceFile}"); + AddFile(location.ResourceFile, hierarchy, fileSystemConnector, connector); + } + } + foreach (var template in Template.Templates) + { + if(template.WebSettings != null && template.WebSettings.SiteLogo != null) + { + // is it a file? + var isFile = false; + using (var fileStream = fileSystemConnector.GetFileStream(template.WebSettings.SiteLogo)) + { + isFile = fileStream != null; + } + if (isFile) + { + WriteObject($"Processing {template.WebSettings.SiteLogo}"); + AddFile(template.WebSettings.SiteLogo, hierarchy, fileSystemConnector, connector); + } + } + if (template.Files.Any()) + { + foreach (var file in template.Files) + { + AddFile(file.Src, hierarchy, fileSystemConnector, connector); + } + } + } + + } + + private void AddFile(string sourceName, ProvisioningHierarchy hierarchy, FileConnectorBase fileSystemConnector, FileConnectorBase connector) + { + using (var fs = fileSystemConnector.GetFileStream(sourceName)) + { + var fileName = sourceName.IndexOf("\\") > 0 ? sourceName.Substring(sourceName.LastIndexOf("\\") + 1) : sourceName; + var folderName = sourceName.IndexOf("\\") > 0 ? sourceName.Substring(0, sourceName.LastIndexOf("\\")) : ""; + hierarchy.Connector.SaveFileStream(fileName, folderName, fs); + + if (hierarchy.Connector is ICommitableFileConnector) + { + ((ICommitableFileConnector)hierarchy.Connector).Commit(); + } + } + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Provisioning/Tenant/TestTenantTemplate.cs b/Commands/Provisioning/Tenant/TestTenantTemplate.cs new file mode 100644 index 000000000..c92c37cab --- /dev/null +++ b/Commands/Provisioning/Tenant/TestTenantTemplate.cs @@ -0,0 +1,93 @@ +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet(VerbsDiagnostic.Test, "PnPTenantTemplate", SupportsShouldProcess = true)] + [Alias("Test-PnPProvisioningHierarchy")] + [CmdletHelp("Tests a provisioning hierarchy for invalid references", + Category = CmdletHelpCategory.Provisioning)] + [CmdletExample( + Code = @"PS:> Test-PnPProvisioningHierarchy -Hierarchy $myhierarchy", + Remarks = "Checks for valid template references", + SortOrder = 1)] + public class TestTenantTemplate : PnPCmdlet + { + [Parameter(Mandatory = true, HelpMessage = "The in-memory template to test", ParameterSetName = ParameterAttribute.AllParameterSets)] + [Alias("Hierarchy")] + public ProvisioningHierarchy Template; + + protected override void ExecuteCmdlet() + { + List issues = new List(); + foreach(var sequence in Template.Sequences) + { + foreach (var site in sequence.SiteCollections) + { + foreach (var template in site.Templates) + { + if(Template.Templates.FirstOrDefault(t => t.Id == template) == null) + { + issues.Add($"Template {template} referenced in site {site.Id} is not present in tenant template."); + } + } + foreach(var subsite in site.Sites.Cast()) + { + foreach (var template in subsite.Templates) + { + if (Template.Templates.FirstOrDefault(t => t.Id == template) == null) + { + issues.Add($"Template {template} referenced in subsite with url {subsite.Url} in site {site.Id} is not present in tenant template."); + } + } + } + } + } + foreach(var template in Template.Templates) + { + var used = false; + foreach(var sequence in Template.Sequences) + { + foreach(var site in sequence.SiteCollections) + { + if(site.Templates.Contains(template.Id)) + { + used = true; + break; + } + + foreach(var subsite in site.Sites) + { + if(subsite.Templates.Contains(template.Id)) + { + used = true; + break; + } + } + if (used) + { + break; + } + } + if(used) + { + break; + } + } + if(!used) + { + issues.Add($"Template {template.Id} is not used by any site in the tenant template sequence."); + } + } + if(issues.Any()) + { + WriteObject(issues, true); + } + + } + } +} From fd78fbdf3b4d38bf6ab664a82d43ceb7670e351a Mon Sep 17 00:00:00 2001 From: VesaJuvonen Date: Wed, 24 Oct 2018 16:32:43 +0300 Subject: [PATCH 10/30] Fixing documentation for Publish-PnPApp. Issue reported in office-docs-powershell repo as #1834 --- Commands/Apps/PublishApp.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Commands/Apps/PublishApp.cs b/Commands/Apps/PublishApp.cs index 181d0fda3..c91b05c78 100644 --- a/Commands/Apps/PublishApp.cs +++ b/Commands/Apps/PublishApp.cs @@ -11,10 +11,10 @@ namespace SharePointPnP.PowerShell.Commands.Apps [CmdletHelp("Publishes/Deploys/Trusts an available app in the app catalog", Category = CmdletHelpCategory.Apps, SupportedPlatform = CmdletSupportedPlatform.Online)] [CmdletExample( - Code = @"PS:> Publish-PnPApp -Identity -Identity 2646ccc3-6a2b-46ef-9273-81411cbbb60f", + Code = @"PS:> Publish-PnPApp -Identity 2646ccc3-6a2b-46ef-9273-81411cbbb60f", Remarks = @"This will deploy/trust an app into the app catalog. Notice that the app needs to be available in the tenant scoped app catalog", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Publish-PnPApp -Identity -Identity 2646ccc3-6a2b-46ef-9273-81411cbbb60f -Scope Site", + Code = @"PS:> Publish-PnPApp -Identity 2646ccc3-6a2b-46ef-9273-81411cbbb60f -Scope Site", Remarks = @"This will deploy/trust an app into the app catalog. Notice that the app needs to be available in the site collection scoped app catalog", SortOrder = 1)] public class PublishApp : PnPCmdlet { From 960c87d44a93af0b9b24c956406fd7a853c0dc17 Mon Sep 17 00:00:00 2001 From: VesaJuvonen Date: Thu, 25 Oct 2018 16:10:10 +0300 Subject: [PATCH 11/30] Removing code sample from removed parameter --- Commands/Site/SetSite.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Commands/Site/SetSite.cs b/Commands/Site/SetSite.cs index 68fdbbe5f..c48347d7f 100644 --- a/Commands/Site/SetSite.cs +++ b/Commands/Site/SetSite.cs @@ -25,10 +25,6 @@ namespace SharePointPnP.PowerShell.Commands.Site Code = @"PS:> Set-PnPSite -DisableFlows:$false", Remarks = "Enables Flows for this site", SortOrder = 3)] - [CmdletExample( - Code = @"PS:> Set-PnPSite -SiteLogoPath c:\images\mylogo.png", - Remarks = "Sets the logo if the site is a modern team site", - SortOrder = 4)] public class SetSite : PnPCmdlet { [Parameter(Mandatory = false, HelpMessage = "The classification to set")] From e45720398ae2832d3a0dfb345aa9c45a88803304 Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Wed, 31 Oct 2018 09:52:14 +0100 Subject: [PATCH 12/30] Fixes issue with unified groups as mentioned in issue #1756 --- Commands/Graph/SetUnifiedGroup.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Commands/Graph/SetUnifiedGroup.cs b/Commands/Graph/SetUnifiedGroup.cs index bee867431..604aa900e 100644 --- a/Commands/Graph/SetUnifiedGroup.cs +++ b/Commands/Graph/SetUnifiedGroup.cs @@ -5,7 +5,6 @@ using SharePointPnP.PowerShell.Commands.Base.PipeBinds; using System; using System.IO; -using System.Linq; using System.Management.Automation; namespace SharePointPnP.PowerShell.Commands.Graph @@ -78,10 +77,15 @@ protected override void ExecuteCmdlet() } groupLogoStream = new FileStream(GroupLogoPath, FileMode.Open, FileAccess.Read); } - + bool? isPrivateGroup = null; + if(IsPrivate.IsPresent) + { + isPrivateGroup = IsPrivate.ToBool(); + } UnifiedGroupsUtility.UpdateUnifiedGroup(group.GroupId, AccessToken, displayName: DisplayName, - description: Description, owners: Owners, members: Members, groupLogo: groupLogoStream, isPrivate: IsPrivate); - } else + description: Description, owners: Owners, members: Members, groupLogo: groupLogoStream, isPrivate: isPrivateGroup); + } + else { WriteError(new ErrorRecord(new Exception("Group not found"), "GROUPNOTFOUND", ErrorCategory.ObjectNotFound, this)); } From fb9b4fce1f8aafd5127e40312aec1711ee82765e Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Wed, 31 Oct 2018 09:55:10 +0100 Subject: [PATCH 13/30] Renamed cmdlets --- .../Provisioning/Tenant/AddSiteTemplate.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Commands/Provisioning/Tenant/AddSiteTemplate.cs diff --git a/Commands/Provisioning/Tenant/AddSiteTemplate.cs b/Commands/Provisioning/Tenant/AddSiteTemplate.cs new file mode 100644 index 000000000..5f65962be --- /dev/null +++ b/Commands/Provisioning/Tenant/AddSiteTemplate.cs @@ -0,0 +1,40 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Framework.Provisioning.Model; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using SharePointPnP.PowerShell.Commands.Base.PipeBinds; +using System; +using System.Linq; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant +{ + [Cmdlet(VerbsCommon.Add, "PnPSiteTemplate", SupportsShouldProcess = true)] + [Alias("Add-PnpProvisioningTemplate")] + [CmdletHelp("Adds a PnP Site Template object to a tenant template", + Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> Add-PnPSiteTemplate -TenantTemplate $tenanttemplate -SiteTemplate $sitetemplate", + Remarks = "Adds an existing site template to an existing tenant template object", + SortOrder = 1)] + public class AddSiteTemplate : PSCmdlet + { + [Parameter(Mandatory = true, HelpMessage = "The template to add to the tenant template")] + [Alias("Template")] + public ProvisioningTemplate SiteTemplate; + + [Parameter(Mandatory = true, HelpMessage = "The tenant template to add the template to", ValueFromPipeline = true)] + [Alias("Hierarchy")] + public ProvisioningHierarchy TenantTemplate; + + protected override void ProcessRecord() + { + if(TenantTemplate.Templates.FirstOrDefault(t => t.Id == SiteTemplate.Id) == null) + { + TenantTemplate.Templates.Add(SiteTemplate); + } else { + WriteError(new ErrorRecord(new Exception($"Template with ID {SiteTemplate.Id} already exists in hierarchy"), "DUPLICATETEMPLATE", ErrorCategory.InvalidData, SiteTemplate)); + } + } + } +} +#endif \ No newline at end of file From 8e1c261a63254dd9d8ebc6964a5be51ac09b25c5 Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Wed, 31 Oct 2018 09:55:27 +0100 Subject: [PATCH 14/30] Renamed cmdlets --- CHANGELOG.md | 4 + .../Provisioning/AddProvisioningSequence.cs | 43 --- Commands/Provisioning/AddProvisioningSite.cs | 31 -- .../Provisioning/AddProvisioningSubSite.cs | 38 --- .../Provisioning/AddProvisioningTemplate.cs | 37 --- .../ApplyProvisioningHierarchy.cs | 266 ------------------ .../Provisioning/GetProvisioningSequence.cs | 39 --- Commands/Provisioning/GetProvisioningSite.cs | 39 --- .../NewProvisioningCommunicationSite.cs | 73 ----- .../Provisioning/NewProvisioningHierarchy.cs | 40 --- .../Provisioning/NewProvisioningSequence.cs | 38 --- .../NewProvisioningTeamNoGroupSite.cs | 62 ---- .../NewProvisioningTeamNoGroupSubSite.cs | 64 ----- .../Provisioning/NewProvisioningTeamSite.cs | 63 ----- .../Provisioning/ReadProvisioningHierarchy.cs | 79 ------ .../Provisioning/SaveProvisioningHierarchy.cs | 172 ----------- .../AddDataRowsToSiteTemplate.cs} | 15 +- .../AddFileToSiteTemplate.cs} | 27 +- .../AddListFoldersToSiteTemplate.cs} | 23 +- .../ApplySiteTemplate.cs} | 39 +-- .../ConvertFolderToProvisioningTemplate.cs | 9 +- .../ConvertSiteTemplate.cs} | 26 +- .../GetProvisioningTemplateFromGallery.cs | 3 +- .../GetSiteTemplate.cs} | 35 +-- .../NewProvisioningTemplateFromFolder.cs | 0 .../NewSiteTemplate.cs} | 11 +- .../ReadSiteTemplate.cs} | 10 +- .../RemoveFileFromSiteTemplate.cs} | 16 +- .../SaveSiteTemplate.cs} | 11 +- .../SetSiteTemplateMetadata.cs} | 35 +-- .../Provisioning/TestProvisioningHierarchy.cs | 91 ------ .../SharePointPnP.PowerShell.Commands.csproj | 60 ++-- 32 files changed, 171 insertions(+), 1328 deletions(-) delete mode 100644 Commands/Provisioning/AddProvisioningSequence.cs delete mode 100644 Commands/Provisioning/AddProvisioningSite.cs delete mode 100644 Commands/Provisioning/AddProvisioningSubSite.cs delete mode 100644 Commands/Provisioning/AddProvisioningTemplate.cs delete mode 100644 Commands/Provisioning/ApplyProvisioningHierarchy.cs delete mode 100644 Commands/Provisioning/GetProvisioningSequence.cs delete mode 100644 Commands/Provisioning/GetProvisioningSite.cs delete mode 100644 Commands/Provisioning/NewProvisioningCommunicationSite.cs delete mode 100644 Commands/Provisioning/NewProvisioningHierarchy.cs delete mode 100644 Commands/Provisioning/NewProvisioningSequence.cs delete mode 100644 Commands/Provisioning/NewProvisioningTeamNoGroupSite.cs delete mode 100644 Commands/Provisioning/NewProvisioningTeamNoGroupSubSite.cs delete mode 100644 Commands/Provisioning/NewProvisioningTeamSite.cs delete mode 100644 Commands/Provisioning/ReadProvisioningHierarchy.cs delete mode 100644 Commands/Provisioning/SaveProvisioningHierarchy.cs rename Commands/Provisioning/{AddDataRowsToProvisioningTemplate.cs => Site/AddDataRowsToSiteTemplate.cs} (95%) rename Commands/Provisioning/{AddFileToProvisioningTemplate.cs => Site/AddFileToSiteTemplate.cs} (79%) rename Commands/Provisioning/{AddListFoldersToProvisioningTemplate.cs => Site/AddListFoldersToSiteTemplate.cs} (89%) rename Commands/Provisioning/{ApplyProvisioningTemplate.cs => Site/ApplySiteTemplate.cs} (88%) rename Commands/Provisioning/{ => Site}/ConvertFolderToProvisioningTemplate.cs (93%) rename Commands/Provisioning/{ConvertProvisioningTemplate.cs => Site/ConvertSiteTemplate.cs} (84%) rename Commands/Provisioning/{ => Site}/GetProvisioningTemplateFromGallery.cs (97%) rename Commands/Provisioning/{GetProvisioningTemplate.cs => Site/GetSiteTemplate.cs} (94%) rename Commands/Provisioning/{ => Site}/NewProvisioningTemplateFromFolder.cs (100%) rename Commands/Provisioning/{NewProvisioningTemplate.cs => Site/NewSiteTemplate.cs} (57%) rename Commands/Provisioning/{ReadProvisioningTemplate.cs => Site/ReadSiteTemplate.cs} (90%) rename Commands/Provisioning/{RemoveFileFromProvisioningTemplate.cs => Site/RemoveFileFromSiteTemplate.cs} (86%) rename Commands/Provisioning/{SaveProvisioningTemplate.cs => Site/SaveSiteTemplate.cs} (90%) rename Commands/Provisioning/{SetProvisioningTemplateMetadata.cs => Site/SetSiteTemplateMetadata.cs} (72%) delete mode 100644 Commands/Provisioning/TestProvisioningHierarchy.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e6344d0d..c41250199 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Updated documentation for New-PnPTenantSite - Fixed documentation for Measure-PnPWeb - Updated samples +- Fixes issue with Set-PnPUnifiedGroup where if you only change for instance the displayname a private group would be marked as public. + +### Deprecated +- Marked Get-PnPProvisioningTemplateFromGallery as deprecated as the PnP Template Gallery has been shut down. ### Contributors - Paul Bullock (pkbullock) diff --git a/Commands/Provisioning/AddProvisioningSequence.cs b/Commands/Provisioning/AddProvisioningSequence.cs deleted file mode 100644 index 2ed6fabdf..000000000 --- a/Commands/Provisioning/AddProvisioningSequence.cs +++ /dev/null @@ -1,43 +0,0 @@ -#if !ONPREMISES -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using System; -using System.Linq; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet(VerbsCommon.Add, "PnPProvisioningSequence", SupportsShouldProcess = true)] - [CmdletHelp("Adds a provisioning sequence object to a provisioning hierarchy", - Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] - [CmdletExample( - Code = @"PS:> Add-PnPProvisioningSequence -Hierarchy $myhierarchy -Sequence $mysequence", - Remarks = "Adds an existing sequence object to an existing hierarchy object", - SortOrder = 1)] - [CmdletExample( - Code = @"PS:> New-PnPProvisioningSequence -Id ""MySequence"" | Add-PnPProvisioningSequence -Hierarchy $hierarchy", - Remarks = "Creates a new instance of a provisioning sequence object and sets the Id to the value specified, then the sequence is added to an existing hierarchy object", - SortOrder = 2)] - public class AddProvisioningSequence : PSCmdlet - { - [Parameter(Mandatory = true, HelpMessage = "The hierarchy to add the sequence to", ParameterSetName = ParameterAttribute.AllParameterSets)] - public ProvisioningHierarchy Hierarchy; - - [Parameter(Mandatory = true, HelpMessage = "Optional Id of the sequence", ParameterSetName = ParameterAttribute.AllParameterSets, ValueFromPipeline = true)] - public ProvisioningSequence Sequence; - - protected override void ProcessRecord() - { - if (Hierarchy.Sequences.FirstOrDefault(s => s.ID == Sequence.ID) == null) - { - Hierarchy.Sequences.Add(Sequence); - WriteObject(Hierarchy); - } - else - { - WriteError(new ErrorRecord(new Exception($"Sequence with ID {Sequence.ID} already exists in hierarchy"), "DUPLICATESEQUENCEID", ErrorCategory.InvalidData, Sequence)); - } - } - } -} -#endif \ No newline at end of file diff --git a/Commands/Provisioning/AddProvisioningSite.cs b/Commands/Provisioning/AddProvisioningSite.cs deleted file mode 100644 index e98888827..000000000 --- a/Commands/Provisioning/AddProvisioningSite.cs +++ /dev/null @@ -1,31 +0,0 @@ -#if !ONPREMISES -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using SharePointPnP.PowerShell.Commands.Base.PipeBinds; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet(VerbsCommon.Add, "PnPProvisioningSite", SupportsShouldProcess = true)] - [CmdletHelp("Adds a provisioning sequence object to a provisioning hierarchy", - Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] - [CmdletExample( - Code = @"PS:> Add-PnPProvisioningSite -Site $myteamsite -Sequence $mysequence", - Remarks = "Adds an existing site object to an existing hierarchy sequence", - SortOrder = 1)] - public class AddProvisioningSite : PSCmdlet - { - [Parameter(Mandatory = true, ValueFromPipeline = true)] - public ProvisioningSitePipeBind Site; - - [Parameter(Mandatory = true, HelpMessage = "The sequence to add the site to", ValueFromPipeline = true)] - public ProvisioningSequence Sequence; - - protected override void ProcessRecord() - { - Sequence.SiteCollections.Add(Site.Site); - WriteObject(Sequence); - } - } -} -#endif \ No newline at end of file diff --git a/Commands/Provisioning/AddProvisioningSubSite.cs b/Commands/Provisioning/AddProvisioningSubSite.cs deleted file mode 100644 index 89669e8db..000000000 --- a/Commands/Provisioning/AddProvisioningSubSite.cs +++ /dev/null @@ -1,38 +0,0 @@ -#if !ONPREMISES -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using System; -using System.Linq; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet(VerbsCommon.Add, "PnPProvisioningSubSite", SupportsShouldProcess = true)] - [CmdletHelp("Adds a provisioning sequence object to a provisioning site object", - Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] - [CmdletExample( - Code = @"PS:> Add-PnPProvisioningSubSite -Site $mysite -SubSite $mysubsite", - Remarks = "Adds an existing subsite object to an existing hierarchy sequence site object", - SortOrder = 1)] - public class AddProvisioningSubSite : PSCmdlet - { - [Parameter(Mandatory = true, HelpMessage = "The subsite to add")] - public TeamNoGroupSubSite SubSite; - - [Parameter(Mandatory = true, HelpMessage = "The site to add the subsite to", ValueFromPipeline = true)] - public SiteCollection Site; - - protected override void ProcessRecord() - { - if (Site.Sites.Cast().FirstOrDefault(s => s.Url == SubSite.Url) == null) - { - Site.Sites.Add(SubSite); - } - else - { - WriteError(new ErrorRecord(new Exception($"Site with URL {SubSite.Url} already exists in sequence"), "DUPLICATEURL", ErrorCategory.InvalidData, SubSite)); - } - } - } -} -#endif \ No newline at end of file diff --git a/Commands/Provisioning/AddProvisioningTemplate.cs b/Commands/Provisioning/AddProvisioningTemplate.cs deleted file mode 100644 index 215ff1a1c..000000000 --- a/Commands/Provisioning/AddProvisioningTemplate.cs +++ /dev/null @@ -1,37 +0,0 @@ -#if !ONPREMISES -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using SharePointPnP.PowerShell.Commands.Base.PipeBinds; -using System; -using System.Linq; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet(VerbsCommon.Add, "PnPProvisioningTemplate", SupportsShouldProcess = true)] - [CmdletHelp("Adds a provisioning template object to a provisioning hierarchy", - Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] - [CmdletExample( - Code = @"PS:> Add-PnPProvisioningTemplate -Hierarchy $myhierarchy -Template $mytemplate", - Remarks = "Adds an existing sequence object to an existing hierarchy object", - SortOrder = 1)] - public class AddProvisioningTemplate : PSCmdlet - { - [Parameter(Mandatory = true, HelpMessage = "The template to add to the hierarchy")] - public ProvisioningTemplate Template; - - [Parameter(Mandatory = true, HelpMessage = "The hierarchy to add the template to", ValueFromPipeline = true)] - public ProvisioningHierarchy Hierarchy; - - protected override void ProcessRecord() - { - if(Hierarchy.Templates.FirstOrDefault(t => t.Id == Template.Id) == null) - { - Hierarchy.Templates.Add(Template); - } else { - WriteError(new ErrorRecord(new Exception($"Template with ID {Template.Id} already exists in hierarchy"), "DUPLICATETEMPLATE", ErrorCategory.InvalidData, Template)); - } - } - } -} -#endif \ No newline at end of file diff --git a/Commands/Provisioning/ApplyProvisioningHierarchy.cs b/Commands/Provisioning/ApplyProvisioningHierarchy.cs deleted file mode 100644 index 41be05e31..000000000 --- a/Commands/Provisioning/ApplyProvisioningHierarchy.cs +++ /dev/null @@ -1,266 +0,0 @@ -#if !ONPREMISES -using Microsoft.SharePoint.Client; -using OfficeDevPnP.Core.Framework.Provisioning.Connectors; -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers; -using OfficeDevPnP.Core.Framework.Provisioning.Providers; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using SharePointPnP.PowerShell.Commands.Base; -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet("Apply", "PnPProvisioningHierarchy", SupportsShouldProcess = true)] - [CmdletHelp("Adds a provisioning sequence object to a provisioning site object", - Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] - [CmdletExample( - Code = @"PS:> Apply-PnPProvisioningHierarchy -Path myfile.pnp", - Remarks = "Will read the provisioning hierarchy from the filesystem and will apply the sequences in the hierarchy", - SortOrder = 1)] - [CmdletExample( - Code = @"PS:> Apply-PnPProvisioningHierarchy -Path myfile.pnp -SequenceId ""mysequence""", - Remarks = "Will read the provisioning hierarchy from the filesystem and will apply the specified sequence in the hierarchy", - SortOrder = 1)] - [CmdletExample( - Code = @"PS:> Apply-PnPProvisioningHierarchy -Path myfile.pnp -Parameters @{""ListTitle""=""Projects"";""parameter2""=""a second value""}", - Remarks = @"Applies a provisioning hierarchy template to the current tenant. It will populate the parameter in the template the values as specified and in the template you can refer to those values with the {parameter:} token. - -For instance with the example above, specifying {parameter:ListTitle} in your template will translate to 'Projects' when applying the template. These tokens can be used in most string values in a template.", - SortOrder = 3)] - public class ApplyProvisioningHierarchy : PnPAdminCmdlet - { - private const string ParameterSet_PATH = "By Path"; - private const string ParameterSet_OBJECT = "By Object"; - - private ProgressRecord progressRecord = new ProgressRecord(0, "Activity", "Status"); - private ProgressRecord subProgressRecord = new ProgressRecord(1, "Activity", "Status"); - - [Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true, HelpMessage = "Path to the xml or pnp file containing the provisioning hierarchy.", ParameterSetName = ParameterSet_PATH)] - public string Path; - - [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ParameterSetName = ParameterSet_OBJECT)] - public ProvisioningHierarchy Hierarchy; - - [Parameter(Mandatory = false)] - public string SequenceId; - - [Parameter(Mandatory = false, HelpMessage = "Root folder where resources/files that are being referenced in the template are located. If not specified the same folder as where the provisioning template is located will be used.", ParameterSetName = ParameterAttribute.AllParameterSets)] - public string ResourceFolder; - - [Parameter(Mandatory = false, HelpMessage = "Allows you to only process a specific part of the template. Notice that this might fail, as some of the handlers require other artifacts in place if they are not part of what your applying.", ParameterSetName = ParameterAttribute.AllParameterSets)] - public Handlers Handlers; - - [Parameter(Mandatory = false, HelpMessage = "Allows you to run all handlers, excluding the ones specified.", ParameterSetName = ParameterAttribute.AllParameterSets)] - public Handlers ExcludeHandlers; - - [Parameter(Mandatory = false, HelpMessage = "Allows you to specify ExtensbilityHandlers to execute while applying a template", ParameterSetName = ParameterAttribute.AllParameterSets)] - public ExtensibilityHandler[] ExtensibilityHandlers; - - [Parameter(Mandatory = false, HelpMessage = "Allows you to specify ITemplateProviderExtension to execute while applying a template.", ParameterSetName = ParameterAttribute.AllParameterSets)] - public ITemplateProviderExtension[] TemplateProviderExtensions; - - [Parameter(Mandatory = false, HelpMessage = "Allows you to specify parameters that can be referred to in the hierarchy by means of the {parameter:} token. See examples on how to use this parameter.", ParameterSetName = ParameterAttribute.AllParameterSets)] - public Hashtable Parameters; - - [Parameter(Mandatory = false, HelpMessage = "Specify this parameter if you want to overwrite and/or create properties that are known to be system entries (starting with vti_, dlc_, etc.)", ParameterSetName = ParameterAttribute.AllParameterSets)] - public SwitchParameter OverwriteSystemPropertyBagValues; - - [Parameter(Mandatory = false, HelpMessage = "Ignore duplicate data row errors when the data row in the template already exists.", ParameterSetName = ParameterAttribute.AllParameterSets)] - public SwitchParameter IgnoreDuplicateDataRowErrors; - - [Parameter(Mandatory = false, HelpMessage = "If set content types will be provisioned if the target web is a subweb.")] - public SwitchParameter ProvisionContentTypesToSubWebs; - - [Parameter(Mandatory = false, HelpMessage = "If set fields will be provisioned if the target web is a subweb.")] - public SwitchParameter ProvisionFieldsToSubWebs; - - [Parameter(Mandatory = false, HelpMessage = "Override the RemoveExistingNodes attribute in the Navigation elements of the template. If you specify this value the navigation nodes will always be removed before adding the nodes in the template")] - public SwitchParameter ClearNavigation; - - protected override void ExecuteCmdlet() - { - var applyingInformation = new ProvisioningTemplateApplyingInformation(); - - if (MyInvocation.BoundParameters.ContainsKey("Handlers")) - { - applyingInformation.HandlersToProcess = Handlers; - } - if (MyInvocation.BoundParameters.ContainsKey("ExcludeHandlers")) - { - foreach (var handler in (Handlers[])Enum.GetValues(typeof(Handlers))) - { - if (!ExcludeHandlers.Has(handler) && handler != Handlers.All) - { - Handlers = Handlers | handler; - } - } - applyingInformation.HandlersToProcess = Handlers; - } - - if (ExtensibilityHandlers != null) - { - applyingInformation.ExtensibilityHandlers = ExtensibilityHandlers.ToList(); - } - - applyingInformation.ProgressDelegate = (message, step, total) => - { - if (message != null) - { - var percentage = Convert.ToInt32((100 / Convert.ToDouble(total)) * Convert.ToDouble(step)); - progressRecord.Activity = $"Applying template to tenant"; - progressRecord.StatusDescription = message; - progressRecord.PercentComplete = percentage; - progressRecord.RecordType = ProgressRecordType.Processing; - WriteProgress(progressRecord); - } - }; - - var warningsShown = new List(); - - applyingInformation.MessagesDelegate = (message, type) => - { - switch (type) - { - case ProvisioningMessageType.Warning: - { - if (!warningsShown.Contains(message)) - { - WriteWarning(message); - warningsShown.Add(message); - } - break; - } - case ProvisioningMessageType.Progress: - { - if (message != null) - { - var activity = message; - if (message.IndexOf("|") > -1) - { - var messageSplitted = message.Split('|'); - if (messageSplitted.Length == 4) - { - var current = double.Parse(messageSplitted[2]); - var total = double.Parse(messageSplitted[3]); - subProgressRecord.RecordType = ProgressRecordType.Processing; - subProgressRecord.Activity = string.IsNullOrEmpty(messageSplitted[0]) ? "-" : messageSplitted[0]; - subProgressRecord.StatusDescription = string.IsNullOrEmpty(messageSplitted[1]) ? "-" : messageSplitted[1]; - subProgressRecord.PercentComplete = Convert.ToInt32((100 / total) * current); - WriteProgress(subProgressRecord); - } - else - { - subProgressRecord.Activity = "Processing"; - subProgressRecord.RecordType = ProgressRecordType.Processing; - subProgressRecord.StatusDescription = activity; - subProgressRecord.PercentComplete = 0; - WriteProgress(subProgressRecord); - } - } - else - { - subProgressRecord.Activity = "Processing"; - subProgressRecord.RecordType = ProgressRecordType.Processing; - subProgressRecord.StatusDescription = activity; - subProgressRecord.PercentComplete = 0; - WriteProgress(subProgressRecord); - } - } - break; - } - case ProvisioningMessageType.Completed: - { - - WriteProgress(new ProgressRecord(1, message, " ") { RecordType = ProgressRecordType.Completed }); - break; - } - } - }; - - applyingInformation.OverwriteSystemPropertyBagValues = OverwriteSystemPropertyBagValues; - applyingInformation.IgnoreDuplicateDataRowErrors = IgnoreDuplicateDataRowErrors; - applyingInformation.ClearNavigation = ClearNavigation; - applyingInformation.ProvisionContentTypesToSubWebs = ProvisionContentTypesToSubWebs; - applyingInformation.ProvisionFieldsToSubWebs = ProvisionFieldsToSubWebs; - - ProvisioningHierarchy hierarchyToApply = null; - - switch (ParameterSetName) - { - case ParameterSet_PATH: - { - hierarchyToApply = GetHierarchy(); - break; - } - case ParameterSet_OBJECT: - { - hierarchyToApply = Hierarchy; - if (ResourceFolder != null) - { - var fileSystemConnector = new FileSystemConnector(ResourceFolder, ""); - hierarchyToApply.Connector = fileSystemConnector; - } - else - { - if (Path != null) - { - if (!System.IO.Path.IsPathRooted(Path)) - { - Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path); - } - } - else - { - Path = SessionState.Path.CurrentFileSystemLocation.Path; - } - var fileInfo = new FileInfo(Path); - var fileConnector = new FileSystemConnector(fileInfo.DirectoryName, ""); - hierarchyToApply.Connector = fileConnector; - } - break; - } - } - if (Parameters != null) - { - foreach (var parameter in Parameters.Keys) - { - if (hierarchyToApply.Parameters.ContainsKey(parameter.ToString())) - { - hierarchyToApply.Parameters[parameter.ToString()] = Parameters[parameter].ToString(); - } - else - { - hierarchyToApply.Parameters.Add(parameter.ToString(), Parameters[parameter].ToString()); - } - } - } - if (!string.IsNullOrEmpty(SequenceId)) - { - Tenant.ApplyProvisionHierarchy(hierarchyToApply, SequenceId, applyingInformation); - } - else - { - foreach (var sequence in hierarchyToApply.Sequences) - { - Tenant.ApplyProvisionHierarchy(hierarchyToApply, sequence.ID, applyingInformation); - } - } - - } - - private ProvisioningHierarchy GetHierarchy() - { - if(!System.IO.Path.IsPathRooted(Path)) - { - Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path); - } - return ReadProvisioningHierarchy.LoadProvisioningHierarchyFromFile(Path, TemplateProviderExtensions); - } - } -} -#endif \ No newline at end of file diff --git a/Commands/Provisioning/GetProvisioningSequence.cs b/Commands/Provisioning/GetProvisioningSequence.cs deleted file mode 100644 index f59079421..000000000 --- a/Commands/Provisioning/GetProvisioningSequence.cs +++ /dev/null @@ -1,39 +0,0 @@ -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using SharePointPnP.PowerShell.Commands.Base.PipeBinds; -using System; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet(VerbsCommon.Get, "PnPProvisioningSequence", SupportsShouldProcess = true)] - [CmdletHelp("Returns one ore more provisioning sequence object(s) from a provisioning hierarchy", - Category = CmdletHelpCategory.Provisioning)] - [CmdletExample( - Code = @"PS:> Get-PnPProvisioningSequence -Hierarchy $myhierarchy", - Remarks = "Returns all sequences from the specified hierarchy", - SortOrder = 1)] - [CmdletExample( - Code = @"PS:> Get-PnPProvisioningSequence -Hierarchy $myhierarchy -Identity ""mysequence""", - Remarks = "Returns the specified sequence from the specified hierarchy", - SortOrder = 2)] - public class GetProvisioningSequence : PSCmdlet - { - [Parameter(Mandatory = true, HelpMessage = "The hierarchy to retrieve the sequence from", ParameterSetName = ParameterAttribute.AllParameterSets)] - public ProvisioningHierarchy Hierarchy; - - [Parameter(Mandatory = false, HelpMessage = "Optional Id of the sequence", ParameterSetName = ParameterAttribute.AllParameterSets, ValueFromPipeline = true)] - public ProvisioningSequencePipeBind Identity; - protected override void ProcessRecord() - { - if (!MyInvocation.BoundParameters.ContainsKey("Identity")) - { - WriteObject(Hierarchy.Sequences, true); - } - else - { - WriteObject(Identity.GetSequenceFromHierarchy(Hierarchy)); - } - } - } -} diff --git a/Commands/Provisioning/GetProvisioningSite.cs b/Commands/Provisioning/GetProvisioningSite.cs deleted file mode 100644 index d736ac23f..000000000 --- a/Commands/Provisioning/GetProvisioningSite.cs +++ /dev/null @@ -1,39 +0,0 @@ -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using SharePointPnP.PowerShell.Commands.Base.PipeBinds; -using System; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet(VerbsCommon.Get, "PnPProvisioningSite", SupportsShouldProcess = true)] - [CmdletHelp("Returns one ore more provisioning sequence object(s) from a provisioning hierarchy", - Category = CmdletHelpCategory.Provisioning)] - [CmdletExample( - Code = @"PS:> Get-PnPProvisioningSite -Sequence $mysequence", - Remarks = "Returns all sites from the specified sequence", - SortOrder = 1)] - [CmdletExample( - Code = @"PS:> Get-PnPProvisioningSite -Sequence $mysequence -Identity 8058ea99-af7b-4bb7-b12a-78f93398041e", - Remarks = "Returns the specified site from the specified sequence", - SortOrder = 2)] - public class GetProvisioningSite : PSCmdlet - { - [Parameter(Mandatory = true, HelpMessage = "The sequence to retrieve the site from", ParameterSetName = ParameterAttribute.AllParameterSets)] - public ProvisioningSequence Sequence; - - [Parameter(Mandatory = false, HelpMessage = "Optional Id of the site", ParameterSetName = ParameterAttribute.AllParameterSets, ValueFromPipeline = true)] - public ProvisioningSitePipeBind Identity; - protected override void ProcessRecord() - { - if (!MyInvocation.BoundParameters.ContainsKey("Identity")) - { - WriteObject(Sequence.SiteCollections, true); - } - else - { - WriteObject(Identity.GetSiteFromSequence(Sequence)); - } - } - } -} diff --git a/Commands/Provisioning/NewProvisioningCommunicationSite.cs b/Commands/Provisioning/NewProvisioningCommunicationSite.cs deleted file mode 100644 index 26d811288..000000000 --- a/Commands/Provisioning/NewProvisioningCommunicationSite.cs +++ /dev/null @@ -1,73 +0,0 @@ -#if !ONPREMISES -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using System.Linq; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet(VerbsCommon.New, "PnPProvisioningCommunicationSite", SupportsShouldProcess = true)] - [CmdletHelp("Creates a communication site object", - Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] - [CmdletExample( - Code = @"PS:> $site = New-PnPProvisioningCommunicationSite -Url ""/sites/mycommunicationsite"" -Title ""My Team Site""", - Remarks = "Creates a new communication site object with the specified variables", - SortOrder = 1)] - public class NewProvisioningCommunicationSite : PSCmdlet - { - [Parameter(Mandatory = true)] - public string Url; - - [Parameter(Mandatory = true)] - public string Title; - - [Parameter(Mandatory = false)] - public uint Language; - - [Parameter(Mandatory = false)] - public string Owner; - - [Parameter(Mandatory = false)] - public string Description; - - [Parameter(Mandatory = false)] - public string Classification; - - [Parameter(Mandatory = false)] - public string SiteDesignId; - - [Parameter(Mandatory = false)] - public SwitchParameter HubSite; - - [Parameter(Mandatory = false)] - public SwitchParameter AllowFileSharingForGuestUsers; - - [Parameter(Mandatory = false)] - public string[] TemplateIds; - - protected override void ProcessRecord() - { - var site = new CommunicationSiteCollection - { - Url = Url, - Language = (int)Language, - Owner = Owner, - AllowFileSharingForGuestUsers = AllowFileSharingForGuestUsers.IsPresent, - Classification = Classification, - Description = Description, - IsHubSite = HubSite.IsPresent, - Title = Title, - }; - if(MyInvocation.BoundParameters.ContainsKey("SiteDesignId")) - { - site.SiteDesign = SiteDesignId; - } - if (TemplateIds != null) - { - site.Templates.AddRange(TemplateIds.ToList()); - } - WriteObject(site); - } - } -} -#endif \ No newline at end of file diff --git a/Commands/Provisioning/NewProvisioningHierarchy.cs b/Commands/Provisioning/NewProvisioningHierarchy.cs deleted file mode 100644 index 5094b4e04..000000000 --- a/Commands/Provisioning/NewProvisioningHierarchy.cs +++ /dev/null @@ -1,40 +0,0 @@ -#if !ONPREMISES -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet(VerbsCommon.New, "PnPProvisioningHierarchy", SupportsShouldProcess = true)] - [CmdletHelp("Creates a new provisioning hierarchy object", - Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] - [CmdletExample( - Code = @"PS:> $hierarchy = New-PnPProvisioningHierarchy", - Remarks = "Creates a new instance of a provisioning hierarchy object.", - SortOrder = 1)] - public class NewProvisioningHierarchy : PSCmdlet - { - [Parameter(Mandatory = false)] - public string Author; - - [Parameter(Mandatory = false)] - public string Description; - - [Parameter(Mandatory = false)] - public string DisplayName; - - [Parameter(Mandatory = false)] - public string Generator; - - protected override void ProcessRecord() - { - var result = new ProvisioningHierarchy(); - result.Author = Author; - result.Description = Description; - result.DisplayName = DisplayName; - result.Generator = Generator; - WriteObject(result); - } - } -} -#endif \ No newline at end of file diff --git a/Commands/Provisioning/NewProvisioningSequence.cs b/Commands/Provisioning/NewProvisioningSequence.cs deleted file mode 100644 index 649aa803a..000000000 --- a/Commands/Provisioning/NewProvisioningSequence.cs +++ /dev/null @@ -1,38 +0,0 @@ -#if !ONPREMISES -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using System; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet(VerbsCommon.New, "PnPProvisioningSequence", SupportsShouldProcess = true)] - [CmdletHelp("Creates a new provisioning sequence object", - Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] - [CmdletExample( - Code = @"PS:> $sequence = New-PnPProvisioningSequence", - Remarks = "Creates a new instance of a provisioning sequence object.", - SortOrder = 1)] - [CmdletExample( - Code = @"PS:> $sequence = New-PnPProvisioningSequence -Id ""MySequence""", - Remarks = "Creates a new instance of a provisioning sequence object and sets the Id to the value specified.", - SortOrder = 2)] - public class NewProvisioningSequence : PSCmdlet - { - [Parameter(Mandatory = false, HelpMessage = "Optional Id of the sequence", ParameterSetName = ParameterAttribute.AllParameterSets)] - public string Id; - protected override void ProcessRecord() - { - var result = new ProvisioningSequence(); - if (this.MyInvocation.BoundParameters.ContainsKey("Id")) - { - result.ID = Id; - } else - { - result.ID = $"sequence-{Guid.NewGuid()}"; - } - WriteObject(result); - } - } -} -#endif \ No newline at end of file diff --git a/Commands/Provisioning/NewProvisioningTeamNoGroupSite.cs b/Commands/Provisioning/NewProvisioningTeamNoGroupSite.cs deleted file mode 100644 index 759873a4b..000000000 --- a/Commands/Provisioning/NewProvisioningTeamNoGroupSite.cs +++ /dev/null @@ -1,62 +0,0 @@ -#if !ONPREMISES -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using System.Linq; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet(VerbsCommon.New, "PnPProvisioningTeamNoGroupSite", SupportsShouldProcess = true)] - [CmdletHelp("Creates a team site without an Office 365 group object", - Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] - [CmdletExample( - Code = @"PS:> $site = New-PnPProvisioningTeamNoGroupSite -Alias ""MyTeamSite"" -Title ""My Team Site""", - Remarks = "Creates a new team site object with the specified variables", - SortOrder = 1)] - public class NewProvisioningTeamNoGroupSite : PSCmdlet - { - [Parameter(Mandatory = true)] - public string Url; - - [Parameter(Mandatory = true)] - public string Title; - - [Parameter(Mandatory = true)] - public uint TimeZoneId; - - [Parameter(Mandatory = false)] - public uint Language; - - [Parameter(Mandatory = false)] - public string Owner; - - [Parameter(Mandatory = false)] - public string Description; - - [Parameter(Mandatory = false)] - public SwitchParameter HubSite; - - [Parameter(Mandatory = false)] - public string[] TemplateIds; - - protected override void ProcessRecord() - { - var site = new TeamNoGroupSiteCollection - { - Url = Url, - Language = (int)Language, - Owner = Owner, - TimeZoneId = (int)TimeZoneId, - Description = Description, - IsHubSite = HubSite.IsPresent, - Title = Title - }; - if (TemplateIds != null) - { - site.Templates.AddRange(TemplateIds.ToList()); - } - WriteObject(site); - } - } -} -#endif \ No newline at end of file diff --git a/Commands/Provisioning/NewProvisioningTeamNoGroupSubSite.cs b/Commands/Provisioning/NewProvisioningTeamNoGroupSubSite.cs deleted file mode 100644 index 9918c1469..000000000 --- a/Commands/Provisioning/NewProvisioningTeamNoGroupSubSite.cs +++ /dev/null @@ -1,64 +0,0 @@ -#if !ONPREMISES -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using System.Linq; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet(VerbsCommon.New, "PnPProvisioningTeamNoGroupSubSite", SupportsShouldProcess = true)] - [CmdletHelp("Creates a team site subsite with no Office 365 group object", - Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] - [CmdletExample( - Code = @"PS:> $site = New-PnPProvisioningTeamNoGroupSubSite -Url ""MyTeamSubsite"" -Title ""My Team Site"" -TimeZoneId 4", - Remarks = "Creates a new team site subsite object with the specified variables", - SortOrder = 1)] - public class NewProvisioningTeamNoGroupSubSite : PSCmdlet - { - - [Parameter(Mandatory = true)] - public string Url; - - [Parameter(Mandatory = true)] - public string Title; - - [Parameter(Mandatory = true)] - public uint TimeZoneId; - - [Parameter(Mandatory = false)] - public uint Language; - - [Parameter(Mandatory = false)] - public string Description; - - [Parameter(Mandatory = false)] - public string[] TemplateIds; - - [Parameter(Mandatory = false)] - public SwitchParameter QuickLaunchDisabled; - - [Parameter(Mandatory = false)] - public SwitchParameter UseDifferentPermissionsFromParentSite; - - protected override void ProcessRecord() - { - SiteCollection c; - var site = new TeamNoGroupSubSite() - { - Url = Url, - Language = (int)Language, - QuickLaunchEnabled = !QuickLaunchDisabled.IsPresent, - UseSamePermissionsAsParentSite = !UseDifferentPermissionsFromParentSite.IsPresent, - TimeZoneId = (int)TimeZoneId, - Description = Description, - Title = Title - }; - if (TemplateIds != null) - { - site.Templates.AddRange(TemplateIds.ToList()); - } - WriteObject(site); - } - } -} -#endif \ No newline at end of file diff --git a/Commands/Provisioning/NewProvisioningTeamSite.cs b/Commands/Provisioning/NewProvisioningTeamSite.cs deleted file mode 100644 index 467e56ff6..000000000 --- a/Commands/Provisioning/NewProvisioningTeamSite.cs +++ /dev/null @@ -1,63 +0,0 @@ -#if !ONPREMISES -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using System.Linq; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet(VerbsCommon.New, "PnPProvisioningTeamSite", SupportsShouldProcess = true)] - [CmdletHelp("Creates a team site object", - Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] - [CmdletExample( - Code = @"PS:> $site = New-PnPProvisioningTeamSite -Alias ""MyTeamSite"" -Title ""My Team Site""", - Remarks = "Creates a new team site object with the specified variables", - SortOrder = 1)] - public class NewProvisioningTeamSite : PSCmdlet - { - - [Parameter(Mandatory = true)] - public string Alias; - - [Parameter(Mandatory = true)] - public string Title; - - [Parameter(Mandatory = false)] - public string Description = ""; - - [Parameter(Mandatory = false)] - public string DisplayName = ""; - - [Parameter(Mandatory = false)] - public string Classification; - - [Parameter(Mandatory = false)] - public SwitchParameter Public; - - [Parameter(Mandatory = false)] - public SwitchParameter HubSite; - - [Parameter(Mandatory = false)] - public string[] TemplateIds; - - protected override void ProcessRecord() - { - var site = new TeamSiteCollection - { - Alias = Alias, - Classification = Classification, - Description = Description, - DisplayName = DisplayName, - IsHubSite = HubSite.IsPresent, - IsPublic = Public.IsPresent, - Title = Title - }; - if (TemplateIds != null) - { - site.Templates.AddRange(TemplateIds.ToList()); - } - WriteObject(site); - } - } -} -#endif \ No newline at end of file diff --git a/Commands/Provisioning/ReadProvisioningHierarchy.cs b/Commands/Provisioning/ReadProvisioningHierarchy.cs deleted file mode 100644 index 7c9fb7bd1..000000000 --- a/Commands/Provisioning/ReadProvisioningHierarchy.cs +++ /dev/null @@ -1,79 +0,0 @@ -#if !ONPREMISES -using OfficeDevPnP.Core.Framework.Provisioning.Connectors; -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using OfficeDevPnP.Core.Framework.Provisioning.Providers; -using OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using SharePointPnP.PowerShell.Commands.Utilities; -using System; -using System.IO; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet(VerbsCommunications.Read, "PnPProvisioningHierarchy")] - [CmdletHelp("Loads/Reads a PnP provisioning hierarchy from the file system and returns an in-memory instance of this template.", - Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] - [CmdletExample( - Code = @"PS:> Read-PnPProvisioningHierarchy -Path hierarchy.pnp", - Remarks = "Reads a PnP provisioning hierarchy file from the file system and returns an in-memory instance", - SortOrder = 1)] - public class ReadProvisioningHierarchy : PSCmdlet - { - [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename to read from, optionally including full path.")] - public string Path; - - [Parameter(Mandatory = false, HelpMessage = "Allows you to specify ITemplateProviderExtension to execute while loading the template.")] - public ITemplateProviderExtension[] TemplateProviderExtensions; - - protected override void ProcessRecord() - { - if (!System.IO.Path.IsPathRooted(Path)) - { - Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path); - } - WriteObject(LoadProvisioningHierarchyFromFile(Path, TemplateProviderExtensions)); - } - - internal static ProvisioningHierarchy LoadProvisioningHierarchyFromFile(string templatePath, ITemplateProviderExtension[] templateProviderExtensions) - { - // Prepare the File Connector - string templateFileName = System.IO.Path.GetFileName(templatePath); - - // Prepare the template path - var fileInfo = new FileInfo(templatePath); - FileConnectorBase fileConnector = new FileSystemConnector(fileInfo.DirectoryName, ""); - - // Load the provisioning template file - var isOpenOfficeFile = false; - using (var stream = fileConnector.GetFileStream(templateFileName)) - { - isOpenOfficeFile = FileUtilities.IsOpenOfficeFile(stream); - } - - XMLTemplateProvider provider; - if (isOpenOfficeFile) - { - provider = new XMLOpenXMLTemplateProvider(new OpenXMLConnector(templateFileName, fileConnector)); - templateFileName = templateFileName.Substring(0, templateFileName.LastIndexOf(".", StringComparison.Ordinal)) + ".xml"; - - var hierarchy = (provider as XMLOpenXMLTemplateProvider).GetHierarchy(); - if (hierarchy != null) - { - hierarchy.Connector = provider.Connector; - return hierarchy; - } - } - else - { - provider = new XMLFileSystemTemplateProvider(fileConnector.Parameters[FileConnectorBase.CONNECTIONSTRING] + "", ""); - } - - ProvisioningHierarchy provisioningHierarchy = provider.GetHierarchy(templateFileName); - provisioningHierarchy.Connector = provider.Connector; - // Return the result - return provisioningHierarchy; - } - } -} -#endif \ No newline at end of file diff --git a/Commands/Provisioning/SaveProvisioningHierarchy.cs b/Commands/Provisioning/SaveProvisioningHierarchy.cs deleted file mode 100644 index 2672f45b3..000000000 --- a/Commands/Provisioning/SaveProvisioningHierarchy.cs +++ /dev/null @@ -1,172 +0,0 @@ -#if !ONPREMISES -using OfficeDevPnP.Core.Framework.Provisioning.Connectors; -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using OfficeDevPnP.Core.Framework.Provisioning.Providers; -using OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using System; -using System.IO; -using System.Linq; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet(VerbsData.Save, "PnPProvisioningHierarchy")] - [CmdletHelp("Saves a PnP provisioning hierarchy to the file system", - Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] - [CmdletExample( - Code = @"PS:> Save-PnPProvisioningHierarchy -Hierarchy $hierarchy -Out .\hierarchy.pnp", - Remarks = "Saves a PnP provisioning hiearchy to the file system", - SortOrder = 1)] - public class SaveProvisioningHierarchy : PSCmdlet - { - [Parameter(Mandatory = true, HelpMessage = "Allows you to provide an in-memory instance of the ProvisioningHierarchy type of the PnP Core Component. When using this parameter, the -Out parameter refers to the path for saving the template and storing any supporting file for the template.")] - public ProvisioningHierarchy Hierarchy; - - [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename to write to, optionally including full path.")] - public string Out; - - [Parameter(Mandatory = false, HelpMessage = "Specifying the Force parameter will skip the confirmation question.")] - public SwitchParameter Force; - - //[Parameter(Mandatory = false, HelpMessage = "Allows you to specify the ITemplateProviderExtension to execute while saving a template.")] - //public ITemplateProviderExtension[] TemplateProviderExtensions; - - protected override void ProcessRecord() - { - // Determine the output file name and path - string outFileName = Path.GetFileName(Out); - - if (!Path.IsPathRooted(Out)) - { - Out = Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Out); - } - - bool proceed = false; - - if (System.IO.File.Exists(Out)) - { - if (Force || ShouldContinue(string.Format(Properties.Resources.File0ExistsOverwrite, Out), - Properties.Resources.Confirm)) - { - System.IO.File.Delete(Out); - proceed = true; - } - } - else - { - proceed = true; - } - - string outPath = new FileInfo(Out).DirectoryName; - - // Determine if it is an .XML or a .PNP file - var extension = ""; - if (proceed && outFileName != null) - { - if (outFileName.IndexOf(".", StringComparison.Ordinal) > -1) - { - extension = outFileName.Substring(outFileName.LastIndexOf(".", StringComparison.Ordinal)).ToLower(); - } - else - { - extension = ".pnp"; - } - } - - var fileSystemConnector = new FileSystemConnector(outPath, ""); - - ITemplateFormatter formatter = XMLPnPSchemaFormatter.LatestFormatter; - - if (extension == ".pnp") - { - // var connector = new OpenXMLConnector(Out, fileSystemConnector); - var templateFileName = outFileName.Substring(0, outFileName.LastIndexOf(".", StringComparison.Ordinal)) + ".xml"; - - XMLTemplateProvider provider = new XMLOpenXMLTemplateProvider( - Out, fileSystemConnector, templateFileName: templateFileName); - WriteObject("Processing template"); - provider.SaveAs(Hierarchy, templateFileName); - ProcessFiles(Out, fileSystemConnector, provider.Connector); - - //provider.SaveAs(Hierarchy, templateFileName); - //connector.Commit(); - } - else - { - XMLTemplateProvider provider = new XMLFileSystemTemplateProvider(outPath, ""); - provider.SaveAs(Hierarchy, Out); - } - } - - private void ProcessFiles(string templateFileName, FileConnectorBase fileSystemConnector, FileConnectorBase connector) - { - var hierarchy = ReadProvisioningHierarchy.LoadProvisioningHierarchyFromFile(templateFileName, null); - if (Hierarchy.Tenant?.AppCatalog != null) - { - foreach (var app in Hierarchy.Tenant.AppCatalog.Packages) - { - WriteObject($"Processing {app.Src}"); - AddFile(app.Src, hierarchy, fileSystemConnector, connector); - } - } - if (Hierarchy.Tenant?.SiteScripts != null) - { - foreach (var siteScript in Hierarchy.Tenant.SiteScripts) - { - WriteObject($"Processing {siteScript.JsonFilePath}"); - AddFile(siteScript.JsonFilePath, hierarchy, fileSystemConnector, connector); - } - } - if (Hierarchy.Localizations != null && Hierarchy.Localizations.Any()) - { - foreach (var location in Hierarchy.Localizations) - { - WriteObject($"Processing {location.ResourceFile}"); - AddFile(location.ResourceFile, hierarchy, fileSystemConnector, connector); - } - } - foreach (var template in Hierarchy.Templates) - { - if(template.WebSettings != null && template.WebSettings.SiteLogo != null) - { - // is it a file? - var isFile = false; - using (var fileStream = fileSystemConnector.GetFileStream(template.WebSettings.SiteLogo)) - { - isFile = fileStream != null; - } - if (isFile) - { - WriteObject($"Processing {template.WebSettings.SiteLogo}"); - AddFile(template.WebSettings.SiteLogo, hierarchy, fileSystemConnector, connector); - } - } - if (template.Files.Any()) - { - foreach (var file in template.Files) - { - AddFile(file.Src, hierarchy, fileSystemConnector, connector); - } - } - } - - } - - private void AddFile(string sourceName, ProvisioningHierarchy hierarchy, FileConnectorBase fileSystemConnector, FileConnectorBase connector) - { - using (var fs = fileSystemConnector.GetFileStream(sourceName)) - { - var fileName = sourceName.IndexOf("\\") > 0 ? sourceName.Substring(sourceName.LastIndexOf("\\") + 1) : sourceName; - var folderName = sourceName.IndexOf("\\") > 0 ? sourceName.Substring(0, sourceName.LastIndexOf("\\")) : ""; - hierarchy.Connector.SaveFileStream(fileName, folderName, fs); - - if (hierarchy.Connector is ICommitableFileConnector) - { - ((ICommitableFileConnector)hierarchy.Connector).Commit(); - } - } - } - } -} -#endif \ No newline at end of file diff --git a/Commands/Provisioning/AddDataRowsToProvisioningTemplate.cs b/Commands/Provisioning/Site/AddDataRowsToSiteTemplate.cs similarity index 95% rename from Commands/Provisioning/AddDataRowsToProvisioningTemplate.cs rename to Commands/Provisioning/Site/AddDataRowsToSiteTemplate.cs index c377d47a2..edc752aa5 100644 --- a/Commands/Provisioning/AddDataRowsToProvisioningTemplate.cs +++ b/Commands/Provisioning/Site/AddDataRowsToSiteTemplate.cs @@ -15,22 +15,23 @@ using System.Text.RegularExpressions; using SPSite = Microsoft.SharePoint.Client.Site; -namespace SharePointPnP.PowerShell.Commands.Provisioning +namespace SharePointPnP.PowerShell.Commands.Provisioning.Site { - [Cmdlet(VerbsCommon.Add, "PnPDataRowsToProvisioningTemplate")] + [Cmdlet(VerbsCommon.Add, "PnPDataRowsToSiteTemplate")] + [Alias("Add-PnPDataRowsToProvisioningTemplate")] [CmdletHelp("Adds datarows to a list inside a PnP Provisioning Template", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Add-PnPDataRowsToProvisioningTemplate -Path template.pnp -List 'PnPTestList' -Query '' -Fields 'Title','Choice'", + Code = @"PS:> Add-PnPDataRowsToSiteTemplate -Path template.pnp -List 'PnPTestList' -Query '' -Fields 'Title','Choice'", Remarks = "Adds datarows to a list in an in-memory PnP Provisioning Template", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Add-PnPDataRowsToProvisioningTemplate -Path template.pnp -List 'PnPTestList' -Query '' -Fields 'Title','Choice' -IncludeSecurity", + Code = @"PS:> Add-PnPDataRowsToSiteTemplate -Path template.pnp -List 'PnPTestList' -Query '' -Fields 'Title','Choice' -IncludeSecurity", Remarks = "Adds datarows to a list in an in-memory PnP Provisioning Template", SortOrder = 2)] - public class AddDataRowsToProvisioningTemplate : PnPWebCmdlet + public class AddDataRowsToSiteTemplate : PnPWebCmdlet { - [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename of the .PNP Open XML provisioning template to read from, optionally including full path.")] + [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename of the .PNP Open XML site template to read from, optionally including full path.")] public string Path; [Parameter(Mandatory = true, HelpMessage = "The list to query")] @@ -64,7 +65,7 @@ protected override void ExecuteCmdlet() Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path); } - var template = ReadProvisioningTemplate + var template = ReadSiteTemplate .LoadProvisioningTemplateFromFile(Path, TemplateProviderExtensions); diff --git a/Commands/Provisioning/AddFileToProvisioningTemplate.cs b/Commands/Provisioning/Site/AddFileToSiteTemplate.cs similarity index 79% rename from Commands/Provisioning/AddFileToProvisioningTemplate.cs rename to Commands/Provisioning/Site/AddFileToSiteTemplate.cs index dcc1fd08e..6ed824687 100644 --- a/Commands/Provisioning/AddFileToProvisioningTemplate.cs +++ b/Commands/Provisioning/Site/AddFileToSiteTemplate.cs @@ -11,31 +11,32 @@ using System.Text; using System.Threading.Tasks; -namespace SharePointPnP.PowerShell.Commands.Provisioning +namespace SharePointPnP.PowerShell.Commands.Provisioning.Site { - [Cmdlet(VerbsCommon.Add, "PnPFileToProvisioningTemplate")] - [CmdletHelp("Adds a file to a PnP Provisioning Template", + [Cmdlet(VerbsCommon.Add, "PnPFileToSiteTemplate")] + [Alias("Add-PnPFileToProvisioningTemplate")] + [CmdletHelp("Adds a file to a PnP Site Template", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Add-PnPFileToProvisioningTemplate -Path template.pnp -Source $sourceFilePath -Folder $targetFolder", - Remarks = "Adds a file to a PnP Provisioning Template", + Code = @"PS:> Add-PnPFileToSiteTemplate -Path template.pnp -Source $sourceFilePath -Folder $targetFolder", + Remarks = "Adds a file to a PnP Site Template", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Add-PnPFileToProvisioningTemplate -Path template.xml -Source $sourceFilePath -Folder $targetFolder", - Remarks = "Adds a file reference to a PnP Provisioning XML Template", + Code = @"PS:> Add-PnPFileToSiteTemplate -Path template.xml -Source $sourceFilePath -Folder $targetFolder", + Remarks = "Adds a file reference to a PnP Site XML Template", SortOrder = 2)] [CmdletExample( - Code = @"PS:> Add-PnPFileToProvisioningTemplate -Path template.pnp -Source ""./myfile.png"" -Folder ""folderinsite"" -FileLevel Published -FileOverwrite:$false", - Remarks = "Adds a file to a PnP Provisioning Template, specifies the level as Published and defines to not overwrite the file if it exists in the site.", + Code = @"PS:> Add-PnPFileToSiteTemplate -Path template.pnp -Source ""./myfile.png"" -Folder ""folderinsite"" -FileLevel Published -FileOverwrite:$false", + Remarks = "Adds a file to a PnP Site Template, specifies the level as Published and defines to not overwrite the file if it exists in the site.", SortOrder = 3)] [CmdletExample( - Code = @"PS:> Add-PnPFileToProvisioningTemplate -Path template.pnp -Source $sourceFilePath -Folder $targetFolder -Container $container", - Remarks = "Adds a file to a PnP Provisioning Template with a custom container for the file", + Code = @"PS:> Add-PnPFileToSiteTemplate -Path template.pnp -Source $sourceFilePath -Folder $targetFolder -Container $container", + Remarks = "Adds a file to a PnP Site Template with a custom container for the file", SortOrder = 4)] public class AddFileToProvisioningTemplate : PSCmdlet { - [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename of the .PNP Open XML provisioning template to read from, optionally including full path.")] + [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename of the .PNP Open XML site template to read from, optionally including full path.")] public string Path; [Parameter(Mandatory = true, Position = 1, HelpMessage = "The file to add to the in-memory template, optionally including full path.")] @@ -67,7 +68,7 @@ protected override void ProcessRecord() Source = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Source); } // Load the template - var template = ReadProvisioningTemplate + var template = ReadSiteTemplate .LoadProvisioningTemplateFromFile(Path, TemplateProviderExtensions); diff --git a/Commands/Provisioning/AddListFoldersToProvisioningTemplate.cs b/Commands/Provisioning/Site/AddListFoldersToSiteTemplate.cs similarity index 89% rename from Commands/Provisioning/AddListFoldersToProvisioningTemplate.cs rename to Commands/Provisioning/Site/AddListFoldersToSiteTemplate.cs index 8b1a81a79..1e84d1d35 100644 --- a/Commands/Provisioning/AddListFoldersToProvisioningTemplate.cs +++ b/Commands/Provisioning/Site/AddListFoldersToSiteTemplate.cs @@ -14,29 +14,30 @@ using System.Threading.Tasks; using Microsoft.SharePoint.Client; -namespace SharePointPnP.PowerShell.Commands.Provisioning +namespace SharePointPnP.PowerShell.Commands.Provisioning.Site { - [Cmdlet(VerbsCommon.Add, "PnPListFoldersToProvisioningTemplate")] + [Cmdlet(VerbsCommon.Add, "PnPListFoldersToSiteTemplate")] + [Alias("Add-PnPListFoldersToProvisioningTemplate")] [CmdletHelp("Adds folders to a list in a PnP Provisioning Template", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Add-PnPListFoldersToProvisioningTemplate -Path template.pnp -List 'PnPTestList'", - Remarks = "Adds top level folders from a list to an existing template and returns an in-memory PnP Provisioning Template", + Code = @"PS:> Add-PnPListFoldersToSiteTemplate -Path template.pnp -List 'PnPTestList'", + Remarks = "Adds top level folders from a list to an existing template and returns an in-memory PnP Site Template", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Add-PnPListFoldersToProvisioningTemplate -Path template.pnp -List 'PnPTestList' -Recursive", - Remarks = "Adds all folders from a list to an existing template and returns an in-memory PnP Provisioning Template", + Code = @"PS:> Add-PnPListFoldersToSiteTemplate -Path template.pnp -List 'PnPTestList' -Recursive", + Remarks = "Adds all folders from a list to an existing template and returns an in-memory PnP Site Template", SortOrder = 2)] [CmdletExample( - Code = @"PS:> Add-PnPListFoldersToProvisioningTemplate -Path template.pnp -List 'PnPTestList' -Recursive -IncludeSecurity", - Remarks = "Adds all folders from a list with unique permissions to an in-memory PnP Provisioning Template", + Code = @"PS:> Add-PnPListFoldersToSiteTemplate -Path template.pnp -List 'PnPTestList' -Recursive -IncludeSecurity", + Remarks = "Adds all folders from a list with unique permissions to an in-memory PnP Site Template", SortOrder = 3)] - public class AddListFoldersToProvisioningTemplate : PnPWebCmdlet + public class AddListFoldersToSiteTemplate : PnPWebCmdlet { - [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename of the .PNP Open XML provisioning template to read from, optionally including full path.")] + [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename of the .PNP Open XML site template to read from, optionally including full path.")] public string Path; [Parameter(Mandatory = true, HelpMessage = "The list to query", Position = 2)] @@ -60,7 +61,7 @@ protected override void ExecuteCmdlet() Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path); } // Load the template - var template = ReadProvisioningTemplate + var template = ReadSiteTemplate .LoadProvisioningTemplateFromFile(Path, TemplateProviderExtensions); diff --git a/Commands/Provisioning/ApplyProvisioningTemplate.cs b/Commands/Provisioning/Site/ApplySiteTemplate.cs similarity index 88% rename from Commands/Provisioning/ApplyProvisioningTemplate.cs rename to Commands/Provisioning/Site/ApplySiteTemplate.cs index a09a567d7..df810b9cc 100644 --- a/Commands/Provisioning/ApplyProvisioningTemplate.cs +++ b/Commands/Provisioning/Site/ApplySiteTemplate.cs @@ -14,50 +14,51 @@ using System.Collections.Generic; using SharePointPnP.PowerShell.Commands.Utilities; -namespace SharePointPnP.PowerShell.Commands.Provisioning +namespace SharePointPnP.PowerShell.Commands.Provisioning.Site { - [Cmdlet("Apply", "PnPProvisioningTemplate")] - [CmdletHelp("Applies a provisioning template to a web", + [Cmdlet("Apply", "PnPSiteTemplate")] + [Alias("Apply-PnPProvisioningTemplate")] + [CmdletHelp("Applies a site template to a web", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Apply-PnPProvisioningTemplate -Path template.xml", - Remarks = @"Applies a provisioning template in XML format to the current web.", + Code = @"PS:> Apply-PnPSiteTemplate -Path template.xml", + Remarks = @"Applies a site template in XML format to the current web.", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Apply-PnPProvisioningTemplate -Path template.xml -ResourceFolder c:\provisioning\resources", - Remarks = @"Applies a provisioning template in XML format to the current web. Any resources like files that are referenced in the template will be retrieved from the folder as specified with the ResourceFolder parameter.", + Code = @"PS:> Apply-PnPSiteTemplate -Path template.xml -ResourceFolder c:\provisioning\resources", + Remarks = @"Applies a site template in XML format to the current web. Any resources like files that are referenced in the template will be retrieved from the folder as specified with the ResourceFolder parameter.", SortOrder = 2)] [CmdletExample( - Code = @"PS:> Apply-PnPProvisioningTemplate -Path template.xml -Parameters @{""ListTitle""=""Projects"";""parameter2""=""a second value""}", - Remarks = @"Applies a provisioning template in XML format to the current web. It will populate the parameter in the template the values as specified and in the template you can refer to those values with the {parameter:} token. + Code = @"PS:> Apply-PnPSiteTemplate -Path template.xml -Parameters @{""ListTitle""=""Projects"";""parameter2""=""a second value""}", + Remarks = @"Applies a site template in XML format to the current web. It will populate the parameter in the template the values as specified and in the template you can refer to those values with the {parameter:} token. For instance with the example above, specifying {parameter:ListTitle} in your template will translate to 'Projects' when applying the template. These tokens can be used in most string values in a template.", SortOrder = 3)] [CmdletExample( - Code = @"PS:> Apply-PnPProvisioningTemplate -Path template.xml -Handlers Lists, SiteSecurity", - Remarks = @"Applies a provisioning template in XML format to the current web. It will only apply the lists and site security part of the template.", + Code = @"PS:> Apply-PnPSiteTemplate -Path template.xml -Handlers Lists, SiteSecurity", + Remarks = @"Applies a site template in XML format to the current web. It will only apply the lists and site security part of the template.", SortOrder = 4)] [CmdletExample( - Code = @"PS:> Apply-PnPProvisioningTemplate -Path template.pnp", - Remarks = @"Applies a provisioning template from a pnp package to the current web.", + Code = @"PS:> Apply-PnPSiteTemplate -Path template.pnp", + Remarks = @"Applies a site template from a pnp package to the current web.", SortOrder = 5)] [CmdletExample( - Code = @"PS:> Apply-PnPProvisioningTemplate -Path https://tenant.sharepoint.com/sites/templatestorage/Documents/template.pnp", - Remarks = @"Applies a provisioning template from a pnp package stored in a library to the current web.", + Code = @"PS:> Apply-PnPSiteTemplate -Path https://tenant.sharepoint.com/sites/templatestorage/Documents/template.pnp", + Remarks = @"Applies a site template from a pnp package stored in a library to the current web.", SortOrder = 6)] [CmdletExample( Code = @" PS:> $handler1 = New-PnPExtensibilityHandlerObject -Assembly Contoso.Core.Handlers -Type Contoso.Core.Handlers.MyExtensibilityHandler1 PS:> $handler2 = New-PnPExtensibilityHandlerObject -Assembly Contoso.Core.Handlers -Type Contoso.Core.Handlers.MyExtensibilityHandler1 -PS:> Apply-PnPProvisioningTemplate -Path NewTemplate.xml -ExtensibilityHandlers $handler1,$handler2", +PS:> Apply-PnPSiteTemplate -Path NewTemplate.xml -ExtensibilityHandlers $handler1,$handler2", Remarks = @"This will create two new ExtensibilityHandler objects that are run while provisioning the template", SortOrder = 7)] [CmdletExample( - Code = @"PS:> Apply-PnPProvisioningTemplate -Path .\ -InputInstance $template", - Remarks = @"Applies a provisioning template from an in-memory instance of a ProvisioningTemplate type of the PnP Core Component, reading the supporting files, if any, from the current (.\) path. The syntax can be used together with any other supported parameters.", + Code = @"PS:> Apply-PnPSiteTemplate -Path .\ -InputInstance $template", + Remarks = @"Applies a site template from an in-memory instance of a ProvisioningTemplate type of the PnP Core Component, reading the supporting files, if any, from the current (.\) path. The syntax can be used together with any other supported parameters.", SortOrder = 8)] - public class ApplyProvisioningTemplate : PnPWebCmdlet + public class ApplySiteTemplate : PnPWebCmdlet { private ProgressRecord progressRecord = new ProgressRecord(0, "Activity", "Status"); private ProgressRecord subProgressRecord = new ProgressRecord(1, "Activity", "Status"); diff --git a/Commands/Provisioning/ConvertFolderToProvisioningTemplate.cs b/Commands/Provisioning/Site/ConvertFolderToProvisioningTemplate.cs similarity index 93% rename from Commands/Provisioning/ConvertFolderToProvisioningTemplate.cs rename to Commands/Provisioning/Site/ConvertFolderToProvisioningTemplate.cs index ef71bd320..389f585e0 100644 --- a/Commands/Provisioning/ConvertFolderToProvisioningTemplate.cs +++ b/Commands/Provisioning/Site/ConvertFolderToProvisioningTemplate.cs @@ -9,18 +9,19 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning { - [Cmdlet(VerbsData.Convert, "PnPFolderToProvisioningTemplate")] + [Cmdlet(VerbsData.Convert, "PnPFolderToSiteTemplate")] + [Alias("Convert-PnPFolderToProvisioningTemplate")] [CmdletHelp("Creates a pnp package file of an existing template xml, and includes all files in the current folder", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Convert-PnPFolderToProvisioningTemplate -Out template.pnp", + Code = @"PS:> Convert-PnPFolderToSiteTemplate -Out template.pnp", Remarks = "Creates a pnp package file of an existing template xml, and includes all files in the current folder", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Convert-PnPFolderToProvisioningTemplate -Out template.pnp -Folder c:\temp", + Code = @"PS:> Convert-PnPFolderToSiteTemplate -Out template.pnp -Folder c:\temp", Remarks = "Creates a pnp package file of an existing template xml, and includes all files in the c:\\temp folder", SortOrder = 2)] - public class ConvertProvisioningTemplateFromFolder : PSCmdlet + public class ConvertFolderToSiteTemplate : PSCmdlet { [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename to write to, optionally including full path.")] public string Out; diff --git a/Commands/Provisioning/ConvertProvisioningTemplate.cs b/Commands/Provisioning/Site/ConvertSiteTemplate.cs similarity index 84% rename from Commands/Provisioning/ConvertProvisioningTemplate.cs rename to Commands/Provisioning/Site/ConvertSiteTemplate.cs index aa6ea8e4b..387555bf0 100644 --- a/Commands/Provisioning/ConvertProvisioningTemplate.cs +++ b/Commands/Provisioning/Site/ConvertSiteTemplate.cs @@ -7,27 +7,28 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning { - [Cmdlet(VerbsData.Convert, "PnPProvisioningTemplate")] - [CmdletHelp("Converts a provisioning template to an other schema version", + [Cmdlet(VerbsData.Convert, "PnPSiteTemplate")] + [Alias("Convert-PnPProvisioningTemplate")] + [CmdletHelp("Converts a site template to an other schema version", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Convert-PnPProvisioningTemplate -Path template.xml", - Remarks = @"Converts a provisioning template to the latest schema and outputs the result to current console.", + Code = @"PS:> Convert-PnPSiteTemplate -Path template.xml", + Remarks = @"Converts a site template to the latest schema and outputs the result to current console.", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Convert-PnPProvisioningTemplate -Path template.xml -Out newtemplate.xml", - Remarks = @"Converts a provisioning template to the latest schema and outputs the result the newtemplate.xml file.", + Code = @"PS:> Convert-PnPSiteTemplate -Path template.xml -Out newtemplate.xml", + Remarks = @"Converts a site template to the latest schema and outputs the result the newtemplate.xml file.", SortOrder = 2)] [CmdletExample( - Code = @"PS:> Convert-PnPProvisioningTemplate -Path template.xml -Out newtemplate.xml -ToSchema V201512", - Remarks = @"Converts a provisioning template to the latest schema using the 201512 schema and outputs the result the newtemplate.xml file.", + Code = @"PS:> Convert-PnPSiteTemplate -Path template.xml -Out newtemplate.xml -ToSchema V201512", + Remarks = @"Converts a site template to the latest schema using the 201512 schema and outputs the result the newtemplate.xml file.", SortOrder = 3)] [CmdletRelatedLink( Text ="Encoding", Url = "https://msdn.microsoft.com/en-us/library/system.text.encoding_properties.aspx")] - public class ConvertProvisioningTemplate : PSCmdlet + public class ConvertSiteTemplate : PSCmdlet { - [Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true, HelpMessage = "Path to the xml file containing the provisioning template")] + [Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true, HelpMessage = "Path to the xml file containing the site template")] public string Path; [Parameter(Mandatory = false, HelpMessage = "Filename to write to, optionally including full path")] @@ -122,6 +123,11 @@ protected override void BeginProcessing() formatter = XMLPnPSchemaFormatter.GetSpecificFormatter(XMLConstants.PROVISIONING_SCHEMA_NAMESPACE_2018_05); break; } + case XMLPnPSchemaVersion.V201807: + { + formatter = XMLPnPSchemaFormatter.GetSpecificFormatter(XMLConstants.PROVISIONING_SCHEMA_NAMESPACE_2018_07); + break; + } } if (!string.IsNullOrEmpty(Out)) diff --git a/Commands/Provisioning/GetProvisioningTemplateFromGallery.cs b/Commands/Provisioning/Site/GetProvisioningTemplateFromGallery.cs similarity index 97% rename from Commands/Provisioning/GetProvisioningTemplateFromGallery.cs rename to Commands/Provisioning/Site/GetProvisioningTemplateFromGallery.cs index 2d47fc5c7..7a08516f0 100644 --- a/Commands/Provisioning/GetProvisioningTemplateFromGallery.cs +++ b/Commands/Provisioning/Site/GetProvisioningTemplateFromGallery.cs @@ -14,8 +14,9 @@ using SharePointPnP.PowerShell.Commands.Utilities; using Resources = SharePointPnP.PowerShell.Commands.Properties.Resources; -namespace SharePointPnP.PowerShell.Commands.Provisioning +namespace SharePointPnP.PowerShell.Commands.Provisioning.Site { + [Obsolete("The PnP Template Gallery has been shut down.")] [Cmdlet(VerbsCommon.Get, "PnPProvisioningTemplateFromGallery", DefaultParameterSetName = "Search")] [CmdletHelp("Retrieves or searches provisioning templates from the PnP Template Gallery", Category = CmdletHelpCategory.Lists)] [CmdletExample( diff --git a/Commands/Provisioning/GetProvisioningTemplate.cs b/Commands/Provisioning/Site/GetSiteTemplate.cs similarity index 94% rename from Commands/Provisioning/GetProvisioningTemplate.cs rename to Commands/Provisioning/Site/GetSiteTemplate.cs index 0995ac510..4eeb5f34e 100644 --- a/Commands/Provisioning/GetProvisioningTemplate.cs +++ b/Commands/Provisioning/Site/GetSiteTemplate.cs @@ -13,74 +13,75 @@ using Resources = SharePointPnP.PowerShell.Commands.Properties.Resources; using System.Collections; -namespace SharePointPnP.PowerShell.Commands.Provisioning +namespace SharePointPnP.PowerShell.Commands.Provisioning.Site { - [Cmdlet(VerbsCommon.Get, "PnPProvisioningTemplate", SupportsShouldProcess = true)] - [CmdletHelp("Generates a provisioning template from a web", + [Cmdlet(VerbsCommon.Get, "PnPSiteTemplate", SupportsShouldProcess = true)] + [Alias("Get-PnPProvisioningTemplate")] + [CmdletHelp("Generates a provisioning site template from a web", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp", + Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp", Remarks = "Extracts a provisioning template in Office Open XML from the current web.", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Get-PnPProvisioningTemplate -Out template.xml", + Code = @"PS:> Get-PnPSiteTemplate -Out template.xml", Remarks = "Extracts a provisioning template in XML format from the current web.", SortOrder = 2)] [CmdletExample( - Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -Schema V201503", + Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -Schema V201503", Remarks = "Extracts a provisioning template in Office Open XML from the current web and saves it in the V201503 version of the schema.", SortOrder = 3)] [CmdletExample( - Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -IncludeAllTermGroups", + Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -IncludeAllTermGroups", Remarks = "Extracts a provisioning template in Office Open XML from the current web and includes all term groups, term sets and terms from the Managed Metadata Service Taxonomy.", SortOrder = 4)] [CmdletExample( - Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -IncludeSiteCollectionTermGroup", + Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -IncludeSiteCollectionTermGroup", Remarks = "Extracts a provisioning template in Office Open XML from the current web and includes the term group currently (if set) assigned to the site collection.", SortOrder = 5)] [CmdletExample( - Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -PersistComposedLookFiles", + Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -PersistComposedLookFiles", Remarks = "Extracts a provisioning template in Office Open XML from the current web and saves the files that make up the composed look to the same folder as where the template is saved.", SortOrder = 6)] [CmdletExample( - Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -Handlers Lists, SiteSecurity", + Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -Handlers Lists, SiteSecurity", Remarks = "Extracts a provisioning template in Office Open XML from the current web, but only processes lists and site security when generating the template.", SortOrder = 7)] [CmdletExample( Code = @" PS:> $handler1 = New-PnPExtensibilityHandlerObject -Assembly Contoso.Core.Handlers -Type Contoso.Core.Handlers.MyExtensibilityHandler1 PS:> $handler2 = New-PnPExtensibilityHandlerObject -Assembly Contoso.Core.Handlers -Type Contoso.Core.Handlers.MyExtensibilityHandler1 -PS:> Get-PnPProvisioningTemplate -Out NewTemplate.xml -ExtensibilityHandlers $handler1,$handler2", +PS:> Get-PnPSiteTemplate -Out NewTemplate.xml -ExtensibilityHandlers $handler1,$handler2", Remarks = @"This will create two new ExtensibilityHandler objects that are run during extraction of the template", SortOrder = 8)] #if !SP2013 [CmdletExample( - Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -PersistMultiLanguageResources", + Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -PersistMultiLanguageResources", Introduction = "Only supported on SP2016 and SP Online", Remarks = "Extracts a provisioning template in Office Open XML from the current web, and for supported artifacts it will create a resource file for each supported language (based upon the language settings of the current web). The generated resource files will be named after the value specified in the Out parameter. For instance if the Out parameter is specified as -Out 'template.xml' the generated resource file will be called 'template.en-US.resx'.", SortOrder = 9)] [CmdletExample( - Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -PersistMultiLanguageResources -ResourceFilePrefix MyResources", + Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -PersistMultiLanguageResources -ResourceFilePrefix MyResources", Introduction = "Only supported on SP2016 and SP Online", Remarks = "Extracts a provisioning template in Office Open XML from the current web, and for supported artifacts it will create a resource file for each supported language (based upon the language settings of the current web). The generated resource files will be named 'MyResources.en-US.resx' etc.", SortOrder = 10)] #endif [CmdletExample( - Code = @"PS:> $template = Get-PnPProvisioningTemplate -OutputInstance", + Code = @"PS:> $template = Get-PnPSiteTemplate -OutputInstance", Remarks = "Extracts an instance of a provisioning template object from the current web. This syntax cannot be used together with the -Out parameter, but it can be used together with any other supported parameters.", SortOrder = 11)] [CmdletExample( - Code = "PS:> Get-PnPProvisioningTemplate -Out template.pnp -ContentTypeGroups \"Group A\",\"Group B\"", + Code = "PS:> Get-PnPSiteTemplate -Out template.pnp -ContentTypeGroups \"Group A\",\"Group B\"", Remarks = @"Extracts a provisioning template in Office Open XML from the current web, but only processes content types from the to given content type groups.", SortOrder = 12)] [CmdletExample( - Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -ExcludeContentTypesFromSyndication", + Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -ExcludeContentTypesFromSyndication", Remarks = "Extracts a provisioning template in Office Open XML from the current web, excluding content types provisioned through content type syndication (content type hub), in order to prevent provisioning errors if the target also provision the content type using syndication.", SortOrder = 13)] [CmdletRelatedLink( Text = "Encoding", Url = "https://msdn.microsoft.com/en-us/library/system.text.encoding_properties.aspx")] - public class GetProvisioningTemplate : PnPWebCmdlet + public class GetSiteTemplate : PnPWebCmdlet { private ProgressRecord mainProgressRecord = new ProgressRecord(0, "Processing", "Status"); private ProgressRecord subProgressRecord = new ProgressRecord(1, "Activity", "Status"); diff --git a/Commands/Provisioning/NewProvisioningTemplateFromFolder.cs b/Commands/Provisioning/Site/NewProvisioningTemplateFromFolder.cs similarity index 100% rename from Commands/Provisioning/NewProvisioningTemplateFromFolder.cs rename to Commands/Provisioning/Site/NewProvisioningTemplateFromFolder.cs diff --git a/Commands/Provisioning/NewProvisioningTemplate.cs b/Commands/Provisioning/Site/NewSiteTemplate.cs similarity index 57% rename from Commands/Provisioning/NewProvisioningTemplate.cs rename to Commands/Provisioning/Site/NewSiteTemplate.cs index a9d0ae020..5ab8d66f7 100644 --- a/Commands/Provisioning/NewProvisioningTemplate.cs +++ b/Commands/Provisioning/Site/NewSiteTemplate.cs @@ -4,14 +4,15 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning { - [Cmdlet(VerbsCommon.New, "PnPProvisioningTemplate", SupportsShouldProcess = true)] - [CmdletHelp("Creates a new provisioning template object", + [Cmdlet(VerbsCommon.New, "PnPSiteTemplate", SupportsShouldProcess = true)] + [Alias("New-PnPProvisioningTemplate")] + [CmdletHelp("Creates a new site template object", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> $template = New-PnPProvisioningTemplate", - Remarks = "Creates a new instance of a provisioning template object.", + Code = @"PS:> $template = New-PnPSiteTemplate", + Remarks = "Creates a new instance of a site template object.", SortOrder = 1)] - public class NewProvisioningTemplate : PSCmdlet + public class NewSiteTemplate : PSCmdlet { protected override void ProcessRecord() { diff --git a/Commands/Provisioning/ReadProvisioningTemplate.cs b/Commands/Provisioning/Site/ReadSiteTemplate.cs similarity index 90% rename from Commands/Provisioning/ReadProvisioningTemplate.cs rename to Commands/Provisioning/Site/ReadSiteTemplate.cs index 8c759e2aa..7b9732faa 100644 --- a/Commands/Provisioning/ReadProvisioningTemplate.cs +++ b/Commands/Provisioning/Site/ReadSiteTemplate.cs @@ -11,19 +11,19 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning { - [Cmdlet(VerbsCommunications.Read, "PnPProvisioningTemplate")] - [Alias("Load-PnPProvisioningTemplate")] + [Cmdlet(VerbsCommunications.Read, "PnPSiteTemplate")] + [Alias("Load-PnPProvisioningTemplate", "Read-PnPProvisioningTemplate")] [CmdletHelp("Loads/Reads a PnP file from the file system", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Read-PnPProvisioningTemplate -Path template.pnp", + Code = @"PS:> Read-PnPSiteTemplate -Path template.pnp", Remarks = "Loads a PnP file from the file system", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Read-PnPProvisioningTemplate -Path template.pnp -TemplateProviderExtensions $extensions", + Code = @"PS:> Read-PnPSiteTemplate -Path template.pnp -TemplateProviderExtensions $extensions", Remarks = "Loads a PnP file from the file system using some custom template provider extenions while loading the file.", SortOrder = 2)] - public class ReadProvisioningTemplate : PSCmdlet + public class ReadSiteTemplate : PSCmdlet { [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename to read from, optionally including full path.")] public string Path; diff --git a/Commands/Provisioning/RemoveFileFromProvisioningTemplate.cs b/Commands/Provisioning/Site/RemoveFileFromSiteTemplate.cs similarity index 86% rename from Commands/Provisioning/RemoveFileFromProvisioningTemplate.cs rename to Commands/Provisioning/Site/RemoveFileFromSiteTemplate.cs index 00e480bc3..952ce792c 100644 --- a/Commands/Provisioning/RemoveFileFromProvisioningTemplate.cs +++ b/Commands/Provisioning/Site/RemoveFileFromSiteTemplate.cs @@ -4,23 +4,21 @@ using OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml; using SharePointPnP.PowerShell.CmdletHelpAttributes; using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Management.Automation; -using System.Text; -using System.Threading.Tasks; -namespace SharePointPnP.PowerShell.Commands.Provisioning +namespace SharePointPnP.PowerShell.Commands.Provisioning.Site { - [Cmdlet(VerbsCommon.Remove, "PnPFileFromProvisioningTemplate")] - [CmdletHelp("Removes a file from a PnP Provisioning Template", + [Cmdlet(VerbsCommon.Remove, "PnPFileFromSiteTemplate")] + [Alias("Remove-PnPFileFromProvisioningTemplate")] + [CmdletHelp("Removes a file from a PnP Site Template", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Remove-PnPFileFromProvisioningTemplate -Path template.pnp -FilePath filePath", + Code = @"PS:> Remove-PnPFileFromSiteTemplate -Path template.pnp -FilePath filePath", Remarks = "Removes a file from an in-memory PnP Provisioning Template", SortOrder = 1)] - public class RemoveFileFromProvisioningTemplate : PSCmdlet + public class RemoveFileFromSiteTemplate : PSCmdlet { [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename to read the template from, optionally including full path.")] public string Path; @@ -38,7 +36,7 @@ protected override void ProcessRecord() Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path); } // Load the template - ProvisioningTemplate template = ReadProvisioningTemplate + ProvisioningTemplate template = ReadSiteTemplate .LoadProvisioningTemplateFromFile(Path, TemplateProviderExtensions); diff --git a/Commands/Provisioning/SaveProvisioningTemplate.cs b/Commands/Provisioning/Site/SaveSiteTemplate.cs similarity index 90% rename from Commands/Provisioning/SaveProvisioningTemplate.cs rename to Commands/Provisioning/Site/SaveSiteTemplate.cs index 035941840..c787f699c 100644 --- a/Commands/Provisioning/SaveProvisioningTemplate.cs +++ b/Commands/Provisioning/Site/SaveSiteTemplate.cs @@ -13,14 +13,15 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning { - [Cmdlet(VerbsData.Save, "PnPProvisioningTemplate")] - [CmdletHelp("Saves a PnP provisioning tempalte to the file system", + [Cmdlet(VerbsData.Save, "PnPSiteTemplate")] + [Alias("Save-PnPProvisioningTemplate")] + [CmdletHelp("Saves a PnP site template to the file system", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Save-PnPProvisioningTemplate -InputInstance $template -Out .\template.pnp", - Remarks = "Saves a PnP provisioning template to the file system as a PnP file.", + Code = @"PS:> Save-PnPSiteTemplate -InputInstance $template -Out .\template.pnp", + Remarks = "Saves a PnP site template to the file system as a PnP file.", SortOrder = 1)] - public class SaveProvisioningTemplate : PSCmdlet + public class SaveSiteTemplate : PSCmdlet { [Parameter(Mandatory = true, HelpMessage = "Allows you to provide an in-memory instance of the ProvisioningTemplate type of the PnP Core Component. When using this parameter, the -Out parameter refers to the path for saving the template and storing any supporting file for the template.")] public ProvisioningTemplate InputInstance; diff --git a/Commands/Provisioning/SetProvisioningTemplateMetadata.cs b/Commands/Provisioning/Site/SetSiteTemplateMetadata.cs similarity index 72% rename from Commands/Provisioning/SetProvisioningTemplateMetadata.cs rename to Commands/Provisioning/Site/SetSiteTemplateMetadata.cs index 5e4508e9e..6dbbda3f4 100644 --- a/Commands/Provisioning/SetProvisioningTemplateMetadata.cs +++ b/Commands/Provisioning/Site/SetSiteTemplateMetadata.cs @@ -10,40 +10,41 @@ using OfficeDevPnP.Core.Framework.Provisioning.Providers; using SharePointPnP.PowerShell.Commands.Utilities; -namespace SharePointPnP.PowerShell.Commands.Provisioning +namespace SharePointPnP.PowerShell.Commands.Provisioning.Site { - [Cmdlet(VerbsCommon.Set, "PnPProvisioningTemplateMetadata")] + [Cmdlet(VerbsCommon.Set, "PnPSiteTemplateMetadata")] + [Alias("Set-PnPProvisioningTemplateMetadata")] [CmdletHelp("Sets metadata of a provisioning template", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Set-PnPProvisioningTemplateMetadata -Path template.xml -TemplateDisplayName ""DisplayNameValue""", - Remarks = @"Sets the DisplayName property of a provisioning template in XML format.", + Code = @"PS:> Set-PnPSiteTemplateMetadata -Path template.xml -TemplateDisplayName ""DisplayNameValue""", + Remarks = @"Sets the DisplayName property of a site template in XML format.", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Set-PnPProvisioningTemplateMetadata -Path template.pnp -TemplateDisplayName ""DisplayNameValue""", - Remarks = @"Sets the DisplayName property of a provisioning template in Office Open XML format.", + Code = @"PS:> Set-PnPSiteTemplateMetadata -Path template.pnp -TemplateDisplayName ""DisplayNameValue""", + Remarks = @"Sets the DisplayName property of a site template in Office Open XML format.", SortOrder = 2)] [CmdletExample( - Code = @"PS:> Set-PnPProvisioningTemplateMetadata -Path template.xml -TemplateImagePreviewUrl ""Full URL of the Image Preview""", - Remarks = @"Sets the Url to the preview image of a provisioning template in XML format.", + Code = @"PS:> Set-PnPSiteTemplateMetadata -Path template.xml -TemplateImagePreviewUrl ""Full URL of the Image Preview""", + Remarks = @"Sets the Url to the preview image of a site template in XML format.", SortOrder = 3)] [CmdletExample( - Code = @"PS:> Set-PnPProvisioningTemplateMetadata -Path template.pnp -TemplateImagePreviewUrl ""Full URL of the Image Preview""", - Remarks = @"Sets the to the preview image of a provisioning template in Office Open XML format.", + Code = @"PS:> Set-PnPSiteTemplateMetadata -Path template.pnp -TemplateImagePreviewUrl ""Full URL of the Image Preview""", + Remarks = @"Sets the to the preview image of a site template in Office Open XML format.", SortOrder = 4)] [CmdletExample( - Code = @"PS:> Set-PnPProvisioningTemplateMetadata -Path template.xml -TemplateProperties @{""Property1"" = ""Test Value 1""; ""Property2""=""Test Value 2""}", - Remarks = @"Sets the property 'Property1' to the value 'Test Value 1' of a provisioning template in XML format.", + Code = @"PS:> Set-PnPSiteTemplateMetadata -Path template.xml -TemplateProperties @{""Property1"" = ""Test Value 1""; ""Property2""=""Test Value 2""}", + Remarks = @"Sets the property 'Property1' to the value 'Test Value 1' of a site template in XML format.", SortOrder = 5)] [CmdletExample( - Code = @"PS:> Set-PnPProvisioningTemplateMetadata -Path template.pnp -TemplateProperties @{""Property1"" = ""Test Value 1""; ""Property2""=""Test Value 2""}", - Remarks = @"Sets the property 'Property1' to the value 'Test Value 1' of a provisioning template in Office Open XML format.", + Code = @"PS:> Set-PnPSiteTemplateMetadata -Path template.pnp -TemplateProperties @{""Property1"" = ""Test Value 1""; ""Property2""=""Test Value 2""}", + Remarks = @"Sets the property 'Property1' to the value 'Test Value 1' of a site template in Office Open XML format.", SortOrder = 6)] - public class SetProvisioningTemplateMetadata : PnPWebCmdlet + public class SetSiteTemplateMetadata : PnPWebCmdlet { - [Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true, HelpMessage = "Path to the xml or pnp file containing the provisioning template.")] + [Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true, HelpMessage = "Path to the xml or pnp file containing the site template.")] public string Path; [Parameter(Mandatory = false, HelpMessage = "It can be used to specify the DisplayName of the template file that will be updated.")] @@ -108,7 +109,7 @@ protected override void ExecuteCmdlet() if (provisioningTemplate == null) return; - GetProvisioningTemplate.SetTemplateMetadata(provisioningTemplate, TemplateDisplayName, TemplateImagePreviewUrl, TemplateProperties); + GetSiteTemplate.SetTemplateMetadata(provisioningTemplate, TemplateDisplayName, TemplateImagePreviewUrl, TemplateProperties); provider.SaveAs(provisioningTemplate, templateFileName, TemplateProviderExtensions); } diff --git a/Commands/Provisioning/TestProvisioningHierarchy.cs b/Commands/Provisioning/TestProvisioningHierarchy.cs deleted file mode 100644 index b339ff341..000000000 --- a/Commands/Provisioning/TestProvisioningHierarchy.cs +++ /dev/null @@ -1,91 +0,0 @@ -using OfficeDevPnP.Core.Framework.Provisioning.Model; -using SharePointPnP.PowerShell.CmdletHelpAttributes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Management.Automation; - -namespace SharePointPnP.PowerShell.Commands.Provisioning -{ - [Cmdlet(VerbsDiagnostic.Test, "PnPProvisioningHierarchy", SupportsShouldProcess = true)] - [CmdletHelp("Tests a provisioning hierarchy for invalid references", - Category = CmdletHelpCategory.Provisioning)] - [CmdletExample( - Code = @"PS:> Test-PnPProvisioningHierarchy -Hierarchy $myhierarchy", - Remarks = "Checks for valid template references", - SortOrder = 1)] - public class TestProvisioningHierarchy : PnPCmdlet - { - [Parameter(Mandatory = true, HelpMessage = "The hierarchy to add the sequence to", ParameterSetName = ParameterAttribute.AllParameterSets)] - public ProvisioningHierarchy Hierarchy; - - protected override void ExecuteCmdlet() - { - List issues = new List(); - foreach(var sequence in Hierarchy.Sequences) - { - foreach (var site in sequence.SiteCollections) - { - foreach (var template in site.Templates) - { - if(Hierarchy.Templates.FirstOrDefault(t => t.Id == template) == null) - { - issues.Add($"Template {template} referenced in site {site.Id} is not present in hierarchy."); - } - } - foreach(var subsite in site.Sites.Cast()) - { - foreach (var template in subsite.Templates) - { - if (Hierarchy.Templates.FirstOrDefault(t => t.Id == template) == null) - { - issues.Add($"Template {template} referenced in subsite with url {subsite.Url} in site {site.Id} is not present in hierarchy"); - } - } - } - } - } - foreach(var template in Hierarchy.Templates) - { - var used = false; - foreach(var sequence in Hierarchy.Sequences) - { - foreach(var site in sequence.SiteCollections) - { - if(site.Templates.Contains(template.Id)) - { - used = true; - break; - } - - foreach(var subsite in site.Sites) - { - if(subsite.Templates.Contains(template.Id)) - { - used = true; - break; - } - } - if (used) - { - break; - } - } - if(used) - { - break; - } - } - if(!used) - { - issues.Add($"Template {template.Id} is not used by any site in the hierarchy."); - } - } - if(issues.Any()) - { - WriteObject(issues, true); - } - - } - } -} diff --git a/Commands/SharePointPnP.PowerShell.Commands.csproj b/Commands/SharePointPnP.PowerShell.Commands.csproj index fb50e70a3..c989966c2 100644 --- a/Commands/SharePointPnP.PowerShell.Commands.csproj +++ b/Commands/SharePointPnP.PowerShell.Commands.csproj @@ -501,22 +501,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -686,28 +686,28 @@ - - + + - - - + + + - - - - - + + + + + - + - - - + + + From 2e3b987b25c9c562b9aee9013df675094e98838d Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Fri, 2 Nov 2018 11:20:39 +0100 Subject: [PATCH 15/30] Removing beta notice as the API is now supported. Also removed unused usings. --- Commands/Admin/NewSite.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Commands/Admin/NewSite.cs b/Commands/Admin/NewSite.cs index 17c4fc725..12902761d 100644 --- a/Commands/Admin/NewSite.cs +++ b/Commands/Admin/NewSite.cs @@ -1,20 +1,14 @@ #if !ONPREMISES -using System; using System.Management.Automation; using Microsoft.SharePoint.Client; -using OfficeDevPnP.Core; -using OfficeDevPnP.Core.Entities; using SharePointPnP.PowerShell.CmdletHelpAttributes; -using SharePointPnP.PowerShell.Commands.Base; -using Resources = SharePointPnP.PowerShell.Commands.Properties.Resources; -using System.Threading.Tasks; using SharePointPnP.PowerShell.Commands.Base.PipeBinds; using SharePointPnP.PowerShell.Commands.Enums; namespace SharePointPnP.PowerShell.Commands { [Cmdlet(VerbsCommon.New, "PnPSite")] - [CmdletHelp("BETA: This cmdlet is using early release APIs. Notice that functionality and parameters can change. Creates a new site collection", + [CmdletHelp("Creates a new site collection", "The New-PnPSite cmdlet creates a new site collection for the current tenant. Currently only 'modern' sites like Communication Site and the Modern Team Site are supported. If you want to create a classic site, use New-PnPTenantSite.", OutputType = typeof(string), OutputTypeDescription = "Returns the url of the newly created site collection", From 374707534993c50ca9f85bba965cb55a28650a99 Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Wed, 7 Nov 2018 17:41:42 +0100 Subject: [PATCH 16/30] updated cmdlet aliases --- CHANGELOG.md | 15 + ...s => AddDataRowsToProvisioningTemplate.cs} | 11 +- ...te.cs => AddFileToProvisioningTemplate.cs} | 15 +- ...> AddListFoldersToProvisioningTemplate.cs} | 14 +- ...mplate.cs => ApplyProvisioningTemplate.cs} | 21 +- .../ConvertFolderToProvisioningTemplate.cs | 9 +- ...late.cs => ConvertProvisioningTemplate.cs} | 17 +- ...Template.cs => GetProvisioningTemplate.cs} | 31 +- ...Template.cs => NewProvisioningTemplate.cs} | 9 +- ...emplate.cs => ReadProvisioningTemplate.cs} | 10 +- ... => RemoveFileFromProvisioningTemplate.cs} | 11 +- ...emplate.cs => SaveProvisioningTemplate.cs} | 5 +- ....cs => SetProvisioningTemplateMetadata.cs} | 19 +- ...Template.cs => AddProvisioningTemplate.cs} | 9 +- .../SharePointPnP.PowerShell.Commands.csproj | 24 +- Commands/Site/SetSite.cs | 275 +++++++++++++++++- 16 files changed, 374 insertions(+), 121 deletions(-) rename Commands/Provisioning/Site/{AddDataRowsToSiteTemplate.cs => AddDataRowsToProvisioningTemplate.cs} (96%) rename Commands/Provisioning/Site/{AddFileToSiteTemplate.cs => AddFileToProvisioningTemplate.cs} (88%) rename Commands/Provisioning/Site/{AddListFoldersToSiteTemplate.cs => AddListFoldersToProvisioningTemplate.cs} (93%) rename Commands/Provisioning/Site/{ApplySiteTemplate.cs => ApplyProvisioningTemplate.cs} (95%) rename Commands/Provisioning/Site/{ConvertSiteTemplate.cs => ConvertProvisioningTemplate.cs} (89%) rename Commands/Provisioning/Site/{GetSiteTemplate.cs => GetProvisioningTemplate.cs} (94%) rename Commands/Provisioning/Site/{NewSiteTemplate.cs => NewProvisioningTemplate.cs} (66%) rename Commands/Provisioning/Site/{ReadSiteTemplate.cs => ReadProvisioningTemplate.cs} (90%) rename Commands/Provisioning/Site/{RemoveFileFromSiteTemplate.cs => RemoveFileFromProvisioningTemplate.cs} (89%) rename Commands/Provisioning/Site/{SaveSiteTemplate.cs => SaveProvisioningTemplate.cs} (96%) rename Commands/Provisioning/Site/{SetSiteTemplateMetadata.cs => SetProvisioningTemplateMetadata.cs} (82%) rename Commands/Provisioning/Tenant/{AddSiteTemplate.cs => AddProvisioningTemplate.cs} (80%) diff --git a/CHANGELOG.md b/CHANGELOG.md index c41250199..7d5a0ebf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,21 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed documentation for Measure-PnPWeb - Updated samples - Fixes issue with Set-PnPUnifiedGroup where if you only change for instance the displayname a private group would be marked as public. +- Renamed (and created aliases for the old cmdlet name) Apply-PnPProvisioningHierarchy to Apply-PnPTenantTemplate +- Renamed (and created aliases for the old cmdlet name) Add-PnPProvisioningSequence to Add-PnPTenantSequence +- Renamed (and created aliases for the old cmdlet name) Add-PnPProvisioningSite to Add-PnPTenantSequenceSite +- Renamed (and created aliases for the old cmdlet name) Add-PnPPnPProvisioningSubSite to Add-PnPTenantSequenceSubSite +- Renamed (and created aliases for the old cmdlet name) Get-PnPProvisioningSequence to Get-PnPTenantSequence +- Renamed (and created aliases for the old cmdlet name) Get-PnPProvisioningSite to Get-PnPTenantSequenceSite +- Renamed (and created aliases for the old cmdlet name) New-PnPProvisioningSequence to New-PnPTenantSequence +- Renamed (and created aliases for the old cmdlet name) New-PnPProvisioningTeamSite to New-PnPTenantSequenceTeamSite +- Renamed (and created aliases for the old cmdlet name) New-PnPProvisioningCommunicationSite to New-PnPTenantSequenceCommunicationSite +- Renamed (and created aliases for the old cmdlet name) New-PnPProvisioningTeamNoGroupSite to New-PnPTenantSequenceTeamNoGroupSite +- Renamed (and created aliases for the old cmdlet name) New-PnPProvisioningTeamNoGroupSubSite to New-PnPTenantSequenceTeamNoGroupSubSite +- Renamed (and created aliases for the old cmdlet name) New-PnPProvisioningHierarchy to New-PnPTenantTemplate +- Renamed (and created aliases for the old cmdlet name) Read-PnPProvisioningHierarchy to Read-PnPTenantTemplate +- Renamed (and created aliases for the old cmdlet name) Save-PnPProvisioningHierarchy to Save-PnPTenantTemplate +- Renamed (and created aliases for the old cmdlet name) Test-PnPProvisioningHierarchy to Test-PnPTenantTemplate ### Deprecated - Marked Get-PnPProvisioningTemplateFromGallery as deprecated as the PnP Template Gallery has been shut down. diff --git a/Commands/Provisioning/Site/AddDataRowsToSiteTemplate.cs b/Commands/Provisioning/Site/AddDataRowsToProvisioningTemplate.cs similarity index 96% rename from Commands/Provisioning/Site/AddDataRowsToSiteTemplate.cs rename to Commands/Provisioning/Site/AddDataRowsToProvisioningTemplate.cs index edc752aa5..50585e5e9 100644 --- a/Commands/Provisioning/Site/AddDataRowsToSiteTemplate.cs +++ b/Commands/Provisioning/Site/AddDataRowsToProvisioningTemplate.cs @@ -17,19 +17,18 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning.Site { - [Cmdlet(VerbsCommon.Add, "PnPDataRowsToSiteTemplate")] - [Alias("Add-PnPDataRowsToProvisioningTemplate")] + [Cmdlet(VerbsCommon.Add, "PnPDataRowsToProvisioningTemplate")] [CmdletHelp("Adds datarows to a list inside a PnP Provisioning Template", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Add-PnPDataRowsToSiteTemplate -Path template.pnp -List 'PnPTestList' -Query '' -Fields 'Title','Choice'", + Code = @"PS:> Add-PnPDataRowsToProvisioningTemplate -Path template.pnp -List 'PnPTestList' -Query '' -Fields 'Title','Choice'", Remarks = "Adds datarows to a list in an in-memory PnP Provisioning Template", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Add-PnPDataRowsToSiteTemplate -Path template.pnp -List 'PnPTestList' -Query '' -Fields 'Title','Choice' -IncludeSecurity", + Code = @"PS:> Add-PnPDataRowsToProvisioningTemplate -Path template.pnp -List 'PnPTestList' -Query '' -Fields 'Title','Choice' -IncludeSecurity", Remarks = "Adds datarows to a list in an in-memory PnP Provisioning Template", SortOrder = 2)] - public class AddDataRowsToSiteTemplate : PnPWebCmdlet + public class AddDataRowsToProvisioningTemplate : PnPWebCmdlet { [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename of the .PNP Open XML site template to read from, optionally including full path.")] public string Path; @@ -65,7 +64,7 @@ protected override void ExecuteCmdlet() Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path); } - var template = ReadSiteTemplate + var template = ReadProvisioningTemplate .LoadProvisioningTemplateFromFile(Path, TemplateProviderExtensions); diff --git a/Commands/Provisioning/Site/AddFileToSiteTemplate.cs b/Commands/Provisioning/Site/AddFileToProvisioningTemplate.cs similarity index 88% rename from Commands/Provisioning/Site/AddFileToSiteTemplate.cs rename to Commands/Provisioning/Site/AddFileToProvisioningTemplate.cs index 6ed824687..ad972c19c 100644 --- a/Commands/Provisioning/Site/AddFileToSiteTemplate.cs +++ b/Commands/Provisioning/Site/AddFileToProvisioningTemplate.cs @@ -13,24 +13,23 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning.Site { - [Cmdlet(VerbsCommon.Add, "PnPFileToSiteTemplate")] - [Alias("Add-PnPFileToProvisioningTemplate")] - [CmdletHelp("Adds a file to a PnP Site Template", + [Cmdlet(VerbsCommon.Add, "PnPFileToProvisioningTemplate")] + [CmdletHelp("Adds a file to a PnP Provisioning Template", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Add-PnPFileToSiteTemplate -Path template.pnp -Source $sourceFilePath -Folder $targetFolder", + Code = @"PS:> Add-PnPFileToProvisioningTemplate -Path template.pnp -Source $sourceFilePath -Folder $targetFolder", Remarks = "Adds a file to a PnP Site Template", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Add-PnPFileToSiteTemplate -Path template.xml -Source $sourceFilePath -Folder $targetFolder", + Code = @"PS:> Add-PnPFileToProvisioningTemplate -Path template.xml -Source $sourceFilePath -Folder $targetFolder", Remarks = "Adds a file reference to a PnP Site XML Template", SortOrder = 2)] [CmdletExample( - Code = @"PS:> Add-PnPFileToSiteTemplate -Path template.pnp -Source ""./myfile.png"" -Folder ""folderinsite"" -FileLevel Published -FileOverwrite:$false", + Code = @"PS:> Add-PnPFileToProvisioningTemplate -Path template.pnp -Source ""./myfile.png"" -Folder ""folderinsite"" -FileLevel Published -FileOverwrite:$false", Remarks = "Adds a file to a PnP Site Template, specifies the level as Published and defines to not overwrite the file if it exists in the site.", SortOrder = 3)] [CmdletExample( - Code = @"PS:> Add-PnPFileToSiteTemplate -Path template.pnp -Source $sourceFilePath -Folder $targetFolder -Container $container", + Code = @"PS:> Add-PnPFileToProvisioningTemplate -Path template.pnp -Source $sourceFilePath -Folder $targetFolder -Container $container", Remarks = "Adds a file to a PnP Site Template with a custom container for the file", SortOrder = 4)] @@ -68,7 +67,7 @@ protected override void ProcessRecord() Source = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Source); } // Load the template - var template = ReadSiteTemplate + var template = ReadProvisioningTemplate .LoadProvisioningTemplateFromFile(Path, TemplateProviderExtensions); diff --git a/Commands/Provisioning/Site/AddListFoldersToSiteTemplate.cs b/Commands/Provisioning/Site/AddListFoldersToProvisioningTemplate.cs similarity index 93% rename from Commands/Provisioning/Site/AddListFoldersToSiteTemplate.cs rename to Commands/Provisioning/Site/AddListFoldersToProvisioningTemplate.cs index 1e84d1d35..b3aa0aee1 100644 --- a/Commands/Provisioning/Site/AddListFoldersToSiteTemplate.cs +++ b/Commands/Provisioning/Site/AddListFoldersToProvisioningTemplate.cs @@ -16,25 +16,23 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning.Site { - [Cmdlet(VerbsCommon.Add, "PnPListFoldersToSiteTemplate")] - [Alias("Add-PnPListFoldersToProvisioningTemplate")] - + [Cmdlet(VerbsCommon.Add, "PnPListFoldersToProvisioningTemplate")] [CmdletHelp("Adds folders to a list in a PnP Provisioning Template", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Add-PnPListFoldersToSiteTemplate -Path template.pnp -List 'PnPTestList'", + Code = @"PS:> Add-PnPListFoldersToProvisioningTemplate -Path template.pnp -List 'PnPTestList'", Remarks = "Adds top level folders from a list to an existing template and returns an in-memory PnP Site Template", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Add-PnPListFoldersToSiteTemplate -Path template.pnp -List 'PnPTestList' -Recursive", + Code = @"PS:> Add-PnPListFoldersToProvisioningTemplate -Path template.pnp -List 'PnPTestList' -Recursive", Remarks = "Adds all folders from a list to an existing template and returns an in-memory PnP Site Template", SortOrder = 2)] [CmdletExample( - Code = @"PS:> Add-PnPListFoldersToSiteTemplate -Path template.pnp -List 'PnPTestList' -Recursive -IncludeSecurity", + Code = @"PS:> Add-PnPListFoldersToProvisioningTemplate -Path template.pnp -List 'PnPTestList' -Recursive -IncludeSecurity", Remarks = "Adds all folders from a list with unique permissions to an in-memory PnP Site Template", SortOrder = 3)] - public class AddListFoldersToSiteTemplate : PnPWebCmdlet + public class AddListFoldersToProvisioningTemplate : PnPWebCmdlet { [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename of the .PNP Open XML site template to read from, optionally including full path.")] @@ -61,7 +59,7 @@ protected override void ExecuteCmdlet() Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path); } // Load the template - var template = ReadSiteTemplate + var template = ReadProvisioningTemplate .LoadProvisioningTemplateFromFile(Path, TemplateProviderExtensions); diff --git a/Commands/Provisioning/Site/ApplySiteTemplate.cs b/Commands/Provisioning/Site/ApplyProvisioningTemplate.cs similarity index 95% rename from Commands/Provisioning/Site/ApplySiteTemplate.cs rename to Commands/Provisioning/Site/ApplyProvisioningTemplate.cs index df810b9cc..4e313c85a 100644 --- a/Commands/Provisioning/Site/ApplySiteTemplate.cs +++ b/Commands/Provisioning/Site/ApplyProvisioningTemplate.cs @@ -16,49 +16,48 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning.Site { - [Cmdlet("Apply", "PnPSiteTemplate")] - [Alias("Apply-PnPProvisioningTemplate")] + [Cmdlet("Apply", "PnPProvisioningTemplate")] [CmdletHelp("Applies a site template to a web", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Apply-PnPSiteTemplate -Path template.xml", + Code = @"PS:> Apply-PnPProvisioningTemplate -Path template.xml", Remarks = @"Applies a site template in XML format to the current web.", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Apply-PnPSiteTemplate -Path template.xml -ResourceFolder c:\provisioning\resources", + Code = @"PS:> Apply-PnPSPnPProvisioningTemplateiteTemplate -Path template.xml -ResourceFolder c:\provisioning\resources", Remarks = @"Applies a site template in XML format to the current web. Any resources like files that are referenced in the template will be retrieved from the folder as specified with the ResourceFolder parameter.", SortOrder = 2)] [CmdletExample( - Code = @"PS:> Apply-PnPSiteTemplate -Path template.xml -Parameters @{""ListTitle""=""Projects"";""parameter2""=""a second value""}", + Code = @"PS:> Apply-PnPProvisioningTemplate -Path template.xml -Parameters @{""ListTitle""=""Projects"";""parameter2""=""a second value""}", Remarks = @"Applies a site template in XML format to the current web. It will populate the parameter in the template the values as specified and in the template you can refer to those values with the {parameter:} token. For instance with the example above, specifying {parameter:ListTitle} in your template will translate to 'Projects' when applying the template. These tokens can be used in most string values in a template.", SortOrder = 3)] [CmdletExample( - Code = @"PS:> Apply-PnPSiteTemplate -Path template.xml -Handlers Lists, SiteSecurity", + Code = @"PS:> Apply-PnPProvisioningTemplate -Path template.xml -Handlers Lists, SiteSecurity", Remarks = @"Applies a site template in XML format to the current web. It will only apply the lists and site security part of the template.", SortOrder = 4)] [CmdletExample( - Code = @"PS:> Apply-PnPSiteTemplate -Path template.pnp", + Code = @"PS:> Apply-PnPProvisioningTemplate -Path template.pnp", Remarks = @"Applies a site template from a pnp package to the current web.", SortOrder = 5)] [CmdletExample( - Code = @"PS:> Apply-PnPSiteTemplate -Path https://tenant.sharepoint.com/sites/templatestorage/Documents/template.pnp", + Code = @"PS:> Apply-PnPProvisioningTemplate -Path https://tenant.sharepoint.com/sites/templatestorage/Documents/template.pnp", Remarks = @"Applies a site template from a pnp package stored in a library to the current web.", SortOrder = 6)] [CmdletExample( Code = @" PS:> $handler1 = New-PnPExtensibilityHandlerObject -Assembly Contoso.Core.Handlers -Type Contoso.Core.Handlers.MyExtensibilityHandler1 PS:> $handler2 = New-PnPExtensibilityHandlerObject -Assembly Contoso.Core.Handlers -Type Contoso.Core.Handlers.MyExtensibilityHandler1 -PS:> Apply-PnPSiteTemplate -Path NewTemplate.xml -ExtensibilityHandlers $handler1,$handler2", +PS:> Apply-PnPProvisioningTemplate -Path NewTemplate.xml -ExtensibilityHandlers $handler1,$handler2", Remarks = @"This will create two new ExtensibilityHandler objects that are run while provisioning the template", SortOrder = 7)] [CmdletExample( - Code = @"PS:> Apply-PnPSiteTemplate -Path .\ -InputInstance $template", + Code = @"PS:> Apply-PnPProvisioningTemplate -Path .\ -InputInstance $template", Remarks = @"Applies a site template from an in-memory instance of a ProvisioningTemplate type of the PnP Core Component, reading the supporting files, if any, from the current (.\) path. The syntax can be used together with any other supported parameters.", SortOrder = 8)] - public class ApplySiteTemplate : PnPWebCmdlet + public class ApplyProvisioningTemplate : PnPWebCmdlet { private ProgressRecord progressRecord = new ProgressRecord(0, "Activity", "Status"); private ProgressRecord subProgressRecord = new ProgressRecord(1, "Activity", "Status"); diff --git a/Commands/Provisioning/Site/ConvertFolderToProvisioningTemplate.cs b/Commands/Provisioning/Site/ConvertFolderToProvisioningTemplate.cs index 389f585e0..6e1276de8 100644 --- a/Commands/Provisioning/Site/ConvertFolderToProvisioningTemplate.cs +++ b/Commands/Provisioning/Site/ConvertFolderToProvisioningTemplate.cs @@ -9,19 +9,18 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning { - [Cmdlet(VerbsData.Convert, "PnPFolderToSiteTemplate")] - [Alias("Convert-PnPFolderToProvisioningTemplate")] + [Cmdlet(VerbsData.Convert, "PnPFolderToProvisioningTemplate")] [CmdletHelp("Creates a pnp package file of an existing template xml, and includes all files in the current folder", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Convert-PnPFolderToSiteTemplate -Out template.pnp", + Code = @"PS:> Convert-PnPFolderToProvisioningTemplate -Out template.pnp", Remarks = "Creates a pnp package file of an existing template xml, and includes all files in the current folder", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Convert-PnPFolderToSiteTemplate -Out template.pnp -Folder c:\temp", + Code = @"PS:> Convert-PnPFolderToProvisioningTemplate -Out template.pnp -Folder c:\temp", Remarks = "Creates a pnp package file of an existing template xml, and includes all files in the c:\\temp folder", SortOrder = 2)] - public class ConvertFolderToSiteTemplate : PSCmdlet + public class ConvertFolderToProvisioningTemplate : PSCmdlet { [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename to write to, optionally including full path.")] public string Out; diff --git a/Commands/Provisioning/Site/ConvertSiteTemplate.cs b/Commands/Provisioning/Site/ConvertProvisioningTemplate.cs similarity index 89% rename from Commands/Provisioning/Site/ConvertSiteTemplate.cs rename to Commands/Provisioning/Site/ConvertProvisioningTemplate.cs index 387555bf0..f896173f9 100644 --- a/Commands/Provisioning/Site/ConvertSiteTemplate.cs +++ b/Commands/Provisioning/Site/ConvertProvisioningTemplate.cs @@ -7,21 +7,20 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning { - [Cmdlet(VerbsData.Convert, "PnPSiteTemplate")] - [Alias("Convert-PnPProvisioningTemplate")] - [CmdletHelp("Converts a site template to an other schema version", + [Cmdlet(VerbsData.Convert, "PnPProvisioningTemplate")] + [CmdletHelp("Converts a provisioning template to an other schema version", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Convert-PnPSiteTemplate -Path template.xml", - Remarks = @"Converts a site template to the latest schema and outputs the result to current console.", + Code = @"PS:> Convert-PnPProvisioningTemplate -Path template.xml", + Remarks = @"Converts a provisioning template to the latest schema and outputs the result to current console.", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Convert-PnPSiteTemplate -Path template.xml -Out newtemplate.xml", - Remarks = @"Converts a site template to the latest schema and outputs the result the newtemplate.xml file.", + Code = @"PS:> Convert-PnPProvisioningTemplate -Path template.xml -Out newtemplate.xml", + Remarks = @"Converts a provisioning template to the latest schema and outputs the result the newtemplate.xml file.", SortOrder = 2)] [CmdletExample( - Code = @"PS:> Convert-PnPSiteTemplate -Path template.xml -Out newtemplate.xml -ToSchema V201512", - Remarks = @"Converts a site template to the latest schema using the 201512 schema and outputs the result the newtemplate.xml file.", + Code = @"PS:> Convert-PnPProvisioningTemplate -Path template.xml -Out newtemplate.xml -ToSchema V201512", + Remarks = @"Converts a provisioning template to the latest schema using the 201512 schema and outputs the result the newtemplate.xml file.", SortOrder = 3)] [CmdletRelatedLink( Text ="Encoding", diff --git a/Commands/Provisioning/Site/GetSiteTemplate.cs b/Commands/Provisioning/Site/GetProvisioningTemplate.cs similarity index 94% rename from Commands/Provisioning/Site/GetSiteTemplate.cs rename to Commands/Provisioning/Site/GetProvisioningTemplate.cs index 4eeb5f34e..506c1481f 100644 --- a/Commands/Provisioning/Site/GetSiteTemplate.cs +++ b/Commands/Provisioning/Site/GetProvisioningTemplate.cs @@ -15,73 +15,72 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning.Site { - [Cmdlet(VerbsCommon.Get, "PnPSiteTemplate", SupportsShouldProcess = true)] - [Alias("Get-PnPProvisioningTemplate")] + [Cmdlet(VerbsCommon.Get, "PnPProvisioningTemplate", SupportsShouldProcess = true)] [CmdletHelp("Generates a provisioning site template from a web", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp", + Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp", Remarks = "Extracts a provisioning template in Office Open XML from the current web.", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Get-PnPSiteTemplate -Out template.xml", + Code = @"PS:> Get-PnPProvisioningTemplate -Out template.xml", Remarks = "Extracts a provisioning template in XML format from the current web.", SortOrder = 2)] [CmdletExample( - Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -Schema V201503", + Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -Schema V201503", Remarks = "Extracts a provisioning template in Office Open XML from the current web and saves it in the V201503 version of the schema.", SortOrder = 3)] [CmdletExample( - Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -IncludeAllTermGroups", + Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -IncludeAllTermGroups", Remarks = "Extracts a provisioning template in Office Open XML from the current web and includes all term groups, term sets and terms from the Managed Metadata Service Taxonomy.", SortOrder = 4)] [CmdletExample( - Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -IncludeSiteCollectionTermGroup", + Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -IncludeSiteCollectionTermGroup", Remarks = "Extracts a provisioning template in Office Open XML from the current web and includes the term group currently (if set) assigned to the site collection.", SortOrder = 5)] [CmdletExample( - Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -PersistComposedLookFiles", + Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -PersistComposedLookFiles", Remarks = "Extracts a provisioning template in Office Open XML from the current web and saves the files that make up the composed look to the same folder as where the template is saved.", SortOrder = 6)] [CmdletExample( - Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -Handlers Lists, SiteSecurity", + Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -Handlers Lists, SiteSecurity", Remarks = "Extracts a provisioning template in Office Open XML from the current web, but only processes lists and site security when generating the template.", SortOrder = 7)] [CmdletExample( Code = @" PS:> $handler1 = New-PnPExtensibilityHandlerObject -Assembly Contoso.Core.Handlers -Type Contoso.Core.Handlers.MyExtensibilityHandler1 PS:> $handler2 = New-PnPExtensibilityHandlerObject -Assembly Contoso.Core.Handlers -Type Contoso.Core.Handlers.MyExtensibilityHandler1 -PS:> Get-PnPSiteTemplate -Out NewTemplate.xml -ExtensibilityHandlers $handler1,$handler2", +PS:> Get-PnPProvisioningTemplate -Out NewTemplate.xml -ExtensibilityHandlers $handler1,$handler2", Remarks = @"This will create two new ExtensibilityHandler objects that are run during extraction of the template", SortOrder = 8)] #if !SP2013 [CmdletExample( - Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -PersistMultiLanguageResources", + Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -PersistMultiLanguageResources", Introduction = "Only supported on SP2016 and SP Online", Remarks = "Extracts a provisioning template in Office Open XML from the current web, and for supported artifacts it will create a resource file for each supported language (based upon the language settings of the current web). The generated resource files will be named after the value specified in the Out parameter. For instance if the Out parameter is specified as -Out 'template.xml' the generated resource file will be called 'template.en-US.resx'.", SortOrder = 9)] [CmdletExample( - Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -PersistMultiLanguageResources -ResourceFilePrefix MyResources", + Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -PersistMultiLanguageResources -ResourceFilePrefix MyResources", Introduction = "Only supported on SP2016 and SP Online", Remarks = "Extracts a provisioning template in Office Open XML from the current web, and for supported artifacts it will create a resource file for each supported language (based upon the language settings of the current web). The generated resource files will be named 'MyResources.en-US.resx' etc.", SortOrder = 10)] #endif [CmdletExample( - Code = @"PS:> $template = Get-PnPSiteTemplate -OutputInstance", + Code = @"PS:> $template = Get-PnPProvisioningTemplate -OutputInstance", Remarks = "Extracts an instance of a provisioning template object from the current web. This syntax cannot be used together with the -Out parameter, but it can be used together with any other supported parameters.", SortOrder = 11)] [CmdletExample( - Code = "PS:> Get-PnPSiteTemplate -Out template.pnp -ContentTypeGroups \"Group A\",\"Group B\"", + Code = "PS:> Get-PnPProvisioningTemplate -Out template.pnp -ContentTypeGroups \"Group A\",\"Group B\"", Remarks = @"Extracts a provisioning template in Office Open XML from the current web, but only processes content types from the to given content type groups.", SortOrder = 12)] [CmdletExample( - Code = @"PS:> Get-PnPSiteTemplate -Out template.pnp -ExcludeContentTypesFromSyndication", + Code = @"PS:> Get-PnPProvisioningTemplate -Out template.pnp -ExcludeContentTypesFromSyndication", Remarks = "Extracts a provisioning template in Office Open XML from the current web, excluding content types provisioned through content type syndication (content type hub), in order to prevent provisioning errors if the target also provision the content type using syndication.", SortOrder = 13)] [CmdletRelatedLink( Text = "Encoding", Url = "https://msdn.microsoft.com/en-us/library/system.text.encoding_properties.aspx")] - public class GetSiteTemplate : PnPWebCmdlet + public class GetProvisioningTemplate : PnPWebCmdlet { private ProgressRecord mainProgressRecord = new ProgressRecord(0, "Processing", "Status"); private ProgressRecord subProgressRecord = new ProgressRecord(1, "Activity", "Status"); diff --git a/Commands/Provisioning/Site/NewSiteTemplate.cs b/Commands/Provisioning/Site/NewProvisioningTemplate.cs similarity index 66% rename from Commands/Provisioning/Site/NewSiteTemplate.cs rename to Commands/Provisioning/Site/NewProvisioningTemplate.cs index 5ab8d66f7..37b713e08 100644 --- a/Commands/Provisioning/Site/NewSiteTemplate.cs +++ b/Commands/Provisioning/Site/NewProvisioningTemplate.cs @@ -4,15 +4,14 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning { - [Cmdlet(VerbsCommon.New, "PnPSiteTemplate", SupportsShouldProcess = true)] - [Alias("New-PnPProvisioningTemplate")] - [CmdletHelp("Creates a new site template object", + [Cmdlet(VerbsCommon.New, "PnPProvisioningTemplate", SupportsShouldProcess = true)] + [CmdletHelp("Creates a new provisioning template object", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> $template = New-PnPSiteTemplate", + Code = @"PS:> $template = New-PnPProvisioningTemplate", Remarks = "Creates a new instance of a site template object.", SortOrder = 1)] - public class NewSiteTemplate : PSCmdlet + public class NewProvisioningTemplate : PSCmdlet { protected override void ProcessRecord() { diff --git a/Commands/Provisioning/Site/ReadSiteTemplate.cs b/Commands/Provisioning/Site/ReadProvisioningTemplate.cs similarity index 90% rename from Commands/Provisioning/Site/ReadSiteTemplate.cs rename to Commands/Provisioning/Site/ReadProvisioningTemplate.cs index 7b9732faa..8c759e2aa 100644 --- a/Commands/Provisioning/Site/ReadSiteTemplate.cs +++ b/Commands/Provisioning/Site/ReadProvisioningTemplate.cs @@ -11,19 +11,19 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning { - [Cmdlet(VerbsCommunications.Read, "PnPSiteTemplate")] - [Alias("Load-PnPProvisioningTemplate", "Read-PnPProvisioningTemplate")] + [Cmdlet(VerbsCommunications.Read, "PnPProvisioningTemplate")] + [Alias("Load-PnPProvisioningTemplate")] [CmdletHelp("Loads/Reads a PnP file from the file system", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Read-PnPSiteTemplate -Path template.pnp", + Code = @"PS:> Read-PnPProvisioningTemplate -Path template.pnp", Remarks = "Loads a PnP file from the file system", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Read-PnPSiteTemplate -Path template.pnp -TemplateProviderExtensions $extensions", + Code = @"PS:> Read-PnPProvisioningTemplate -Path template.pnp -TemplateProviderExtensions $extensions", Remarks = "Loads a PnP file from the file system using some custom template provider extenions while loading the file.", SortOrder = 2)] - public class ReadSiteTemplate : PSCmdlet + public class ReadProvisioningTemplate : PSCmdlet { [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename to read from, optionally including full path.")] public string Path; diff --git a/Commands/Provisioning/Site/RemoveFileFromSiteTemplate.cs b/Commands/Provisioning/Site/RemoveFileFromProvisioningTemplate.cs similarity index 89% rename from Commands/Provisioning/Site/RemoveFileFromSiteTemplate.cs rename to Commands/Provisioning/Site/RemoveFileFromProvisioningTemplate.cs index 952ce792c..d007b450d 100644 --- a/Commands/Provisioning/Site/RemoveFileFromSiteTemplate.cs +++ b/Commands/Provisioning/Site/RemoveFileFromProvisioningTemplate.cs @@ -10,15 +10,14 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning.Site { - [Cmdlet(VerbsCommon.Remove, "PnPFileFromSiteTemplate")] - [Alias("Remove-PnPFileFromProvisioningTemplate")] - [CmdletHelp("Removes a file from a PnP Site Template", + [Cmdlet(VerbsCommon.Remove, "PnPFileFromProvisioningTemplate")] + [CmdletHelp("Removes a file from a PnP Provisioning Template", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Remove-PnPFileFromSiteTemplate -Path template.pnp -FilePath filePath", + Code = @"PS:> Remove-PnPFileFromProvisioningTemplate -Path template.pnp -FilePath filePath", Remarks = "Removes a file from an in-memory PnP Provisioning Template", SortOrder = 1)] - public class RemoveFileFromSiteTemplate : PSCmdlet + public class RemoveFileFromProvisioningTemplate : PSCmdlet { [Parameter(Mandatory = true, Position = 0, HelpMessage = "Filename to read the template from, optionally including full path.")] public string Path; @@ -36,7 +35,7 @@ protected override void ProcessRecord() Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path); } // Load the template - ProvisioningTemplate template = ReadSiteTemplate + ProvisioningTemplate template = ReadProvisioningTemplate .LoadProvisioningTemplateFromFile(Path, TemplateProviderExtensions); diff --git a/Commands/Provisioning/Site/SaveSiteTemplate.cs b/Commands/Provisioning/Site/SaveProvisioningTemplate.cs similarity index 96% rename from Commands/Provisioning/Site/SaveSiteTemplate.cs rename to Commands/Provisioning/Site/SaveProvisioningTemplate.cs index c787f699c..5238dfab2 100644 --- a/Commands/Provisioning/Site/SaveSiteTemplate.cs +++ b/Commands/Provisioning/Site/SaveProvisioningTemplate.cs @@ -13,15 +13,14 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning { - [Cmdlet(VerbsData.Save, "PnPSiteTemplate")] - [Alias("Save-PnPProvisioningTemplate")] + [Cmdlet(VerbsData.Save, "PnPProvisioningTemplate")] [CmdletHelp("Saves a PnP site template to the file system", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( Code = @"PS:> Save-PnPSiteTemplate -InputInstance $template -Out .\template.pnp", Remarks = "Saves a PnP site template to the file system as a PnP file.", SortOrder = 1)] - public class SaveSiteTemplate : PSCmdlet + public class SaveProvisioningTemplate : PSCmdlet { [Parameter(Mandatory = true, HelpMessage = "Allows you to provide an in-memory instance of the ProvisioningTemplate type of the PnP Core Component. When using this parameter, the -Out parameter refers to the path for saving the template and storing any supporting file for the template.")] public ProvisioningTemplate InputInstance; diff --git a/Commands/Provisioning/Site/SetSiteTemplateMetadata.cs b/Commands/Provisioning/Site/SetProvisioningTemplateMetadata.cs similarity index 82% rename from Commands/Provisioning/Site/SetSiteTemplateMetadata.cs rename to Commands/Provisioning/Site/SetProvisioningTemplateMetadata.cs index 6dbbda3f4..307e3e435 100644 --- a/Commands/Provisioning/Site/SetSiteTemplateMetadata.cs +++ b/Commands/Provisioning/Site/SetProvisioningTemplateMetadata.cs @@ -12,37 +12,36 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning.Site { - [Cmdlet(VerbsCommon.Set, "PnPSiteTemplateMetadata")] - [Alias("Set-PnPProvisioningTemplateMetadata")] + [Cmdlet(VerbsCommon.Set, "PnPProvisioningTemplateMetadata")] [CmdletHelp("Sets metadata of a provisioning template", Category = CmdletHelpCategory.Provisioning)] [CmdletExample( - Code = @"PS:> Set-PnPSiteTemplateMetadata -Path template.xml -TemplateDisplayName ""DisplayNameValue""", + Code = @"PS:> Set-PnPProvisioningTemplateMetadata -Path template.xml -TemplateDisplayName ""DisplayNameValue""", Remarks = @"Sets the DisplayName property of a site template in XML format.", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Set-PnPSiteTemplateMetadata -Path template.pnp -TemplateDisplayName ""DisplayNameValue""", + Code = @"PS:> Set-PnPProvisioningTemplateMetadata -Path template.pnp -TemplateDisplayName ""DisplayNameValue""", Remarks = @"Sets the DisplayName property of a site template in Office Open XML format.", SortOrder = 2)] [CmdletExample( - Code = @"PS:> Set-PnPSiteTemplateMetadata -Path template.xml -TemplateImagePreviewUrl ""Full URL of the Image Preview""", + Code = @"PS:> Set-PnPProvisioningTemplateMetadata -Path template.xml -TemplateImagePreviewUrl ""Full URL of the Image Preview""", Remarks = @"Sets the Url to the preview image of a site template in XML format.", SortOrder = 3)] [CmdletExample( - Code = @"PS:> Set-PnPSiteTemplateMetadata -Path template.pnp -TemplateImagePreviewUrl ""Full URL of the Image Preview""", + Code = @"PS:> Set-PnPProvisioningTemplateMetadata -Path template.pnp -TemplateImagePreviewUrl ""Full URL of the Image Preview""", Remarks = @"Sets the to the preview image of a site template in Office Open XML format.", SortOrder = 4)] [CmdletExample( - Code = @"PS:> Set-PnPSiteTemplateMetadata -Path template.xml -TemplateProperties @{""Property1"" = ""Test Value 1""; ""Property2""=""Test Value 2""}", + Code = @"PS:> Set-PnPProvisioningTemplateMetadata -Path template.xml -TemplateProperties @{""Property1"" = ""Test Value 1""; ""Property2""=""Test Value 2""}", Remarks = @"Sets the property 'Property1' to the value 'Test Value 1' of a site template in XML format.", SortOrder = 5)] [CmdletExample( - Code = @"PS:> Set-PnPSiteTemplateMetadata -Path template.pnp -TemplateProperties @{""Property1"" = ""Test Value 1""; ""Property2""=""Test Value 2""}", + Code = @"PS:> Set-PnPProvisioningTemplateMetadata -Path template.pnp -TemplateProperties @{""Property1"" = ""Test Value 1""; ""Property2""=""Test Value 2""}", Remarks = @"Sets the property 'Property1' to the value 'Test Value 1' of a site template in Office Open XML format.", SortOrder = 6)] - public class SetSiteTemplateMetadata : PnPWebCmdlet + public class SetProvisioningTemplateMetadata : PnPWebCmdlet { [Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true, HelpMessage = "Path to the xml or pnp file containing the site template.")] public string Path; @@ -109,7 +108,7 @@ protected override void ExecuteCmdlet() if (provisioningTemplate == null) return; - GetSiteTemplate.SetTemplateMetadata(provisioningTemplate, TemplateDisplayName, TemplateImagePreviewUrl, TemplateProperties); + GetProvisioningTemplate.SetTemplateMetadata(provisioningTemplate, TemplateDisplayName, TemplateImagePreviewUrl, TemplateProperties); provider.SaveAs(provisioningTemplate, templateFileName, TemplateProviderExtensions); } diff --git a/Commands/Provisioning/Tenant/AddSiteTemplate.cs b/Commands/Provisioning/Tenant/AddProvisioningTemplate.cs similarity index 80% rename from Commands/Provisioning/Tenant/AddSiteTemplate.cs rename to Commands/Provisioning/Tenant/AddProvisioningTemplate.cs index 5f65962be..739e61785 100644 --- a/Commands/Provisioning/Tenant/AddSiteTemplate.cs +++ b/Commands/Provisioning/Tenant/AddProvisioningTemplate.cs @@ -8,15 +8,14 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant { - [Cmdlet(VerbsCommon.Add, "PnPSiteTemplate", SupportsShouldProcess = true)] - [Alias("Add-PnpProvisioningTemplate")] - [CmdletHelp("Adds a PnP Site Template object to a tenant template", + [Cmdlet(VerbsCommon.Add, "PnpProvisioningTemplate", SupportsShouldProcess = true)] + [CmdletHelp("Adds a PnP Provisioning Template object to a tenant template", Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] [CmdletExample( - Code = @"PS:> Add-PnPSiteTemplate -TenantTemplate $tenanttemplate -SiteTemplate $sitetemplate", + Code = @"PS:> Add-PnpProvisioningTemplate -TenantTemplate $tenanttemplate -SiteTemplate $sitetemplate", Remarks = "Adds an existing site template to an existing tenant template object", SortOrder = 1)] - public class AddSiteTemplate : PSCmdlet + public class AddProvisioningTemplate : PSCmdlet { [Parameter(Mandatory = true, HelpMessage = "The template to add to the tenant template")] [Alias("Template")] diff --git a/Commands/SharePointPnP.PowerShell.Commands.csproj b/Commands/SharePointPnP.PowerShell.Commands.csproj index c989966c2..3891248b9 100644 --- a/Commands/SharePointPnP.PowerShell.Commands.csproj +++ b/Commands/SharePointPnP.PowerShell.Commands.csproj @@ -505,7 +505,7 @@ - + @@ -686,27 +686,27 @@ - - + + - - - + + + - - + + - + - + - - + + diff --git a/Commands/Site/SetSite.cs b/Commands/Site/SetSite.cs index 68fdbbe5f..32f6319a1 100644 --- a/Commands/Site/SetSite.cs +++ b/Commands/Site/SetSite.cs @@ -1,6 +1,13 @@ #if !ONPREMISES +using Microsoft.Online.SharePoint.TenantAdministration; +using Microsoft.Online.SharePoint.TenantManagement; using Microsoft.SharePoint.Client; +using OfficeDevPnP.Core; +using OfficeDevPnP.Core.Entities; using SharePointPnP.PowerShell.CmdletHelpAttributes; +using SharePointPnP.PowerShell.Commands.Utilities; +using System; +using System.Collections.Generic; using System.Management.Automation; namespace SharePointPnP.PowerShell.Commands.Site @@ -31,27 +38,110 @@ namespace SharePointPnP.PowerShell.Commands.Site SortOrder = 4)] public class SetSite : PnPCmdlet { - [Parameter(Mandatory = false, HelpMessage = "The classification to set")] + +#if !ONPREMISES + private const string ParameterSet_LOCKSTATE = "Set Lock State"; + private const string ParameterSet_PROPERTIES = "Set Properties"; +#endif + + [Parameter(Mandatory = false)] + [Alias("Url")] + public string Identity; + + [Parameter(Mandatory = false, HelpMessage = "The classification to set", ParameterSetName = ParameterSet_PROPERTIES)] public string Classification; - [Parameter(Mandatory = false, HelpMessage = "Disables flows for this site")] + [Parameter(Mandatory = false, HelpMessage = "Disables flows for this site", ParameterSetName = ParameterSet_PROPERTIES)] public SwitchParameter DisableFlows; - [Parameter(Mandatory = false, HelpMessage = "Sets the logo if the site is modern team site. If you want to set the logo for a classic site, use Set-PnPWeb -SiteLogoUrl")] + [Parameter(Mandatory = false, HelpMessage = "Sets the logo if the site is modern team site. If you want to set the logo for a classic site, use Set-PnPWeb -SiteLogoUrl", ParameterSetName = ParameterSet_PROPERTIES)] public string LogoFilePath; + [Parameter(Mandatory = false, HelpMessage = "Specifies what the sharing capablilites are for the site. Possible values: Disabled, ExternalUserSharingOnly, ExternalUserAndGuestSharing, ExistingExternalUserSharingOnly", ParameterSetName = ParameterSet_PROPERTIES)] + public SharingCapabilities? Sharing = null; + + [Parameter(Mandatory = false, HelpMessage = "Specifies the storage quota for this site collection in megabytes. This value must not exceed the company's available quota.", ParameterSetName = ParameterSet_PROPERTIES)] + public long? StorageMaximumLevel = null; + + [Parameter(Mandatory = false, HelpMessage = "Specifies the warning level for the storage quota in megabytes. This value must not exceed the values set for the StorageMaximumLevel parameter", ParameterSetName = ParameterSet_PROPERTIES)] + public long? StorageWarningLevel = null; + + [Parameter(Mandatory = false, HelpMessage = "Specifies the quota for this site collection in Sandboxed Solutions units. This value must not exceed the company's aggregate available Sandboxed Solutions quota. The default value is 0. For more information, see Resource Usage Limits on Sandboxed Solutions in SharePoint 2010 : http://msdn.microsoft.com/en-us/library/gg615462.aspx.", ParameterSetName = ParameterSet_PROPERTIES)] + [Obsolete("Sandboxed solution code has been deprecated")] + public double? UserCodeMaximumLevel = null; + + [Parameter(Mandatory = false, HelpMessage = "Specifies the warning level for the resource quota. This value must not exceed the value set for the UserCodeMaximumLevel parameter", ParameterSetName = ParameterSet_PROPERTIES)] + [Obsolete("Sandboxed solution code has been deprecated")] + public double? UserCodeWarningLevel = null; + + [Parameter(Mandatory = false, HelpMessage = "Sets the lockstate of a site", ParameterSetName = ParameterSet_LOCKSTATE)] + public SiteLockState? LockState; + + [Parameter(Mandatory = false, HelpMessage = "Specifies if the site administrator can upgrade the site collection", ParameterSetName = ParameterSet_PROPERTIES)] + public SwitchParameter? AllowSelfServiceUpgrade = null; + + [Parameter(Mandatory = false, HelpMessage = "Specifies if a site allows custom script or not. See https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f for more information.", ParameterSetName = ParameterSet_PROPERTIES)] + [Alias("DenyAndAddCustomizePages")] + public SwitchParameter NoScriptSite; + + [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.", ParameterSetName = ParameterSet_PROPERTIES)] + public List Owners; + + [Parameter(Mandatory = false, HelpMessage = "Specifies if comments on site pages are enabled or disabled", ParameterSetName = ParameterSet_PROPERTIES)] + public SwitchParameter CommentsOnSitePagesDisabled; + + [Parameter(Mandatory = false, HelpMessage = @"Specifies the default link permission for the site collection. None - Respect the organization default link permission. View - Sets the default link permission for the site to ""view"" permissions. Edit - Sets the default link permission for the site to ""edit"" permissions", ParameterSetName = ParameterSet_PROPERTIES)] + public SharingPermissionType? DefaultLinkPermission; + + [Parameter(Mandatory = false, HelpMessage = @"Specifies the default link type for the site collection. None - Respect the organization default sharing link type. AnonymousAccess - Sets the default sharing link for this site to an Anonymous Access or Anyone link. Internal - Sets the default sharing link for this site to the ""organization"" link or company shareable link. Direct - Sets the default sharing link for this site to the ""Specific people"" link", ParameterSetName = ParameterSet_PROPERTIES)] + public SharingLinkType? DefaultSharingLinkType; + + [Parameter(Mandatory = false, ParameterSetName = ParameterSet_PROPERTIES)] + public AppViewsPolicy? DisableAppViews; + + [Parameter(Mandatory = false, ParameterSetName = ParameterSet_PROPERTIES)] + public CompanyWideSharingLinksPolicy? DisableCompanyWideSharingLinks; + + [Parameter(Mandatory = false, HelpMessage = @"Specifies to prevent non-owners from inviting new users to the site", ParameterSetName = ParameterSet_PROPERTIES)] + public SwitchParameter DisableSharingForNonOwners; + + [Parameter(Mandatory = false, HelpMessage = @"Specifies the language of this site collection.", ParameterSetName = ParameterSet_PROPERTIES)] + public uint? LocaleId; + + [Parameter(Mandatory = false, HelpMessage = @"Specifies the language of this site collection.", ParameterSetName = ParameterSet_PROPERTIES)] + public string NewUrl; + + [Parameter(Mandatory = false, HelpMessage = @"Specifies the Geo/Region restrictions of this site.", ParameterSetName = ParameterSet_PROPERTIES)] + public RestrictedToRegion? RestrictedToGeo; + + [Parameter(Mandatory = false, HelpMessage = @"Specifies a list of email domains that is allowed for sharing with the external collaborators. Specify a comma separated list for example ""contoso.com"",""fabrikam.com""", ParameterSetName = ParameterSet_PROPERTIES)] + List SharingAllowedDomainList; + + [Parameter(Mandatory = false, HelpMessage = @"Disables or enables the Social Bar for Site Collection.", ParameterSetName = ParameterSet_PROPERTIES)] + public SwitchParameter SocialBarOnSitePagesDisabled; + + [Parameter(Mandatory = false, HelpMessage = "Wait for the operation to complete", ParameterSetName = ParameterSet_LOCKSTATE)] + public SwitchParameter Wait; + protected override void ExecuteCmdlet() { - var executeQueryRequired = false; + var context = ClientContext; var site = ClientContext.Site; - if (MyInvocation.BoundParameters.ContainsKey("Classification")) + var siteUrl = ClientContext.Url; + + var executeQueryRequired = false; + + if (!string.IsNullOrEmpty(Identity)) { - site.Classification = Classification; - executeQueryRequired = true; + context = ClientContext.Clone(Identity); + site = context.Site; + siteUrl = context.Url; } - if (MyInvocation.BoundParameters.ContainsKey("DisableFlows")) + + + if (MyInvocation.BoundParameters.ContainsKey("Classification")) { - site.DisableFlows = DisableFlows; + site.Classification = Classification; executeQueryRequired = true; } if (MyInvocation.BoundParameters.ContainsKey("LogoFilePath")) @@ -67,22 +157,183 @@ protected override void ExecuteCmdlet() { var bytes = System.IO.File.ReadAllBytes(LogoFilePath); var mimeType = System.Web.MimeMapping.GetMimeMapping(LogoFilePath); - var result = OfficeDevPnP.Core.Sites.SiteCollection.SetGroupImage(ClientContext, bytes, mimeType).GetAwaiter().GetResult(); + var result = OfficeDevPnP.Core.Sites.SiteCollection.SetGroupImage(context, bytes, mimeType).GetAwaiter().GetResult(); } else { throw new System.Exception("Logo file does not exist"); } - } else + } + else { throw new System.Exception("Not an Office365 group enabled site."); } } if (executeQueryRequired) { - ClientContext.ExecuteQueryRetry(); + context.ExecuteQueryRetry(); + } + + if (IsTenantProperty()) + { + var tenantAdminUrl = UrlUtilities.GetTenantAdministrationUrl(context.Url); + context = context.Clone(tenantAdminUrl); + + executeQueryRequired = false; + Func timeoutFunction = TimeoutFunction; + Tenant tenant = new Tenant(context); + var siteProperties = tenant.GetSitePropertiesByUrl(siteUrl, false); + if (LockState.HasValue) + { + tenant.SetSiteLockState(siteUrl, LockState.Value, Wait, Wait ? timeoutFunction : null); + WriteWarning("You changed the lockstate of this site. This change is not guaranteed to be effective immediately. Please wait a few minutes for this to take effect."); + } + + if (Owners != null && Owners.Count > 0) + { + var admins = new List(); + foreach (var owner in Owners) + { + var userEntity = new UserEntity { LoginName = owner }; + admins.Add(userEntity); + } + tenant.AddAdministrators(admins, new Uri(siteUrl)); + } + if (Sharing.HasValue) + { + siteProperties.SharingCapability = Sharing.Value; + executeQueryRequired = true; + } + if (StorageMaximumLevel.HasValue) + { + siteProperties.StorageMaximumLevel = StorageMaximumLevel.Value; + executeQueryRequired = true; + } + if (StorageWarningLevel.HasValue) + { + siteProperties.StorageWarningLevel = StorageWarningLevel.Value; + executeQueryRequired = true; + } +#pragma warning disable CS0618 // Type or member is obsolete + if (UserCodeWarningLevel.HasValue) + { + siteProperties.UserCodeWarningLevel = UserCodeWarningLevel.Value; + executeQueryRequired = true; + } + if (UserCodeMaximumLevel.HasValue) + { + siteProperties.UserCodeMaximumLevel = UserCodeMaximumLevel.Value; + executeQueryRequired = true; + } +#pragma warning restore CS0618 // Type or member is obsolete + + if (AllowSelfServiceUpgrade.HasValue) + { + siteProperties.AllowSelfServiceUpgrade = AllowSelfServiceUpgrade.Value; + executeQueryRequired = true; + } + if (NoScriptSite.IsPresent) + { + siteProperties.DenyAddAndCustomizePages = (NoScriptSite == true ? DenyAddAndCustomizePagesStatus.Enabled : DenyAddAndCustomizePagesStatus.Disabled); + executeQueryRequired = true; + } + if (CommentsOnSitePagesDisabled.IsPresent) + { + siteProperties.CommentsOnSitePagesDisabled = CommentsOnSitePagesDisabled; + executeQueryRequired = true; + } + if (DefaultLinkPermission.HasValue) + { + siteProperties.DefaultLinkPermission = DefaultLinkPermission.Value; + executeQueryRequired = true; + } + if (DefaultSharingLinkType.HasValue) + { + siteProperties.DefaultSharingLinkType = DefaultSharingLinkType.Value; + executeQueryRequired = true; + } + if (DisableAppViews.HasValue) + { + siteProperties.DisableAppViews = DisableAppViews.Value; + executeQueryRequired = true; + } + if (DisableCompanyWideSharingLinks.HasValue) + { + siteProperties.DisableCompanyWideSharingLinks = DisableCompanyWideSharingLinks.Value; + executeQueryRequired = true; + } + if (DisableFlows.IsPresent) + { + siteProperties.DisableFlows = DisableFlows ? FlowsPolicy.Disabled : FlowsPolicy.NotDisabled; + executeQueryRequired = true; + } + if (LocaleId.HasValue) + { + siteProperties.Lcid = LocaleId.Value; + executeQueryRequired = true; + } + if (!string.IsNullOrEmpty(NewUrl)) + { + siteProperties.NewUrl = NewUrl; + executeQueryRequired = true; + } + if (RestrictedToGeo.HasValue) + { + siteProperties.RestrictedToRegion = RestrictedToGeo.Value; + executeQueryRequired = true; + } + if (SocialBarOnSitePagesDisabled.IsPresent) + { + siteProperties.SocialBarOnSitePagesDisabled = SocialBarOnSitePagesDisabled; + executeQueryRequired = true; + } + if (executeQueryRequired) + { + siteProperties.Update(); + tenant.Context.ExecuteQueryRetry(); + } + + if (DisableSharingForNonOwners.IsPresent) + { + Office365Tenant office365Tenant = new Office365Tenant(context); + context.Load(office365Tenant); + context.ExecuteQueryRetry(); + office365Tenant.DisableSharingForNonOwnersOfSite(siteUrl); + context.ExecuteQuery(); + } } } + + private bool TimeoutFunction(TenantOperationMessage message) + { + if (message == TenantOperationMessage.SettingSiteProperties || message == TenantOperationMessage.SettingSiteLockState) + { + Host.UI.Write("."); + } + return Stopping; + } + + private bool IsTenantProperty() => LockState.HasValue || + (Owners != null && Owners.Count > 0) || + Sharing.HasValue || + StorageMaximumLevel.HasValue || + StorageWarningLevel.HasValue || +#pragma warning disable CS0618 // Type or member is obsolete + UserCodeMaximumLevel.HasValue || + UserCodeWarningLevel.HasValue || +#pragma warning restore CS0618 // Type or member is obsolete + AllowSelfServiceUpgrade.HasValue || + NoScriptSite.IsPresent || + CommentsOnSitePagesDisabled.IsPresent || + DefaultLinkPermission.HasValue || + DefaultSharingLinkType.HasValue || + DisableAppViews.HasValue || + DisableFlows.IsPresent || + DisableSharingForNonOwners.IsPresent || + LocaleId.HasValue || + !string.IsNullOrEmpty(NewUrl) || + RestrictedToGeo.HasValue || + SocialBarOnSitePagesDisabled.IsPresent; } } #endif \ No newline at end of file From 05cb7ebc83186c775f1c59626f2d6c961b14840b Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Thu, 8 Nov 2018 00:05:03 +0100 Subject: [PATCH 17/30] Added deprecation warnings --- Commands/Provisioning/Tenant/AddProvisioningTemplate.cs | 2 +- Commands/Provisioning/Tenant/AddTenantSequence.cs | 4 ++++ Commands/Provisioning/Tenant/AddTenantSequenceSite.cs | 4 ++++ Commands/Provisioning/Tenant/AddTenantSequenceSubSite.cs | 5 +++++ Commands/Provisioning/Tenant/ApplyTenantTemplate.cs | 5 +++++ Commands/Provisioning/Tenant/GetTenantSequence.cs | 5 +++++ Commands/Provisioning/Tenant/GetTenantSequenceSite.cs | 5 +++++ Commands/Provisioning/Tenant/NewTenantSequence.cs | 5 +++++ .../Tenant/NewTenantSequenceCommunicationSite.cs | 5 +++++ .../Provisioning/Tenant/NewTenantSequenceTeamNoGroupSite.cs | 5 +++++ .../Tenant/NewTenantSequenceTeamNoGroupSubSite.cs | 5 +++++ Commands/Provisioning/Tenant/NewTenantSequenceTeamSite.cs | 5 +++++ Commands/Provisioning/Tenant/NewTenantTemplate.cs | 4 ++++ Commands/Provisioning/Tenant/ReadTenantTemplate.cs | 5 +++++ Commands/Provisioning/Tenant/SaveTenantTemplate.cs | 4 ++++ Commands/Provisioning/Tenant/TestTenantTemplate.cs | 4 ++++ 16 files changed, 71 insertions(+), 1 deletion(-) diff --git a/Commands/Provisioning/Tenant/AddProvisioningTemplate.cs b/Commands/Provisioning/Tenant/AddProvisioningTemplate.cs index 739e61785..fef54f1a0 100644 --- a/Commands/Provisioning/Tenant/AddProvisioningTemplate.cs +++ b/Commands/Provisioning/Tenant/AddProvisioningTemplate.cs @@ -8,7 +8,7 @@ namespace SharePointPnP.PowerShell.Commands.Provisioning.Tenant { - [Cmdlet(VerbsCommon.Add, "PnpProvisioningTemplate", SupportsShouldProcess = true)] + [Cmdlet(VerbsCommon.Add, "PnPProvisioningTemplate", SupportsShouldProcess = true)] [CmdletHelp("Adds a PnP Provisioning Template object to a tenant template", Category = CmdletHelpCategory.Provisioning, SupportedPlatform = CmdletSupportedPlatform.Online)] [CmdletExample( diff --git a/Commands/Provisioning/Tenant/AddTenantSequence.cs b/Commands/Provisioning/Tenant/AddTenantSequence.cs index 74c893f7a..482b0b0ec 100644 --- a/Commands/Provisioning/Tenant/AddTenantSequence.cs +++ b/Commands/Provisioning/Tenant/AddTenantSequence.cs @@ -30,6 +30,10 @@ public class AddTenantSequence : PSCmdlet protected override void ProcessRecord() { + if (MyInvocation.InvocationName.ToLower() == "add-pnpprovisioningsequence") + { + WriteWarning("Add-PnPProvisioningSequence has been deprecated. Use Add-PnPTenantSequence instead."); + } if (Template.Sequences.FirstOrDefault(s => s.ID == Sequence.ID) == null) { Template.Sequences.Add(Sequence); diff --git a/Commands/Provisioning/Tenant/AddTenantSequenceSite.cs b/Commands/Provisioning/Tenant/AddTenantSequenceSite.cs index e01e3d512..17bf559d0 100644 --- a/Commands/Provisioning/Tenant/AddTenantSequenceSite.cs +++ b/Commands/Provisioning/Tenant/AddTenantSequenceSite.cs @@ -24,6 +24,10 @@ public class AddTenantSequenceSite : PSCmdlet protected override void ProcessRecord() { + if (MyInvocation.InvocationName.ToLower() == "add-pnpprovisioningsite") + { + WriteWarning("Add-PnPProvisioningSite has been deprecated. Use Add-PnPTenantSequenceSite instead."); + } Sequence.SiteCollections.Add(Site.Site); WriteObject(Sequence); } diff --git a/Commands/Provisioning/Tenant/AddTenantSequenceSubSite.cs b/Commands/Provisioning/Tenant/AddTenantSequenceSubSite.cs index 558db7642..4b7201cfa 100644 --- a/Commands/Provisioning/Tenant/AddTenantSequenceSubSite.cs +++ b/Commands/Provisioning/Tenant/AddTenantSequenceSubSite.cs @@ -25,6 +25,11 @@ public class AddTenantSequenceSubSite : PSCmdlet protected override void ProcessRecord() { + if (MyInvocation.InvocationName.ToLower() == "add-pnpprovisioningsubsite") + { + WriteWarning("Add-PnPProvisioningSubSite has been deprecated. Use Add-PnPTenantSequenceSubSite instead."); + } + if (Site.Sites.Cast().FirstOrDefault(s => s.Url == SubSite.Url) == null) { Site.Sites.Add(SubSite); diff --git a/Commands/Provisioning/Tenant/ApplyTenantTemplate.cs b/Commands/Provisioning/Tenant/ApplyTenantTemplate.cs index 504dec6c1..c1ef23888 100644 --- a/Commands/Provisioning/Tenant/ApplyTenantTemplate.cs +++ b/Commands/Provisioning/Tenant/ApplyTenantTemplate.cs @@ -86,6 +86,11 @@ public class ApplyTenantTemplate : PnPAdminCmdlet protected override void ExecuteCmdlet() { + if (MyInvocation.InvocationName.ToLower() == "apply-pnpprovisioninghierarchy") + { + WriteWarning("Apply-PnPProvisioningHierarchy has been deprecated. Use Apply-PnPTenantTemplate instead."); + } + var applyingInformation = new ProvisioningTemplateApplyingInformation(); if (MyInvocation.BoundParameters.ContainsKey("Handlers")) diff --git a/Commands/Provisioning/Tenant/GetTenantSequence.cs b/Commands/Provisioning/Tenant/GetTenantSequence.cs index 2475a6aff..2c5e16080 100644 --- a/Commands/Provisioning/Tenant/GetTenantSequence.cs +++ b/Commands/Provisioning/Tenant/GetTenantSequence.cs @@ -27,6 +27,11 @@ public class GetTenantSequence : PSCmdlet public ProvisioningSequencePipeBind Identity; protected override void ProcessRecord() { + + if (MyInvocation.InvocationName.ToLower() == "get-pnpprovisioningsequence") + { + WriteWarning("Get-PnPProvisioningSequence has been deprecated. Use Get-PnPTenantSequence instead."); + } if (!MyInvocation.BoundParameters.ContainsKey("Identity")) { WriteObject(Template.Sequences, true); diff --git a/Commands/Provisioning/Tenant/GetTenantSequenceSite.cs b/Commands/Provisioning/Tenant/GetTenantSequenceSite.cs index 646659f1e..3dacb1758 100644 --- a/Commands/Provisioning/Tenant/GetTenantSequenceSite.cs +++ b/Commands/Provisioning/Tenant/GetTenantSequenceSite.cs @@ -27,6 +27,11 @@ public class GetTenantSequenceSite : PSCmdlet public ProvisioningSitePipeBind Identity; protected override void ProcessRecord() { + if (MyInvocation.InvocationName.ToLower() == "get-pnpprovisioningsite") + { + WriteWarning("Get-PnPProvisioningSite has been deprecated. Use Get-PnPTenantSequenceSite instead."); + } + if (!MyInvocation.BoundParameters.ContainsKey("Identity")) { WriteObject(Sequence.SiteCollections, true); diff --git a/Commands/Provisioning/Tenant/NewTenantSequence.cs b/Commands/Provisioning/Tenant/NewTenantSequence.cs index d6e65f792..637872131 100644 --- a/Commands/Provisioning/Tenant/NewTenantSequence.cs +++ b/Commands/Provisioning/Tenant/NewTenantSequence.cs @@ -24,6 +24,11 @@ public class NewTenantSequence : PSCmdlet public string Id; protected override void ProcessRecord() { + if (MyInvocation.InvocationName.ToLower() == "new-pnpprovisioningsequence") + { + WriteWarning("New-PnPProvisioningSequence has been deprecated. Use New-PnPTenantSequence instead."); + } + var result = new ProvisioningSequence(); if (this.MyInvocation.BoundParameters.ContainsKey("Id")) { diff --git a/Commands/Provisioning/Tenant/NewTenantSequenceCommunicationSite.cs b/Commands/Provisioning/Tenant/NewTenantSequenceCommunicationSite.cs index e9b5df5da..88ff3691e 100644 --- a/Commands/Provisioning/Tenant/NewTenantSequenceCommunicationSite.cs +++ b/Commands/Provisioning/Tenant/NewTenantSequenceCommunicationSite.cs @@ -48,6 +48,11 @@ public class NewTenantSequenceCommunicationSite : PSCmdlet protected override void ProcessRecord() { + if (MyInvocation.InvocationName.ToLower() == "new-pnpprovisioningcommunicationsite") + { + WriteWarning("New-PnPProvisioningCommunicationSite has been deprecated. Use New-PnPTenantSequenceCommunicationSite instead."); + } + var site = new CommunicationSiteCollection { Url = Url, diff --git a/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSite.cs b/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSite.cs index bcc487db4..3e61f9dc6 100644 --- a/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSite.cs +++ b/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSite.cs @@ -42,6 +42,11 @@ public class NewTenantSequenceTeamNoGroupSite : PSCmdlet protected override void ProcessRecord() { + if (MyInvocation.InvocationName.ToLower() == "new-pnpprovisioningteamnogroupsite") + { + WriteWarning("New-PnPProvisioningTeamNoGroupSite has been deprecated. Use New-PnPTenantSequenceTeamNoGroupSite instead."); + } + var site = new TeamNoGroupSiteCollection { Url = Url, diff --git a/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSubSite.cs b/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSubSite.cs index b11b56042..942311464 100644 --- a/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSubSite.cs +++ b/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSubSite.cs @@ -43,6 +43,11 @@ public class NewTenantSequenceTeamNoGroupSubSite : PSCmdlet protected override void ProcessRecord() { + if (MyInvocation.InvocationName.ToLower() == "new-pnpprovisioningteamnogroupsubsite") + { + WriteWarning("New-PnPProvisioningTeamNoGroupSubSite has been deprecated. Use New-PnPTenantSequenceTeamNoGroupSubSite instead."); + } + SiteCollection c; var site = new TeamNoGroupSubSite() { diff --git a/Commands/Provisioning/Tenant/NewTenantSequenceTeamSite.cs b/Commands/Provisioning/Tenant/NewTenantSequenceTeamSite.cs index c86c524b0..b889aa8cc 100644 --- a/Commands/Provisioning/Tenant/NewTenantSequenceTeamSite.cs +++ b/Commands/Provisioning/Tenant/NewTenantSequenceTeamSite.cs @@ -43,6 +43,11 @@ public class NewTenantSequenceTeamSite : PSCmdlet protected override void ProcessRecord() { + if (MyInvocation.InvocationName.ToLower() == "new-pnpprovisioningcommunicationsite") + { + WriteWarning("New-PnPProvisioningCommunicationSite has been deprecated. Use New-PnPTenantSequenceCommunicationSite instead."); + } + var site = new TeamSiteCollection { Alias = Alias, diff --git a/Commands/Provisioning/Tenant/NewTenantTemplate.cs b/Commands/Provisioning/Tenant/NewTenantTemplate.cs index 6c901965c..43c557dcb 100644 --- a/Commands/Provisioning/Tenant/NewTenantTemplate.cs +++ b/Commands/Provisioning/Tenant/NewTenantTemplate.cs @@ -29,6 +29,10 @@ public class NewTenantTemplate : PSCmdlet protected override void ProcessRecord() { + if (MyInvocation.InvocationName.ToLower() == "new-pnpprovisioninghierarchy") + { + WriteWarning("New-PnPProvisioningHierarchy has been deprecated. Use New-PnPTenantTemplate instead."); + } var result = new ProvisioningHierarchy(); result.Author = Author; result.Description = Description; diff --git a/Commands/Provisioning/Tenant/ReadTenantTemplate.cs b/Commands/Provisioning/Tenant/ReadTenantTemplate.cs index b0d699062..25e0c5cb8 100644 --- a/Commands/Provisioning/Tenant/ReadTenantTemplate.cs +++ b/Commands/Provisioning/Tenant/ReadTenantTemplate.cs @@ -29,6 +29,11 @@ public class ReadTenantTemplate : PSCmdlet protected override void ProcessRecord() { + if (MyInvocation.InvocationName.ToLower() == "read-pnpprovisioninghierarchy") + { + WriteWarning("Read-PnPProvisioningHierarchy has been deprecated. Use Read-PnPTenantTemplate instead."); + } + if (!System.IO.Path.IsPathRooted(Path)) { Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path); diff --git a/Commands/Provisioning/Tenant/SaveTenantTemplate.cs b/Commands/Provisioning/Tenant/SaveTenantTemplate.cs index b2eb42636..e22ef83ca 100644 --- a/Commands/Provisioning/Tenant/SaveTenantTemplate.cs +++ b/Commands/Provisioning/Tenant/SaveTenantTemplate.cs @@ -33,6 +33,10 @@ public class SaveTenantTemplate : PSCmdlet protected override void ProcessRecord() { + if (MyInvocation.InvocationName.ToLower() == "save-pnpprovisioninghierarchy") + { + WriteWarning("Save-PnPProvisioningHierarchy has been deprecated. Use Save-PnPTenantTemplate instead."); + } // Determine the output file name and path string outFileName = Path.GetFileName(Out); diff --git a/Commands/Provisioning/Tenant/TestTenantTemplate.cs b/Commands/Provisioning/Tenant/TestTenantTemplate.cs index c92c37cab..3ace7cb30 100644 --- a/Commands/Provisioning/Tenant/TestTenantTemplate.cs +++ b/Commands/Provisioning/Tenant/TestTenantTemplate.cs @@ -23,6 +23,10 @@ public class TestTenantTemplate : PnPCmdlet protected override void ExecuteCmdlet() { + if (MyInvocation.InvocationName.ToLower() == "test-pnpprovisioninghierarchy") + { + WriteWarning("Test-PnPProvisioningHierarchy has been deprecated. Use Test-PnPTenantTemplate instead."); + } List issues = new List(); foreach(var sequence in Template.Sequences) { From e5a39c33d401eefa02a626a450c4883d640e3943 Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Thu, 8 Nov 2018 00:08:55 +0100 Subject: [PATCH 18/30] Revert "Removing code sample from removed parameter" This reverts commit 960c87d44a93af0b9b24c956406fd7a853c0dc17. --- Commands/Site/SetSite.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Commands/Site/SetSite.cs b/Commands/Site/SetSite.cs index e88985b76..32f6319a1 100644 --- a/Commands/Site/SetSite.cs +++ b/Commands/Site/SetSite.cs @@ -32,6 +32,10 @@ namespace SharePointPnP.PowerShell.Commands.Site Code = @"PS:> Set-PnPSite -DisableFlows:$false", Remarks = "Enables Flows for this site", SortOrder = 3)] + [CmdletExample( + Code = @"PS:> Set-PnPSite -SiteLogoPath c:\images\mylogo.png", + Remarks = "Sets the logo if the site is a modern team site", + SortOrder = 4)] public class SetSite : PnPCmdlet { From 3a4e51d27bbab923f09c0d8d680db5f04c49f3e6 Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Thu, 8 Nov 2018 09:59:54 +0100 Subject: [PATCH 19/30] Added additional documentation around using Grant-PnPHubSiteRights --- Commands/Admin/GrantHubSiteRights.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Commands/Admin/GrantHubSiteRights.cs b/Commands/Admin/GrantHubSiteRights.cs index a514cc949..6aa9a78c6 100644 --- a/Commands/Admin/GrantHubSiteRights.cs +++ b/Commands/Admin/GrantHubSiteRights.cs @@ -4,26 +4,26 @@ using SharePointPnP.PowerShell.CmdletHelpAttributes; using SharePointPnP.PowerShell.Commands.Base; using SharePointPnP.PowerShell.Commands.Base.PipeBinds; -using System; using System.Management.Automation; namespace SharePointPnP.PowerShell.Commands.Admin { [Cmdlet(VerbsSecurity.Grant, "PnPHubSiteRights")] - [CmdletHelp(@"Grant Permissions to associate sites to Hub Sites.", + [CmdletHelp(@"Grant Permissions to associate sites to Hub Sites for one or more specific users", Category = CmdletHelpCategory.TenantAdmin, SupportedPlatform = CmdletSupportedPlatform.Online)] - [CmdletExample(Code = @"PS:> Grant-PnPHubSiteRights -Identity https://contoso.sharepoint.com/sites/hubsite -Principals ""myuser@mydomain.com"",""myotheruser@mydomain.com"" -Rights Join", Remarks = "This example shows how to grant right to myuser and myotheruser to associate their sites with hubsite", SortOrder = 1)] + [CmdletExample(Code = @"PS:> Grant-PnPHubSiteRights -Identity https://contoso.sharepoint.com/sites/hubsite -Principals ""myuser@mydomain.com"",""myotheruser@mydomain.com"" -Rights Join", Remarks = "This example shows how to grant rights to myuser and myotheruser to associate their sites with the provided Hub Site", SortOrder = 1)] + [CmdletExample(Code = @"PS:> Grant-PnPHubSiteRights -Identity https://contoso.sharepoint.com/sites/hubsite -Principals ""myuser@mydomain.com"" -Rights None", Remarks = "This example shows how to revoke rights from myuser to associate their sites with the provided Hub Site", SortOrder = 2)] public class GrantHubSiteRights : PnPAdminCmdlet { - [Parameter(Position = 0, ValueFromPipeline = true, Mandatory = true)] + [Parameter(Position = 0, ValueFromPipeline = true, Mandatory = true, HelpMessage = "The Hub Site to set the permissions on to associate another site with this Hub Site")] [Alias("HubSite")] public HubSitePipeBind Identity { get; set; } - [Parameter(Mandatory = true)] + [Parameter(Mandatory = true, HelpMessage = "One or more usernames that will be given or revoked the permission to associate a site with this Hub Site")] public string[] Principals { get; set; } - [Parameter(Mandatory = true)] + [Parameter(Mandatory = true, HelpMessage = "Provide Join to give permissions to associate a site with this Hub Site or use None to revoke the permissions for the user(s) specified with the Principals argument")] public SPOHubSiteUserRights Rights { get; set; } protected override void ExecuteCmdlet() From 0a6d1a67bd1ad685f4af322849861f4600d55a0c Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Thu, 8 Nov 2018 10:07:49 +0100 Subject: [PATCH 20/30] Extra clarification that permissions are added to existing permissions and do not overwrite what has been set before --- Commands/Admin/GrantHubSiteRights.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Commands/Admin/GrantHubSiteRights.cs b/Commands/Admin/GrantHubSiteRights.cs index 6aa9a78c6..796da63aa 100644 --- a/Commands/Admin/GrantHubSiteRights.cs +++ b/Commands/Admin/GrantHubSiteRights.cs @@ -9,7 +9,7 @@ namespace SharePointPnP.PowerShell.Commands.Admin { [Cmdlet(VerbsSecurity.Grant, "PnPHubSiteRights")] - [CmdletHelp(@"Grant Permissions to associate sites to Hub Sites for one or more specific users", + [CmdletHelp(@"Grant additional permissions to the permissions already in place to associate sites to Hub Sites for one or more specific users", Category = CmdletHelpCategory.TenantAdmin, SupportedPlatform = CmdletSupportedPlatform.Online)] [CmdletExample(Code = @"PS:> Grant-PnPHubSiteRights -Identity https://contoso.sharepoint.com/sites/hubsite -Principals ""myuser@mydomain.com"",""myotheruser@mydomain.com"" -Rights Join", Remarks = "This example shows how to grant rights to myuser and myotheruser to associate their sites with the provided Hub Site", SortOrder = 1)] @@ -20,7 +20,7 @@ public class GrantHubSiteRights : PnPAdminCmdlet [Alias("HubSite")] public HubSitePipeBind Identity { get; set; } - [Parameter(Mandatory = true, HelpMessage = "One or more usernames that will be given or revoked the permission to associate a site with this Hub Site")] + [Parameter(Mandatory = true, HelpMessage = "One or more usernames that will be given or revoked the permission to associate a site with this Hub Site. It does not replace permissions given out before but adds to the already existing permissions.")] public string[] Principals { get; set; } [Parameter(Mandatory = true, HelpMessage = "Provide Join to give permissions to associate a site with this Hub Site or use None to revoke the permissions for the user(s) specified with the Principals argument")] From 9fc7755bfa0f0dabdab40fc6d62d91b736dc4d6b Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Thu, 8 Nov 2018 10:10:25 +0100 Subject: [PATCH 21/30] Updated OData related nuget packages --- .../SharePointPnP.PowerShell.Commands.csproj | 16 ++++++++-------- Commands/app.config | 12 ++++++++++++ Commands/packages.config | 8 ++++---- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Commands/SharePointPnP.PowerShell.Commands.csproj b/Commands/SharePointPnP.PowerShell.Commands.csproj index 3891248b9..a66dc5503 100644 --- a/Commands/SharePointPnP.PowerShell.Commands.csproj +++ b/Commands/SharePointPnP.PowerShell.Commands.csproj @@ -303,14 +303,14 @@ ..\packages\Microsoft.ApplicationInsights.2.5.1\lib\net45\Microsoft.ApplicationInsights.dll - - ..\packages\Microsoft.Data.Edm.5.6.2\lib\net40\Microsoft.Data.Edm.dll + + ..\packages\Microsoft.Data.Edm.5.8.4\lib\net40\Microsoft.Data.Edm.dll - - ..\packages\Microsoft.Data.OData.5.6.2\lib\net40\Microsoft.Data.OData.dll + + ..\packages\Microsoft.Data.OData.5.8.4\lib\net40\Microsoft.Data.OData.dll - - ..\packages\Microsoft.Data.Services.Client.5.6.2\lib\net40\Microsoft.Data.Services.Client.dll + + ..\packages\Microsoft.Data.Services.Client.5.8.4\lib\net40\Microsoft.Data.Services.Client.dll ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.1.0.0\lib\netstandard1.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll @@ -401,8 +401,8 @@ - - ..\packages\System.Spatial.5.6.2\lib\net40\System.Spatial.dll + + ..\packages\System.Spatial.5.8.4\lib\net40\System.Spatial.dll ..\packages\System.Text.Encodings.Web.4.0.0\lib\netstandard1.0\System.Text.Encodings.Web.dll diff --git a/Commands/app.config b/Commands/app.config index 286872ee0..752055dfe 100644 --- a/Commands/app.config +++ b/Commands/app.config @@ -54,6 +54,18 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/Commands/packages.config b/Commands/packages.config index 19f91682b..5294fe07f 100644 --- a/Commands/packages.config +++ b/Commands/packages.config @@ -5,9 +5,9 @@ - - - + + + @@ -36,7 +36,7 @@ - + From daad8dba14f21665d451878b7a57420e7d79c924 Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Thu, 8 Nov 2018 10:16:32 +0100 Subject: [PATCH 22/30] changelog update --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d5a0ebf8..0dcd9c412 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Changed - Updated New-PnPSite to support language/locale for new sites. - Updated documentation for New-PnPTenantSite -- Fixed documentation for Measure-PnPWeb +- Fixed documentation for Measure-PnPWeb, Set-PnPSite - Updated samples - Fixes issue with Set-PnPUnifiedGroup where if you only change for instance the displayname a private group would be marked as public. - Renamed (and created aliases for the old cmdlet name) Apply-PnPProvisioningHierarchy to Apply-PnPTenantTemplate From 15ac31aa0800e55895b688cc5220046034fa6b91 Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Thu, 8 Nov 2018 11:21:54 +0100 Subject: [PATCH 23/30] Added -IncludeModernSites switch to Get-PnPTenantRecycleBinItem to also include modern sites in the tenant scoped recycle bin. Without it, it will only return classic sites being in the tenant scoped recycle bin --- Commands/RecycleBin/GetTenantRecycleBinItem.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Commands/RecycleBin/GetTenantRecycleBinItem.cs b/Commands/RecycleBin/GetTenantRecycleBinItem.cs index 1d0134162..20259f42a 100644 --- a/Commands/RecycleBin/GetTenantRecycleBinItem.cs +++ b/Commands/RecycleBin/GetTenantRecycleBinItem.cs @@ -16,13 +16,20 @@ namespace SharePointPnP.PowerShell.Commands.RecycleBin OutputTypeLink = "https://msdn.microsoft.com/en-us/library/microsoft.online.sharepoint.tenantadministration.deletedsiteproperties.aspx")] [CmdletExample( Code = @"PS:> Get-PnPTenantRecycleBinItem", - Remarks = "Returns all site collections in the tenant scoped recycle bin", + Remarks = "Returns all classic site collections in the tenant scoped recycle bin", SortOrder = 1)] + [CmdletExample( + Code = @"PS:> Get-PnPTenantRecycleBinItem -IncludeModernSites", + Remarks = "Returns all modern and classic site collections in the tenant scoped recycle bin", + SortOrder = 2)] public class GetTenantRecycleBinItems : PnPAdminCmdlet { + [Parameter(Mandatory = false, HelpMessage = "If provided, it will also return all Modern Sites next to the classic sites that have been deleted and are in the tenant scoped recycle bin")] + public SwitchParameter IncludeModernSites; + protected override void ExecuteCmdlet() { - var deletedSites = Tenant.GetDeletedSiteProperties(0); + var deletedSites = IncludeModernSites ? Tenant.GetDeletedSitePropertiesFromSharePoint("0") : Tenant.GetDeletedSiteProperties(0); ClientContext.Load(deletedSites, c => c.IncludeWithDefaultProperties(s => s.Url, s => s.SiteId, s => s.DaysRemaining, s => s.Status)); ClientContext.ExecuteQueryRetry(); if (deletedSites.AreItemsAvailable) From 8e12da3c54d30e69ad0f9c661176519ac5cddb5e Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Thu, 8 Nov 2018 12:16:16 +0100 Subject: [PATCH 24/30] Manual merge of PR #1053 and test updates --- Commands/Files/CopyFile.cs | 17 ++-- Tests/FilesTest.cs | 197 ++++++++++++++++--------------------- Tests/PSTestScope.cs | 55 +++++++++++ Tests/TestCommon.cs | 11 ++- 4 files changed, 156 insertions(+), 124 deletions(-) diff --git a/Commands/Files/CopyFile.cs b/Commands/Files/CopyFile.cs index 605d28175..35010b1e7 100644 --- a/Commands/Files/CopyFile.cs +++ b/Commands/Files/CopyFile.cs @@ -255,13 +255,16 @@ private void UploadFile(File srcFile, Folder targetFolder, string filename = "") { var binaryStream = srcFile.OpenBinaryStream(); _sourceContext.ExecuteQueryRetry(); - if (string.IsNullOrWhiteSpace(filename)) filename = srcFile.Name; - this.UploadFileWithInvalidCharacters(targetFolder, filename, binaryStream.Value, OverwriteIfAlreadyExists); + if (string.IsNullOrWhiteSpace(filename)) + { + filename = srcFile.Name; + } + this.UploadFileWithSpecialCharacters(targetFolder, filename, binaryStream.Value, OverwriteIfAlreadyExists); _targetContext.ExecuteQueryRetry(); } - private File UploadFileWithInvalidCharacters(Folder folder, string fileName, System.IO.Stream stream, bool overwriteIfExists) + private File UploadFileWithSpecialCharacters(Folder folder, string fileName, System.IO.Stream stream, bool overwriteIfExists) { if (fileName == null) { @@ -277,13 +280,7 @@ private File UploadFileWithInvalidCharacters(Folder folder, string fileName, Sys { throw new ArgumentException("Filename is required"); } - /* - if (Regex.IsMatch(fileName, REGEX_INVALID_FILE_NAME_CHARS)) - { - throw new ArgumentException(CoreResources.FileFolderExtensions_UploadFile_The_argument_must_be_a_single_file_name_and_cannot_contain_path_characters_, nameof(fileName)); - } - */ - + // Create the file var newFileInfo = new FileCreationInformation() { diff --git a/Tests/FilesTest.cs b/Tests/FilesTest.cs index 379546b82..2bf24a234 100644 --- a/Tests/FilesTest.cs +++ b/Tests/FilesTest.cs @@ -1,17 +1,22 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +#if !ONPREMISES +using Microsoft.Online.SharePoint.TenantAdministration; using Microsoft.SharePoint.Client; -using System.Management.Automation.Runspaces; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; using System.Collections; using System.Linq; -using System.Management.Automation; -using System.Text; +using System.Management.Automation.Runspaces; namespace SharePointPnP.PowerShell.Tests { [TestClass] public class FilesTests { + private string site1Id; + private string site2Id; + private string site1Url; + private string site2Url; + private const string targetLibraryRelativeUrl = "/sites/dev/Shared%20Documents"; private const string targetLibraryName = "Documents"; private const string targetLibraryDesc = "Documents library for Files testing"; @@ -24,115 +29,74 @@ public class FilesTests [TestInitialize] public void Initialize() { - //With thanks to Paolo Pialorsi https://piasys.com/blog/uploading-a-file-into-a-library-via-csom-even-if-the-library-does-not-exist/ using (var ctx = TestCommon.CreateClientContext()) { - ExceptionHandlingScope scope = new ExceptionHandlingScope(ctx); - using (scope.StartScope()) + site1Id = Guid.NewGuid().ToString(); + site2Id = Guid.NewGuid().ToString(); + + site1Url = $"{TestCommon.GetTenantRootUrl(ctx)}/sites/PNPPS_Test_{site1Id}"; + site2Url = $"{TestCommon.GetTenantRootUrl(ctx)}/sites/PNPPS_Test_{site2Id}"; + + using (var site1Ctx = OfficeDevPnP.Core.Sites.SiteCollection.CreateAsync(ctx, new OfficeDevPnP.Core.Sites.CommunicationSiteCollectionCreationInformation() { - using (scope.StartTry()) - { - Folder folder = ctx.Web.GetFolderByServerRelativeUrl(targetLibraryRelativeUrl); - } - using (scope.StartCatch()) - { - // Create the library, in case it doesn’t exist - ListCreationInformation lci = new ListCreationInformation(); - lci.Title = targetLibraryName; - lci.Description = targetLibraryDesc; - lci.TemplateType = (Int32)ListTemplateType.DocumentLibrary; - lci.QuickLaunchOption = QuickLaunchOptions.On; - List library = ctx.Web.Lists.Add(lci); - } - using (scope.StartFinally()) + Url = site1Url, + Lcid = 1033, + Title = "PnP PowerShell File Copy Test Site 1" + }).GetAwaiter().GetResult()) + { + site1Ctx.Web.EnsureProperty(w => w.ServerRelativeUrl); + Folder folder = site1Ctx.Web.GetFolderByServerRelativeUrl($"{site1Ctx.Web.ServerRelativeUrl}/Shared%20Documents"); + FileCreationInformation fci = new FileCreationInformation { - Folder folder = ctx.Web.GetFolderByServerRelativeUrl(targetLibraryRelativeUrl); - FileCreationInformation fci = new FileCreationInformation(); - fci.Content = Encoding.ASCII.GetBytes(targetFileContents); - fci.Url = targetFileName; - fci.Overwrite = true; - File fileToUpload = folder.Files.Add(fci); - ctx.Load(fileToUpload); - - fci.Url = targetFileNameWithAmpersand; - fci.Overwrite = true; - fileToUpload = folder.Files.Add(fci); - ctx.Load(fileToUpload); + Content = System.Text.Encoding.ASCII.GetBytes(targetFileContents), + Url = targetFileName, + Overwrite = true + }; + File fileToUpload = folder.Files.Add(fci); + site1Ctx.Load(fileToUpload); + fci.Url = targetFileNameWithAmpersand; + fci.Overwrite = true; + fileToUpload = folder.Files.Add(fci); + site1Ctx.Load(fileToUpload); + site1Ctx.ExecuteQueryRetry(); + + folder.EnsureFolder(targetCopyFolderName); - folder.Folders.Add(targetCopyFolderName); - } } - ctx.ExecuteQuery(); + OfficeDevPnP.Core.Sites.SiteCollection.CreateAsync(ctx, new OfficeDevPnP.Core.Sites.CommunicationSiteCollectionCreationInformation() + { + Url = site2Url, + Lcid = 1033, + Title = "PnP PowerShell File Copy Test Site 2" + }).GetAwaiter().GetResult(); } } - + [TestCleanup] public void Cleanup() { - using (var ctx = TestCommon.CreateClientContext()) - { - ExceptionHandlingScope scope = new ExceptionHandlingScope(ctx); - using (scope.StartScope()) - { - using (scope.StartTry()) - { - File initialFile = ctx.Web.GetFileByServerRelativeUrl(targetLibraryRelativeUrl + "/" + targetFileName); - if (initialFile != null) - { - initialFile.DeleteObject(); - } - Folder copyFolder = ctx.Web.GetFolderByServerRelativeUrl(targetLibraryRelativeUrl + "/" + targetCopyFolderName); - if (copyFolder != null) - { - copyFolder.DeleteObject(); - } - } - using (scope.StartCatch()) - { - // Ignore as file not created or already deleted - } - } - ctx.ExecuteQuery(); - } - using (var ctx = TestCommon.CreateClientContextDev2()) + using (var ctx = TestCommon.CreateTenantClientContext()) { - ExceptionHandlingScope scope = new ExceptionHandlingScope(ctx); - using (scope.StartScope()) - { - using (scope.StartTry()) - { - File initialFile = ctx.Web.GetFileByServerRelativeUrl(targetSite2LibraryRelativeUrl + "/" + targetFileName); - if (initialFile != null) - { - initialFile.DeleteObject(); - } - File ampersandFile = ctx.Web.GetFileByServerRelativeUrl(targetSite2LibraryRelativeUrl + "/" + targetFileNameWithAmpersand); - if (ampersandFile != null) - { - ampersandFile.DeleteObject(); - } - } - using (scope.StartCatch()) - { - // Ignore as file not created or already deleted - } - } - ctx.ExecuteQuery(); + Tenant tenant = new Tenant(ctx); + tenant.DeleteSiteCollection(site1Url, false); + tenant.DeleteSiteCollection(site2Url, false); } } [TestMethod] public void GetFile_AsListItem_Test() { - using (var scope = new PSTestScope(true)) + using (var scope = new PSTestScope(site1Url, true)) { + var siteRelativeFolderUrl = $"/sites/PNPPS_Test_{site1Id}/Shared%20Documents"; + var values = new Hashtable(); values.Add("Title", "Test"); //Get-PnPFile -Url /sites/project/_catalogs/themes/15/company.spcolor -AsFile", var results = scope.ExecuteCommand("Get-PnPFile", - new CommandParameter("Url", System.IO.Path.Combine(targetLibraryRelativeUrl,targetFileName)), + new CommandParameter("Url", $"{siteRelativeFolderUrl}/{targetFileName}"), new CommandParameter("AsListItem")); Assert.IsTrue(results.Any()); @@ -144,10 +108,12 @@ public void GetFile_AsListItem_Test() [TestMethod] public void GetFile_AsFile_Test() { - using (var scope = new PSTestScope(true)) + using (var scope = new PSTestScope(site1Url, true)) { + var siteRelativeFolderUrl = $"/sites/PNPPS_Test_{site1Id}/Shared%20Documents"; + var results = scope.ExecuteCommand("Get-PnPFile", - new CommandParameter("Url", System.IO.Path.Combine(targetLibraryRelativeUrl, targetFileName)), + new CommandParameter("Url", $"{siteRelativeFolderUrl}/{targetFileName}"), new CommandParameter("AsFile")); Assert.IsTrue(results.Any()); @@ -159,19 +125,24 @@ public void GetFile_AsFile_Test() [TestMethod] public void CopyFileTest() { - using (var scope = new PSTestScope(true)) + using (var scope = new PSTestScope(site1Url, true)) { - string sourceUrl = targetLibraryRelativeUrl + "/" + targetFileName; - string destinationUrl = targetLibraryRelativeUrl + "/" + targetCopyFolderName + "/" + targetFileName; + var sourceUrl = $"/sites/PNPPS_Test_{site1Id}/Shared%20Documents/{targetFileName}"; + + var destinationUrl = $"/sites/PNPPS_Test_{site1Id}/Shared%20Documents/{targetCopyFolderName}"; + var results = scope.ExecuteCommand("Copy-PnPFile", new CommandParameter("SourceUrl", sourceUrl), new CommandParameter("TargetUrl", destinationUrl), new CommandParameter("Force")); - using (var ctx = TestCommon.CreateClientContext()) + + using (var ctx = TestCommon.CreateClientContext(site1Url)) { File initialFile = ctx.Web.GetFileByServerRelativeUrl(destinationUrl); - if (initialFile == null) + ctx.Load(initialFile); + ctx.ExecuteQueryRetry(); + if (!initialFile.Exists) { Assert.Fail("Copied file cannot be found"); } @@ -182,19 +153,22 @@ public void CopyFileTest() [TestMethod] public void CopyFile_WithAmpersand_Test() { - using (var scope = new PSTestScope(true)) + using (var scope = new PSTestScope(site1Url, true)) { - string sourceUrl = targetLibraryRelativeUrl + "/" + targetFileNameWithAmpersand; - string destinationUrl = targetLibraryRelativeUrl + "/" + targetCopyFolderName + "/" + targetFileNameWithAmpersand; + var sourceUrl = $"/sites/PNPPS_Test_{site1Id}/Shared%20Documents/{targetFileNameWithAmpersand}"; + var destinationUrl = $"/sites/PNPPS_Test_{site1Id}/Shared%20Documents/{targetCopyFolderName}"; + var results = scope.ExecuteCommand("Copy-PnPFile", new CommandParameter("SourceUrl", sourceUrl), new CommandParameter("TargetUrl", destinationUrl), new CommandParameter("Force")); - using (var ctx = TestCommon.CreateClientContext()) + using (var ctx = TestCommon.CreateClientContext(site1Url)) { File initialFile = ctx.Web.GetFileByServerRelativeUrl(destinationUrl); - if (initialFile == null) + ctx.Load(initialFile); + ctx.ExecuteQueryRetry(); + if (!initialFile.Exists) { Assert.Fail("Copied file cannot be found"); } @@ -205,17 +179,17 @@ public void CopyFile_WithAmpersand_Test() [TestMethod] public void CopyFile_BetweenSiteCollections_Test() { - using (var scope = new PSTestScope(true)) + using (var scope = new PSTestScope(site1Url, true)) { - string sourceUrl = targetLibraryRelativeUrl + "/" + targetFileName; - string destinationFolderUrl = targetSite2LibraryRelativeUrl; - string destinationFileUrl = targetSite2LibraryRelativeUrl + "/" + targetFileName; + var sourceUrl = $"/sites/PNPPS_Test_{site1Id}/Shared%20Documents/{targetFileName}"; + var destinationFolderUrl = $"/sites/PNPPS_Test_{site2Id}/Shared%20Documents"; + string destinationFileUrl = $"/sites/PNPPS_Test_{site2Id}/Shared%20Documents/{targetFileName}"; var results = scope.ExecuteCommand("Copy-PnPFile", new CommandParameter("SourceUrl", sourceUrl), new CommandParameter("TargetUrl", destinationFolderUrl), new CommandParameter("Force")); - using (var ctx = TestCommon.CreateClientContextDev2()) + using (var ctx = TestCommon.CreateClientContext(site2Url)) { File initialFile = ctx.Web.GetFileByServerRelativeUrl(destinationFileUrl); ctx.Load(initialFile); @@ -231,17 +205,17 @@ public void CopyFile_BetweenSiteCollections_Test() [TestMethod] public void CopyFile_BetweenSiteCollectionsWithAmpersand_Test() { - using (var scope = new PSTestScope(true)) + using (var scope = new PSTestScope(site1Url, true)) { - string sourceUrl = targetLibraryRelativeUrl + "/" + targetFileNameWithAmpersand; - string destinationFolderUrl = targetSite2LibraryRelativeUrl; - string destinationFileUrl = targetSite2LibraryRelativeUrl + "/" + targetFileNameWithAmpersand; + var sourceUrl = $"/sites/PNPPS_Test_{site1Id}/Shared%20Documents/{targetFileNameWithAmpersand}"; + var destinationFolderUrl = $"/sites/PNPPS_Test_{site2Id}/Shared%20Documents"; + string destinationFileUrl = $"/sites/PNPPS_Test_{site2Id}/Shared%20Documents/{targetFileNameWithAmpersand}"; var results = scope.ExecuteCommand("Copy-PnPFile", new CommandParameter("SourceUrl", sourceUrl), new CommandParameter("TargetUrl", destinationFolderUrl), new CommandParameter("Force")); - using (var ctx = TestCommon.CreateClientContextDev2()) + using (var ctx = TestCommon.CreateClientContext(site2Url)) { File initialFile = ctx.Web.GetFileByServerRelativeUrl(destinationFileUrl); ctx.Load(initialFile); @@ -255,3 +229,4 @@ public void CopyFile_BetweenSiteCollectionsWithAmpersand_Test() } } } +#endif \ No newline at end of file diff --git a/Tests/PSTestScope.cs b/Tests/PSTestScope.cs index 38ddc4f81..437e60d6c 100644 --- a/Tests/PSTestScope.cs +++ b/Tests/PSTestScope.cs @@ -73,6 +73,61 @@ public PSTestScope(bool connect = true) } } + public PSTestScope(string siteUrl, bool connect = true) + { + SiteUrl = siteUrl; + CredentialManagerEntry = ConfigurationManager.AppSettings["SPOCredentialManagerLabel"]; + Realm = ConfigurationManager.AppSettings["Realm"]; + AppId = ConfigurationManager.AppSettings["AppId"]; + AppSecret = ConfigurationManager.AppSettings["AppSecret"]; + + var iss = InitialSessionState.CreateDefault(); + if (connect) + { + SessionStateCmdletEntry ssce = new SessionStateCmdletEntry("Connect-PnPOnline", typeof(ConnectOnline), null); + + iss.Commands.Add(ssce); + } + _runSpace = RunspaceFactory.CreateRunspace(iss); + + _runSpace.Open(); + + // Sets the execution policy to unrestricted. Requires Visual Studio to run in elevated mode. + var pipeLine = _runSpace.CreatePipeline(); + Command cmd = new Command("Set-ExecutionPolicy"); + cmd.Parameters.Add("ExecutionPolicy", "Unrestricted"); + cmd.Parameters.Add("Scope", "Process"); + pipeLine.Commands.Add(cmd); + pipeLine.Invoke(); + + if (connect) + { + pipeLine = _runSpace.CreatePipeline(); + cmd = new Command("connect-pnponline"); + cmd.Parameters.Add("Url", SiteUrl); + if (!string.IsNullOrEmpty(CredentialManagerEntry)) + { + // Use Windows Credential Manager to authenticate + cmd.Parameters.Add("Credentials", CredentialManagerEntry); + } + else + { + if (!string.IsNullOrEmpty(AppId) && !string.IsNullOrEmpty(AppSecret)) + { + // Use oAuth Token to authenticate + if (!string.IsNullOrEmpty(Realm)) + { + cmd.Parameters.Add("Realm", Realm); + } + cmd.Parameters.Add("AppId", AppId); + cmd.Parameters.Add("AppSecret", AppSecret); + } + } + pipeLine.Commands.Add(cmd); + pipeLine.Invoke(); + } + } + public Collection ExecuteCommand(string cmdletString) { diff --git a/Tests/TestCommon.cs b/Tests/TestCommon.cs index de6f7e135..87eae2a25 100644 --- a/Tests/TestCommon.cs +++ b/Tests/TestCommon.cs @@ -17,7 +17,6 @@ static TestCommon() // Read configuration data TenantUrl = ConfigurationManager.AppSettings["SPOTenantUrl"]; DevSiteUrl = ConfigurationManager.AppSettings["SPODevSiteUrl"]; - Dev2SiteUrl = ConfigurationManager.AppSettings["SPODev2SiteUrl"]; if (string.IsNullOrEmpty(TenantUrl) || string.IsNullOrEmpty(DevSiteUrl)) { @@ -109,9 +108,9 @@ public static ClientContext CreateClientContext() return CreateContext(DevSiteUrl, Credentials); } - public static ClientContext CreateClientContextDev2() + public static ClientContext CreateClientContext(string siteUrl) { - return CreateContext(Dev2SiteUrl, Credentials); + return CreateContext(siteUrl, Credentials); } public static ClientContext CreateTenantClientContext() @@ -175,6 +174,12 @@ private static SecureString GetSecureString(string input) return secureString; } + + public static string GetTenantRootUrl(ClientContext ctx) + { + var uri = new Uri(ctx.Url); + return $"https://{uri.DnsSafeHost}"; + } #endregion } } From e99bc55d8b208890948e679aa6f0c1eb00b830e9 Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Thu, 8 Nov 2018 12:20:52 +0100 Subject: [PATCH 25/30] updated changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dcd9c412..23c894e94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Added ### Changed +- Copy-PnPFile now supports special characters like '&' in file names - Updated New-PnPSite to support language/locale for new sites. - Updated documentation for New-PnPTenantSite - Fixed documentation for Measure-PnPWeb, Set-PnPSite @@ -37,6 +38,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Paul Bullock (pkbullock) - François-Xavier Cat (lazywinadmin) - Koen Zomers (KoenZomers) +- Kevin McDonnell (kevmcdonk) ## [3.2.1810.0] Released ### Added From 22c1c085b916c9bf88c940fea45033ea386db4c5 Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Thu, 8 Nov 2018 18:02:41 +0100 Subject: [PATCH 26/30] Added UseWebLogin option to connect As most SPO tenants these days will use at least MFA, I believe it would be good to show the proper way to connect using PnP PowerShell, being using -UseWebLogin. I've added this in the readme. I had some students in my class this week that were confused by this default option proposed here to connect. --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e7c52809..053645a8e 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,12 @@ To use the library you first need to connect to your tenant: Connect-PnPOnline –Url https://yoursite.sharepoint.com –Credentials (Get-Credential) ``` +Or if you have Multi Factor Authentication enabled or if you are using a federated identity provider like AD FS, instead use: + +```powershell +Connect-PnPOnline –Url https://yoursite.sharepoint.com –UseWebLogin +``` + To view all cmdlets, enter: ```powershell @@ -105,4 +111,4 @@ To debug the cmdlets: launch PowerShell and attach Visual Studio to the powershe This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. - \ No newline at end of file + From c4da5f2654e830c2170470193e2ff874b3e03c30 Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Thu, 8 Nov 2018 18:09:05 +0100 Subject: [PATCH 27/30] Adding mention of the proper SLN file to use Adding mentioning the proper Visual Studio Solution file to be used as discussed via e-mail --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a6e7bfd2b..6cf0de83c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,6 +14,8 @@ Please see following page for additional insights on the model. ## Building the source code ## +Once you have downloaded the code, in the folder with the PnP PowerShell source code, open the solution file SharePointPnP.PowerShell.sln. + If you have set up up the projects and you are ready to build the source code, make sure to build the SharePointPnP.PowerShellModuleFilesGenerator project first. This project will be executed after every build and it will generate the required PSD1 and XML files with cmdlet documentation in them. When you build the solution a postbuild script will copy the required files to a folder in your users folder called @@ -23,7 +25,7 @@ To debug the cmdlets: launch PowerShell and attach Visual Studio to the powershe ## Code contributions In order to succesfully compile the PnP PowerShell solution you will _also_ have to download *and build in Visual Studio* the [PnP-Sites-Core](https://github.com/OfficeDev/PnP-Sites-Core) repository and make the dev branch available. The PowerShell solution depends on it. In order to succesfully -compile it, make sure that PnP-Sites-Core is located at the same level as PnP-PowerShell. +compile it, make sure that PnP-Sites-Core is located at the same level as PnP-PowerShell and you open the solution file OfficeDevPnP.Core.sln located in the Core subfolder of the sourcecode. So: ``` From 308ed48fe5495e0433d1ae1c41c1f86bf2c04ef1 Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Fri, 9 Nov 2018 11:48:40 +0100 Subject: [PATCH 28/30] Removed optional argument as discussed --- Commands/RecycleBin/GetTenantRecycleBinItem.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Commands/RecycleBin/GetTenantRecycleBinItem.cs b/Commands/RecycleBin/GetTenantRecycleBinItem.cs index 20259f42a..4c80c7c34 100644 --- a/Commands/RecycleBin/GetTenantRecycleBinItem.cs +++ b/Commands/RecycleBin/GetTenantRecycleBinItem.cs @@ -8,7 +8,7 @@ namespace SharePointPnP.PowerShell.Commands.RecycleBin { [Cmdlet(VerbsCommon.Get, "PnPTenantRecycleBinItem", DefaultParameterSetName = "All")] - [CmdletHelp("Returns the items in the tenant scoped recycle bin", + [CmdletHelp("Returns all modern and classic site collections in the tenant scoped recycle bin", DetailedDescription = "This command will return all the items in the tenant recycle bin for the Office 365 tenant you are connected to. Be sure to connect to the SharePoint Online Admin endpoint (https://yourtenantname-admin.sharepoint.com) in order for this command to work.", Category = CmdletHelpCategory.RecycleBin, SupportedPlatform = CmdletSupportedPlatform.Online, @@ -16,20 +16,13 @@ namespace SharePointPnP.PowerShell.Commands.RecycleBin OutputTypeLink = "https://msdn.microsoft.com/en-us/library/microsoft.online.sharepoint.tenantadministration.deletedsiteproperties.aspx")] [CmdletExample( Code = @"PS:> Get-PnPTenantRecycleBinItem", - Remarks = "Returns all classic site collections in the tenant scoped recycle bin", - SortOrder = 1)] - [CmdletExample( - Code = @"PS:> Get-PnPTenantRecycleBinItem -IncludeModernSites", Remarks = "Returns all modern and classic site collections in the tenant scoped recycle bin", - SortOrder = 2)] + SortOrder = 1)] public class GetTenantRecycleBinItems : PnPAdminCmdlet { - [Parameter(Mandatory = false, HelpMessage = "If provided, it will also return all Modern Sites next to the classic sites that have been deleted and are in the tenant scoped recycle bin")] - public SwitchParameter IncludeModernSites; - protected override void ExecuteCmdlet() { - var deletedSites = IncludeModernSites ? Tenant.GetDeletedSitePropertiesFromSharePoint("0") : Tenant.GetDeletedSiteProperties(0); + var deletedSites = Tenant.GetDeletedSitePropertiesFromSharePoint("0"); ClientContext.Load(deletedSites, c => c.IncludeWithDefaultProperties(s => s.Url, s => s.SiteId, s => s.DaysRemaining, s => s.Status)); ClientContext.ExecuteQueryRetry(); if (deletedSites.AreItemsAvailable) From 3887612e145b3f16e513d6e2ea4c450a2f1fd913 Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Fri, 9 Nov 2018 11:54:08 +0100 Subject: [PATCH 29/30] suppress deprecated methods, removed unused parameter --- Commands/Provisioning/Site/ConvertProvisioningTemplate.cs | 2 ++ Commands/Provisioning/Site/GetProvisioningTemplate.cs | 2 ++ .../Provisioning/Tenant/NewTenantSequenceTeamNoGroupSubSite.cs | 1 - Commands/Site/SetSite.cs | 3 --- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Commands/Provisioning/Site/ConvertProvisioningTemplate.cs b/Commands/Provisioning/Site/ConvertProvisioningTemplate.cs index f896173f9..c9a056eb3 100644 --- a/Commands/Provisioning/Site/ConvertProvisioningTemplate.cs +++ b/Commands/Provisioning/Site/ConvertProvisioningTemplate.cs @@ -104,7 +104,9 @@ protected override void BeginProcessing() } case XMLPnPSchemaVersion.V201605: { +#pragma warning disable CS0618 // Type or member is obsolete formatter = XMLPnPSchemaFormatter.GetSpecificFormatter(XMLConstants.PROVISIONING_SCHEMA_NAMESPACE_2016_05); +#pragma warning restore CS0618 // Type or member is obsolete break; } case XMLPnPSchemaVersion.V201705: diff --git a/Commands/Provisioning/Site/GetProvisioningTemplate.cs b/Commands/Provisioning/Site/GetProvisioningTemplate.cs index 506c1481f..c0d3fffca 100644 --- a/Commands/Provisioning/Site/GetProvisioningTemplate.cs +++ b/Commands/Provisioning/Site/GetProvisioningTemplate.cs @@ -416,7 +416,9 @@ private void ExtractTemplate(XMLPnPSchemaVersion schema, string path, string pac } case XMLPnPSchemaVersion.V201605: { +#pragma warning disable CS0618 // Type or member is obsolete formatter = XMLPnPSchemaFormatter.GetSpecificFormatter(XMLConstants.PROVISIONING_SCHEMA_NAMESPACE_2016_05); +#pragma warning restore CS0618 // Type or member is obsolete break; } case XMLPnPSchemaVersion.V201705: diff --git a/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSubSite.cs b/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSubSite.cs index 942311464..19b65c1dc 100644 --- a/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSubSite.cs +++ b/Commands/Provisioning/Tenant/NewTenantSequenceTeamNoGroupSubSite.cs @@ -48,7 +48,6 @@ protected override void ProcessRecord() WriteWarning("New-PnPProvisioningTeamNoGroupSubSite has been deprecated. Use New-PnPTenantSequenceTeamNoGroupSubSite instead."); } - SiteCollection c; var site = new TeamNoGroupSubSite() { Url = Url, diff --git a/Commands/Site/SetSite.cs b/Commands/Site/SetSite.cs index 32f6319a1..603fa1207 100644 --- a/Commands/Site/SetSite.cs +++ b/Commands/Site/SetSite.cs @@ -114,9 +114,6 @@ public class SetSite : PnPCmdlet [Parameter(Mandatory = false, HelpMessage = @"Specifies the Geo/Region restrictions of this site.", ParameterSetName = ParameterSet_PROPERTIES)] public RestrictedToRegion? RestrictedToGeo; - [Parameter(Mandatory = false, HelpMessage = @"Specifies a list of email domains that is allowed for sharing with the external collaborators. Specify a comma separated list for example ""contoso.com"",""fabrikam.com""", ParameterSetName = ParameterSet_PROPERTIES)] - List SharingAllowedDomainList; - [Parameter(Mandatory = false, HelpMessage = @"Disables or enables the Social Bar for Site Collection.", ParameterSetName = ParameterSet_PROPERTIES)] public SwitchParameter SocialBarOnSitePagesDisabled; From 4f325f84b5d3bdd90a93b48efa9568a5fc19e8f6 Mon Sep 17 00:00:00 2001 From: Erwin van Hunen Date: Fri, 9 Nov 2018 14:11:02 +0100 Subject: [PATCH 30/30] November 2018 Release --- CHANGELOG.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23c894e94..d0451ccf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). -## [3.3.1811.0] Unreleased +## [3.4.1812.0] + +### Added + +### Changed + +### Deprecated + +### Contributors + +## [3.3.1811.0] ### Added ### Changed