0

I am currently writing a script using the O365 CLI. The aim of the script is to register a site collection as a hub site. I am stuck at the end result of which I want to capture the ID.

The script so far does the following:

o365 spo login "https://mytenant-admin.sharepoint.com/" 
$hubsite = o365 spo hubsite register --url https://mytenant.sharepoint.com/sites/hubsite 

Write-Host "Hubsite ID: $hubsite.ID"

It is a simple enough script however the "Write-Host" keeps returning blank. If I just enter $hubsite then I get the similar to the following:

Description : null ID : 1af04d03-d2a9-4eb4-aa9c-000000 LogoUrl : null RequiresJoinApproval: false SiteDesignId : 00000000-0000-0000-0000-000000000000 SiteId : 1af04d03-d2a9-4eb4-aa9c-2acbfc952c00 SiteUrl : https://mytenant.sharepoint.com/sites/hubsite Targets : null TenantInstanceId : 35da7502-e9d2-4684-0000-d84b98b0000 Title : Communication Site

Can please anyone help with where I am going wrong?

  • how about Write-Host "Hubsite ID: $($hubsite.ID)" ? – Gautam Sheth Mar 6 '19 at 12:30
  • Unfortuantly this just output the below Hubsite ID: – Adam13Hylo Mar 6 '19 at 12:54
0

I managed to resolve this by outputting the results to JSON, instead I now have the following:

o365 spo login "https://mytenant-admin.sharepoint.com/" 
$hubsite = o365 spo hubsite register --url https://mytenant.sharepoint.com/sites/hubsite -output json | ConvertFrom-Json

Write-Host "Hubsite ID: $hubsite.ID"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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