Forum Discussion
Calling the SPO Site ID?
Hello there,
I'm trying to find the SPO site ID using PowerShell. I have tried using the following command, but it does not return any results.
Get-PnPTenantSite| Where-Object {$_.Url -eq "https://companydomainsharepoint.com/sites/mysite"} | select *idI have verified that the URL buy adding the _api/site after the site and also matches the one from the SharePoint admin center reports.
https://companydomain.sharepoint.com/sites/mysite/_api/site
<d:Id m:type="Edm.Guid">*******-***-***-***-********</d:Id>Is there another way to get the SPO site ID using PowerShell? I appreciate any help or guidance you can provide.
3 Replies
- That's probably due to it not getting any results.
Try this and see if you get any value, else it's not matching on your URL:
$mySite = Get-PnPTenantSite| Where-Object {$_.Url -eq "https://companydomainsharepoint.com/sites/mysite"}
$mySite.value- marcin-260Copper ContributorThanks Nicolas, no results. It's does not contain any 'value' property even when pipping out as a full list.
Is this template specific? The one I'm looking at is SITEPAGEPUBLISHING#0?marcin-260 I think the site Id you are looking for is not returned using the Get-PnPTenantSite command. I even tried using -Detailed with the PowerShell command like below but it did not return the expected Id:
Get-PnPTenantSite -DetailedYou can try using Get-PnPSite like:
$SiteURL = "https://contoso.sharepoint.com/Sites/mysite" #Connect to SP site Connect-PnPOnline -Url $SiteURL -Interactive #Get site ID $Site = Get-PnPSite -Includes ID #Print site ID Write-host -f Green "Site ID: "$Site.Id
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.