Powershell : Remove logon scripts

Removes logon scripts on a particular OU.

$path = [adsi]"LDAP://OU=Users,OU=IT,OU=Eu,DC=eu,DC=somewhere,DC=com"
$obj = New-Object adsisearcher($path , "(scriptPath=*)")
$users = $obj.FindAll()

foreach ($user in $users)
{
$user = [adsi]$user.path
$user.PutEx(1,"scriptPath",$null)
$user.SetInfo()
}

Leave a Reply

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