PowerShell: Function to Set user object ScriptPath in Active Directory

Here a neat little function for you, it sets the logon script path using the Set-ADUser.

 
# Name...........: Set-ScriptPath
# Description ...: Sets the specified users logonscript.
# Syntax.........: Set-ScriptPath User LogonScript
# Example .......: Set-ScriptPath BloggsJ Default.bat
# Parameters ....: $sAM, $Scriptpath
# Author ........: Raf Delgado
Function Set-ScriptPath{param ($sAM, $scriptpath)Set-ADUser
$check -Identity $sAM -ScriptPath $scriptpath = get-aduser -Identity $sAM -Properties * -ErrorAction SilentlyContinue#$check.scriptpathIf
{} ($check.scriptpath -eq $scriptpath)Else{
}Write-Output "Error $sAM Logon Script Not Set: $scriptpath " }#EndRegion

Leave a Reply

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