Update user account properties


hi

can me find out why getting following error messages?

function setl1customaccountproperties($ip,$vm,$acc) {
$erroractionpreference = "silentlycontinue"
$error.clear()
write-host "setting properties " -foregroundcolor $colfunc -nonewline; write-host $acc -foregroundcolor $colvar -nonewline; write-host " account on " -foregroundcolor $colfunc -nonewline; write-host $vm -foregroundcolor $colvar -nonewline
 
 $user = new-object -typename adsi -argumentlist @(
    "winnt://$ip/$acc,user",
    "$ip\$guestusername",
    $guestpassword                            
)

$user.connectclientdrivesatlogon = 0
$user.connectclientprintersatlogon = 0
$user.defaulttomainprinter = 0
$user.enableremotecontrol = 0
$user.allowlogon = 0
$user.setinfo()
error-check
}

hi kelly,

to enable "connect client printers @ logon" , "default main client printer" in ad, please refer script below:

$user.invokeset("connectclientdrivesatlogon",0) $user.invokeset("connectclientprintersatlogon",0) $user.invokeset("defaulttomainprinter",1)  $user.setinfo() 
hope helps.



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

WIMMount (HSM) causing cluster storage to go redirected (2012r2 DC)

Failed to delete the test record dcdiag-test-record in zone test.com

Azure MFA with Azure AD and RDS