Delete script path attrubute RRS feed

  • Question

  • Hi, I am trying to delete a logon script that is configured for a few hundred users but the following is not working. I think the Set-User $user part might be wrong but am not sure?

    Any help please, thanks

    $batusers = Get-ADUser -filter { scriptpath -like "test.bat" } | select displayname
    Foreach ($user in $batusers)
     { Set-ADUser $user -scriptpath $null }

    Monday, April 3, 2017 1:41 PM


  • You cannot assign Null or a blank string to any AD attribute. Use the -Clear parameter of the Set-ADUser cmdlet.

    Also, probably better to use the -eq operator rather than -Like in your filter.

    Finally, don't select displayName. That does not uniquely identify the user. Select sAMAccountName , which does uniquely identify the object.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Monday, April 3, 2017 2:43 PM