Set user’s logon script

Staying on the profile tab we can also set a logon script

$ou = "OU=BlogTests,DC=Manticore,DC=org"            
$name = "UserA"            
Get-ADUser -Identity $name |            
Set-ADUser -ScriptPath "ls1.cmd"            
"`nAD provider"            
$name = "UserB"            
$dn = "cn=$name,$ou"            
Set-ItemProperty -Path AD:\$dn  -Name scriptpath -Value "ls1.cmd" -Force            
$name = "UserC"            
Get-QADUser -Identity $name |            
Set-QADUser -LogonScript "ls1.cmd"            
$name = "UserD"            
$dn = "cn=$name,$ou"            
$user = [adsi]"LDAP://$dn"            
$user.scriptpath = "ls1.cmd"            

Simply set the name of the logon script file in the scriptpath attribute. Notice that the Quest cmdlet uses –LogonScript for the parameter

The full path isn’t required because logon scripts are in the netlogon share on domain controllers – you don’t want to set a specific domain controller usually

This entry was posted in PowerShell and Active Directory. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s