Skip to main content
added 398 characters in body
Source Link
Eric Alexander
  • 43.3k
  • 10
  • 54
  • 93

There is no exposed ID property on the site object in PowerShell. For all intents and purposes, the Url is the "site id". In all commands where you would need to supply something like an ID, you pass in the site URL.

In order to do it in PowerShell, you will need to install the SharePoint Online client components and use CSOM to get the site guid.

$context = New-Object Microsoft.SharePoint.Client.ClientContext("https://tenant.sharepoint.com/teams/eric")
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($credential.UserName,$credential.Password)
$site = $context.Site
$context.Load($site)
$context.ExecuteQuery()
$site.Id

Note that there is no way to construct a context object via the guid. Check out the constructor information. It is either a Uri or a string of the absolute Url.

So realistically, forget about the notion of a Site Id and think in terms of Urls as your unique identifier.

There is no exposed ID property on the site object in PowerShell. For all intents and purposes, the Url is the "site id". In all commands where you would need to supply something like an ID, you pass in the site URL.

In order to do it in PowerShell, you will need to install the SharePoint Online client components and use CSOM to get the site guid.

$context = New-Object Microsoft.SharePoint.Client.ClientContext("https://tenant.sharepoint.com/teams/eric")
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($credential.UserName,$credential.Password)
$site = $context.Site
$context.Load($site)
$context.ExecuteQuery()
$site.Id

There is no exposed ID property on the site object in PowerShell. For all intents and purposes, the Url is the "site id". In all commands where you would need to supply something like an ID, you pass in the site URL.

In order to do it in PowerShell, you will need to install the SharePoint Online client components and use CSOM to get the site guid.

$context = New-Object Microsoft.SharePoint.Client.ClientContext("https://tenant.sharepoint.com/teams/eric")
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($credential.UserName,$credential.Password)
$site = $context.Site
$context.Load($site)
$context.ExecuteQuery()
$site.Id

Note that there is no way to construct a context object via the guid. Check out the constructor information. It is either a Uri or a string of the absolute Url.

So realistically, forget about the notion of a Site Id and think in terms of Urls as your unique identifier.

Source Link
Eric Alexander
  • 43.3k
  • 10
  • 54
  • 93

There is no exposed ID property on the site object in PowerShell. For all intents and purposes, the Url is the "site id". In all commands where you would need to supply something like an ID, you pass in the site URL.

In order to do it in PowerShell, you will need to install the SharePoint Online client components and use CSOM to get the site guid.

$context = New-Object Microsoft.SharePoint.Client.ClientContext("https://tenant.sharepoint.com/teams/eric")
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($credential.UserName,$credential.Password)
$site = $context.Site
$context.Load($site)
$context.ExecuteQuery()
$site.Id