I have a powershell script which is fixing some corrupted userprofiles. But the results are also groups. I would like to skip the groups and fix only the users. How can I check if the spuser object is a user or group in Powershell?
$webApp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup("http://portal.myCompany.net")
foreach ($site in $webApp.Sites)
{
foreach($webSite in $site.AllWebs)
{
$siteUrl = $site.Url
$webUrl = $webSite.Url
write-host $siteUrl
write-host $webUrl
$allCoruptedUsers = Get-SPUser -Limit All –Web $webUrl | Where-Object {$_.DisplayName –like "myDomain*"}
# get all users from project portal
foreach ($user in $allCoruptedUsers)
{
#TODO: CHECK IF THIS $USER OBJECT IS A USER AND NOT A GROUP
write-host " - fix displayname" $user.LoginName -ForeGroundColor Green
Set-SPUser -Identity $user -Web $webUrl -SyncFromAD
}
write-host ""
}
}