0

I'm building a PowerShell script to export a list of all the site collections in a particular web application.

So far I have this:

Get-SpWebApplication http://www.contoso.com | Get-SPSite -Limit All |
Select URL, ID, contentdatabase, owneralias,
secondaryowneralias | Export-CSV "f:\VLESites.csv" -NoTypeInformation

This creates a csv file at the specified drive location containing a list of site collection URLs, GUIDs and Content DBs within the stated web app. So far so good.

Unfortunately it doesn't display the primary and secondary owners of the site collections.

How can I modify this script to also display this ower information?

0

3 Answers 3

2

Try to use Owner instead of owneralias, and SecondaryContact instead of secondaryowneralias.

1

simple:

Get-SpWebApplication http://www.contoso.com | Get-SPSite -Limit All |
Select URL, ID, contentdatabase,Owner, SecondaryOwner | Export-CSV "f:\VLESites.csv" -NoTypeInformation
1

Here is the script. It will get you primary administrators in an excel file for each site collection inside a web application. I am not able to get Secondary Owner Property though.

$WebApplicationUrl = "https://peopletest.brookfield.com"
$outputFile1 = "C:\TEMP\siteCollectionAdminsPrimary.csv"
$outputFile2 = "C:\TEMP\siteCollectionAdminsSecondary.csv"
$primarySiteAdminsCollection = @() #variable that will contain all the primary Site Collection Admins and will be exported
$secondarySiteAdminsCollection = @() #variable that will contain all the secondary Site Collection Admins and will be exported

$webApplication = Get-SPWebApplication $WebApplicationUrl;
if($webApplication -ne $null)
{
    ##Looping through all the site collections in the provided web application
    foreach($siteCollection in $webApplication.Sites)
    {
        $primarySiteAdminsCollection += $siteCollection.Owner
         $secondarySiteAdminsCollection += $siteCollection.SecondaryContact
    }
    $primarySiteAdminsCollection | ConvertTo-Csv -Delimiter "~" -NoTypeInformation | Out-File -Append -FilePath $outputFile1
    $secondarySiteAdminsCollection | ConvertTo-Csv -Delimiter "~" -NoTypeInformation | Out-File -Append -FilePath $outputFile2
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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