Forum Discussion
Dahmeey
Oct 15, 2019Copper Contributor
Powershell scripts for creating subsite in sharepoint online
Hi, anyone please help out with cmdlets to create a subsite in sharepoint online using sharepoint online management tool. Thanks
10 Replies
- DahmeeyCopper ContributorVikram_Samal I was able to make it work via windows powershell. Thanks
Dahmeey You can always install the Pnp PowerShell assembly in your system from here:
Thanks for confirming that it worked for you!
- DahmeeyCopper ContributorThanks for your response Vikram_Samal please will this script run in sharepoint online management tool?
Dahmeey Yes I tested there and it worked
- DahmeeyCopper ContributorVikram_Samal Would try it at work tomorrow and revert. Thanks alot
Dahmeey The code for creating sub site is
$username = "vsamal@myDomain.onmicrosoft.com"
$password = "MyPassword"
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)
Connect-PnPOnline https://myDomain.sharepoint.com/sites/demo/ -cred $cred
New-PnPWeb -Title "SubSite A" -Url SubSiteA -Description "Information about SUBSITE A" -Locale 1033 -Template "STS#0"Then the output comes like this:
Hope this helps!
- DahmeeyCopper ContributorHi Vikram_Samal below is the error I'm getting. kindly assist.
Connect-PnPOnline : The term 'Connect-PnPOnline' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ Connect-PnPOnline https://damtek.sharepoint.com/sites/LabAs/demo -cre ...
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Connect-PnPOnline:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
New-PnPWeb : The term 'New-PnPWeb' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:2 char:1
+ New-PnPWeb -Title "SubSite A" -Url SubSiteA -Description "Information ...
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (New-PnPWeb:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException