I have computer name = xyz
I run the following script to set usercontrol flag.
$accountName = "xyz";
$user = [ADSI] "LDAP://CN=xyz,OU=TestOS,DC=domain,DC=net"
Write-Host $user
if(($user.UserAccountControl[0] -band 4096) -ne 0) {
"WORKSTATION_TRUST_ACCOUNT (0x1000 4096) set for $accountName"
} else {
"WORKSTATION_TRUST_ACCOUNT (0x1000 4096) is NOT set for $accountName"
# Add the useraccountdisabled flag (decimal value 4096)
$user.userAccountControl[0] += 4096
# Save the new value in the user object
$user.SetInfo()
"WORKSTATION_TRUST_ACCOUNT (0x1000 4096) has been added for $accountName"
}
but getting output as
Exception calling "SetInfo" with "0" argument(s): "A device attached to the system is not functioning.
I searched and found out if computer name doesn't exit these error will be thrown.
But I am able to get details using following command.
Get-ADComputer "xyz" -Properties *
Why I am getting "A device attached to the system is not functioning" error even though machine name exist?