Forum Discussion

Dahmeey's avatar
Dahmeey
Copper Contributor
Oct 15, 2019

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

  • 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!

    • Dahmeey's avatar
      Dahmeey
      Copper Contributor
      Hi 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

Resources