Hi,
Wondering if anyone can help.
When i run the below script data is exported to a CSV. I wan't all of the data to appear in columns, this is possible for $secadmins outputs but $sitecoll.url seems to be in the same column as $secadmins.
$adminUPN="_______@_____"$SiteURL = "https://_____-admin.sharepoint.com"
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."
Connect-SPOService -Url $SiteURL -Credential $userCredential
#Set file location for saving information. We'll create a tab separated file.
$FileLocation = "SiteCollectionOwnersReport.csv"
"Site Collection Admin Report" | Out-file $FileLocation
$sitecolls = get-sposite -limit all
foreach ($sitecoll in $sitecolls)
{
$sitecoll.url
$sitecoll.url | Out-file -Append $FileLocation
if ($sitecoll.url -ne 'https://_______.sharepoint.com/')
{
$secadmins = Get-SPOUser -Site $sitecoll.url -Limit All | where {$_.IsSiteAdmin}
$secadmins | Out-file -Append $FileLocation
}
}
Write-Output "Script Execution finished"
##############################################################################
## End of Script
##############################################################################
Callum