script to remove logon scripts from AD profile


i'm looking powershell script remove logon scripts (scriptpath attribute) user profiles in given ou (and child ous). in advance.

a powershell script similar vbscript solution posted in other forum follows. partially tested:

 

$ads_property_clear = 1

$ou = [adsi]"ldap://ou=west,dc=mydomain,dc=com"

function clearscriptpath($parent)
{
    foreach ($child in $parent.get_children())
    {
        if ($child.class -eq "user")
        {
            $child.putex($ads_property_clear, "scriptpath", 0)
            $child.setinfo()
        }
        if ($child.class -eq "organizationalunit")
        {
            clearscriptpath $child
        }
    }
}

clearscriptpath $ou

-----

 


richard mueller - mvp directory services


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607