Omar El-Anis – 365 Developer

My experiences with SharePoint, Flows, PowerApps, JavaScript and all of the other lovely web technologies out there!

SharePoint Services SharePoint Useful Tricks Uncategorised

Create Modern Portal SharePoint site in SharePoint Online using powershell

Use the script below to create a new Modern Portal site within SharePoint Online using c# PowerShell

</p>
<p># Connect to SharePoint Online<br>
# This command will prompt the sign-in UI to authenticate<br>
Connect-PnPOnline "https://tenant.sharepoint.com/" –Credentials (Get-Credential)</p>
<p># Create the new "modern" team site<br>
$teamSiteUrl = New-PnPSite -Type TeamSite -Title "TITLE FOR THE SITE" -Alias "My site alias" -Description "site for storing and managing all collaboration" -Url https://tenant.sharepoint.com/sites/MYSITEURL<br>
# Connect to the modern site using PnP PowerShell SP cmdlets<br>
# Since we are connecting now to SP side, credentials will be asked<br>
Connect-PnPOnline $teamSiteUrl</p>
<p># Now we have access on the SharePoint site for any operations<br>
$context = Get-PnPContext<br>
$web = Get-PnPWeb<br>
$context.Load($web, $web.WebTemplate)<br>
Execute-PnPQuery<br>
$web.WebTemplate + "#" + $web.Configuration</p>
<p>

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments