0

I tried to create a new Modern SharePoint Site with the PNP Framework. I ran in the following error. I want to store the Url in a variable. Everytime I store it in a variabel I get an error message:

New-PnPSite : The property or field 'Url' has not been initialized. It has not been requested or the request has not been executed. It may need to be 
explicitly requested.

I don't where the error is coming from.

Here is my code so far:

$AdminURL = "https://{tenant}-admin.sharepoint.com"
$SiteTitle= "Test1238"
$SiteUrl= "https://{tenant}.sharepoint.com/sites/Test1238"

Connect-PnPOnline -Url $AdminURL -Interactive

New-PnPSite -Type TeamSiteWithoutMicrosoft365Group -Title $SiteTitle -Owner $SiteOwner -Lcid 1033 -Url $SiteUrl

Thanks for the help

Best regards

Matthias

2
  • I just tried the same code provided by you and it is working fine for me. Try Updating PnP PowerShell. Also, are you passing the hardcoded $SiteUrl as shown in your code or getting it dynamically from somewhere else? What is the value you passed for -Owner (In $SiteOwner variable)? May 1, 2023 at 5:34
  • Also, try this: $newSiteUrl = New-PnPSite -Type TeamSiteWithoutMicrosoft365Group -Title $SiteTitle -Owner $SiteOwner -Lcid 1033 -Url $SiteUrl. Let me know if this works for you! May 1, 2023 at 5:37

1 Answer 1

0

Didn't have the same problem as you. Why not try the SharePoint Online Management Shell?

#Connect to SharePoint Online
Connect-SPOService -url "https://domain-admin.sharepoint.com" -Credential (Get-credential)

#Create a modern team site
New-SPOSite -Url "https://domain.sharepoint.com/sites/sitename" -Owner "[email protected]" -StorageQuota 2048 -Title "sitename" -Template "STS#3"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.