$username=$Manager|Select-Object*-ExpandPropertyManager is equal null ?
$Users=Get-ADUser-Filter {Enabled-eq$true-andgweVfOpcoId-ne"0" }-SearchScopeSubtree-SearchBase"OU=Opcos,OU=MOSSUsers,OU=MOSS,OU=Sharepoint,DC=sharepdev1,DC=local"
foreach($userin$Users)
{
$Manager=$user|Get-ADUser-Properties*|SelectManager
if($Manager.Manager-ne$null)
{
$username=$Manager|Select-Object*-ExpandPropertyManager
$userstatus=Get-ADUser-Identity$username-PropertiesEnabled
if($userstatus.enabled-eq$ture)
{
$User=Get-ADUser-Identity$username-PropertiesMemberOf
$Group= (Get-ADGroup"Managers").distinguishedName
If ($User.memberOf.Contains($Group))
{
Write-Host"User is already a member of one of the Job Roles"
}
Else
{
Write-Host"User is not a member of any of the Job Roles"
Add-ADGroupMember-IdentityManagers-Member$username
}
}
}
}
Import-ModuleActiveDirectory