Quantcast
Channel: SharePoint 2013 - Setup, Upgrade, Administration and Operations forum
Viewing all articles
Browse latest Browse all 21070

Get SharePoint Online Site Collection Admins

$
0
0

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


Viewing all articles
Browse latest Browse all 21070

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>