Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

PowerShell: New-AdUser > Account > Log on to

$
0
0

Hey,
To make it easy: I'm creating a new user and I need to define one computer that can log on to it in the User Properties > Account > Log on to..

This is the 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
    }


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>