I am currently working with some code that gives me the following:
- Site Collection Guid
I would like to fetch the site url using the site collection Guid with PNP PowerShell.
Does anyone have any idea how to do this?
I am currently working with some code that gives me the following:
I would like to fetch the site url using the site collection Guid with PNP PowerShell.
Does anyone have any idea how to do this?
The Microsoft Graph can provide you the information about the site collection. See the paragraph Note for existing SharePoint developers and especially the last example.
The endpoint URL for your use case would then be
https://graph.microsoft.com/v1.0/sites/{hostname},{spsite-id}
Resulting URL for tenant mytenant.sharepoint.com
and site collection 21e6689e-ddd0-48eb-1234-0357c5fa1093
:
https://graph.microsoft.com/v1.0/sites/mytenant.sharepoint.com,21e6689e-ddd0-48eb-1234-0357c5fa1093
The response then looks like this:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites/$entity",
"createdDateTime": "2018-01-12T21:27:53.963Z",
"description": "",
"id": "mytenant.sharepoint.com,21e6689e-ddd0-48eb-1234-0357c5fa1093,2cb44c34-5aee-4c5e-1234-9a2d36b8204b",
"lastModifiedDateTime": "2019-04-02T10:58:01Z",
"name": "mysitecollection",
"webUrl": "https://mytenant.sharepoint.com/sites/mysitecollection",
"displayName": "My Site Collection",
"root": {},
"siteCollection": {
"hostname": "mytenant.sharepoint.com"
}
}
Edit - Below will work only for SP on premises environment.
I think you can use Pure Powershell command.
Get-SPSite -Identity "121321-12312-12312-1231231"
Identity parameter takes url or GUID, below is text from microsoft documentation
-Identity Specifies the URL or GUID of the site collection to get. The type must be a valid URL, in the form, https://server_name or https://server_name/sites/sitename, or a valid GUID (for example, 12345678-90ab-cdef-1234-567890bcdefgh).
https://docs.microsoft.com/en-us/powershell/module/sharepoint-server/get-spsite?view=sharepoint-ps
Hope this helps...Happy Coding..!!!