PowerShell: New-AdUser > Account > Log on to


hey,
make easy: i'm creating new user , need define 1 computer can log on in user properties > account > log on to..

current script:

$cred        = get-credential  $template    = get-aduser -identity "account_c"  $computers   = get-content ".\computers.txt"  $password    = "pa$$w0rd"  $domain      = "domain.no"  $ou          = "ou=autologon,ou=systemusers,ou=admin,dc=domain,dc=no"    foreach ($computer in $computers)       {      $newbie  = "account_$computer"      $upn     = "$newbie $domain" -replace " ","@"        new-aduser -name $newbie -samaccountname $newbie -instance $template -userprincipalname $upn -givenname $newbie -accountpassword $password -changepasswordatlogon $false -displayname $newbie -enabled $true -server $domain -path $path -cred $cred -enable $true -cannotchangepassword $true -passwordneverexpires $true      }

you can assign netbios name of computer extended property "logonworkstations". if there more 1 computer in list, make names comma separated (not array).


richard mueller - mvp directory services



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

2008 Windows Deployment Server Properties Error

Domain migration ERR3:7075 Failed to change domain affiliation, hr=8007054a This operation is only allowed for the Primary Domain Controller of the domain

How do a find data in one file, search for it in another file and if not found, write a custom message to another file