locked
Set an AD attribute to "not set" RRS feed

  • Question

  • Hi all,

    I have to delete the profile path attribute for more than 200 accounts. I want to this with a power shell script but I am unable to set an attribute to "not set".

    What is the correct code for the <?????????> part in the following example. I tried it with $null (error was: profilepath isn't allowed to be null) and with "" or ''. Then the setInfo() throws an exception. To change the profilepath to another string isn't a problem. But to reset an attribute to "not set" was a problem for me :)

    Here the important PS code.

    function changeKDpupil([DirectoryServices.DirectoryEntry]$user)
    {
        trap{$error[0].exception.message;break}
        $user.profilePath=<??????????????????????????????????????????>
        $user.setInfo()
    }

    Kind regards
    Martin
    Wednesday, November 11, 2009 1:01 PM

Answers

All replies

  • Where does the profilePath property come from?  What type of object is it associated with?

    If you check another property/attribute that is currently 'not set' in PowerShell, what does its value look like?
    Wednesday, November 11, 2009 8:29 PM
  • Hi Marco,

    $user is a directory entry and profilePath is the AD attribute of this user. You can see the attribute names on attribute editor in AD.

    I will try to print out a not set attribute now ... good idea!
    Thursday, November 12, 2009 10:02 AM
  • $user.profilePath.clear()
    $user.setInfo()

    Shay Levy [MVP]
    http://blogs.microsoft.co.il/blogs/ScriptFanatic
    PowerShell Toolbar
    • Marked as answer by htblva5 Thursday, November 12, 2009 11:24 AM
    Thursday, November 12, 2009 10:21 AM