Server 2012 PS: Script to update script path



  • Looking to update the script path for all users in AD on a Server 2012.

    Getting through a search, I find this, and it dissecting it, seems like it would work. for ALL (wildcard) users in AD. But,.. before I go and actually run it,.. wanted to confirm.

    Import-module ActiveDirectory  
    Get-ADUser -Filter * -SearchBase "OU=User Accounts,DC=santhosh,DC=lab" | Set-ADUser –scriptPath “\\San01\test.bat” 
    

    As I read it

    Import-module ActiveDirectory  
    

    Get module - gotta have that

    Get-ADUser -Filter * 
    

    Get users, filter on wild card

    -SearchBase "OU=User Accounts,DC=santhosh,DC=lab"
    

    Search OU User Accounts, on DC Santhosh.lab

     | Set-ADUser –scriptPath “\\San01\test.bat” 
    

    update the script path to UNC\file



  • breaking it down like that makes it seem easy, and understandable. might give it a go replacing the wildcard with a single user to test.



  • @gjacobse said in Server 2012 PS: Script to update script path:

    breaking it down like that makes it seem easy, and understandable. might give it a go replacing the wildcard with a single user to test.

    I would recommend this, lol.



  • @dafyre said in Server 2012 PS: Script to update script path:

    @gjacobse said in Server 2012 PS: Script to update script path:

    breaking it down like that makes it seem easy, and understandable. might give it a go replacing the wildcard with a single user to test.

    I would recommend this, lol.

    Oh - I would too... 🙂



  • Since I was working with only ONE user this is what I needed to change it to, else was getting Parameter set cannot be resolved

    Import-module ActiveDirectory  
    Get-ADUser -Filter {Name -eq "SomeUser"} -SearchBase "OU=Users,OU=OUGroup,DC=DOMAINname,DC=com" | Set-ADUser –scriptPath “\\SERVERNAME\netlogon\2018ADUC-script.txt”
    

    But it worked!