Hi Expert,
I need to verify is the Computer Object Owner is still enable with the script below. not sure where goes wrong but the result always go to "User $userName who Manage this machine is DISABLE" even the user is enable.
$ManageBy = Get-ADComputer computer -Properties ManagedBy |select -ExpandProperty ManagedBy
$userName = Get-ADUser "$ManageBy" -Properties name| select -ExpandProperty Name
$user = Get-ADUser "$ManageBy" -Properties enabled,name,managedObjects,manager | select ManagedObjects,Name,Enabled,Manager
$ValidateUser = $user
try{$ValidateUser = Get-ADUser "$ManageBy" -Properties enabled|select Enable -ErrorAction SilentlyContinue } Catch {}
if ($ValidateUser -eq $user)
{
Write-Host "User $userName who Manage this machine is Enable" -ForegroundColor yellow
$user| fl
}
if ($ValidateUser -ne $user)
{
Write-Host "User $userName who Manage this machine is DISABLE" -ForegroundColor Red
$user|fl
}