Powershell: How to modify login script path

When you decide that the 90’s login script, .bat, .cmd files ;), has to leave for ex. GPO Drive maps, then you can remove it from all AD users with this simple command:

#Remove any login script from all users in the OU.
 
Import-module ActiveDirectory  
Get-ADUser -Filter * -SearchBase "OU=Marketing,DC=martinsblog,DC=local" | Set-ADUser -Clear scriptPath 
 
# Set a login script for all users is the OU
Import-module ActiveDirectory  
Get-ADUser -Filter * -SearchBase "OU=Marketing,DC=martinsblog,DC=local" | Set-ADUser –scriptPath “\\dc01\netlogon\myscript.bat” 

And it’s gone:

2 Comments

  1. Steven Mak

    How to update the logon scripp from csv file ?

    Reply
    1. Martin (Post author)

      What do you mean by csv file?

      Reply

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close