0
Webアプリケーションから特定のドメインユーザー、サイトおよびサイトコレクションの管理者を抽出しようとしていますが、Microsoft.SharePoint.SPUserCollectionというサイト管理者の列があります。 CSVでその価値を知るのを手伝ってください。サイト管理者の値は、CSVのMicrosoft.SharePoint.SPUserCollectionとして表示されます。
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $currentLocation = (Get-Location).Path $outputReport = $currentLocation + "\" + "SharePointUsers2.csv" $UserDataCollection = @() $WebAppsColl = Get-SPWebApplication "https://Webapp.com" foreach($WebApp in $WebAppsColl) { Write-host "Scanning Web Application:"$WebApp.Name
$SitesColl = $WebApp.Sites
foreach ($Site in $SitesColl)
{
Write-host "Scanning Site Collection:"$Site.URL
$WebsColl = $Site.AllWebs
foreach ($web in $WebsColl)
{
Write-host "Scanning Web:"$Web.URL
$UsersColl = $web.AllUsers
foreach ($user in $UsersColl)
{
if($User.IsDomainGroup -eq $false -and $user -notlike "*XXXXXX*" -and $user -notlike "*global*" -and $user -notlike "*SHAREPOINT*" -and $user -notlike "*AUTHORITY*" -and $user -notlike "*windows*" -and $user -notlike "*312220573*" -and $user -notlike "*true*" -and $user -notlike "*KDS*")
{
$UserData = New-Object PSObject
$UserData | Add-Member -type NoteProperty -name "UserLogin" -value $user.UserLogin.ToString()
$UserData | Add-Member -type NoteProperty -name "DisplayName" -value $user.displayName.ToString()
$UserData | Add-Member -type NoteProperty -name "E-mailID" -value $user.Email.ToString()
$userData | Add-Member -type NoteProperty -Name "Site" -Value $user.ParentWeb.Url.Tostring()
$scusers = $user.ParentWeb.SiteAdministrators
$siteadmin = @()
$userData | Add-Member -type NoteProperty -Name "SC Admins" -value $user.ParentWeb.SiteAdministrators.ToString()
$UserDataCollection += $UserData
}
}
$Web.dispose()
}
$site.dispose()
}
}
$UserDataCollection = $UserDataCollection #|sort-object -Property {$_.UserLogin } -Unique
$UserDataCollection | Export-Csv -LiteralPath $OutputReport -NoTypeInformation
Write-host "Total Number of Unique Users found:"$UserDataCollection.Length