Set-ADUser -Replace

Hi
I could be wrong, but I think there's an error in the help for Set-ADUser, in the section describing the -Replace parameter:
For example, if you want to replace the value "555-222-2222" with the values
"555-222-1111" for Phone-Office-Other attribute (LDAP display name
'otherTelephone') set the Replace parameter as follows.
-Replace @{otherTelephone='555-222-2222', '555-222-1111'}
Wouldn't that example set the otherTelephone property to the two values given rather than replacing the first one wuth the second?
Thanks

Looks like you're right. I just took a look through the AD cmdlets with dotPeek, and when the -Replace parameter is used (with an array), it calls Clear() followed by AddRange() on the property collection:
if (customPropertyValue is object[])
propertyValue.Clear();
propertyValue.AddRange((object[]) customPropertyValue);
else
propertyValue.Value = customPropertyValue;

Similar Messages

  • Powershell - Bulk Set-ADUser attributes via a CSV file

    I am attempting to do a Bulk replace of AD User account attributes via a CSV file.  Each line in this script works except the part of Set-ADUser where I enter -Replace $attribs. I'm not sure how to code this
    part.
    <#
    The .csv file should have the following headers (first line)
    GroupName,Status,Approver1,Approver2,Owner
    #>
    #Import CSV
    $csv = @()
    $csv = Import-Csv -Path "C:\TempAdd_Grp_Attrib.csv"
    #Loop through all items in the CSV
    ForEach ($item In $csv)
    $gname = $item.GroupName
    $attribs = @{'extensionAttribute2'=$item.Status; 'extensionAttribute3'=$item.Approver1; 'extensionAttribute4'=$item.Approver2; 'managedBy'=$item.Owner}
    Set-ADGroup -Identity $gname #-Replace $attribs
    mamadukes

    Yes. I am attempting to update the AD Group extension attributes.
    The code below works, but I know I can streamline this if I use the INSTANCE, which I am having an issue with (Set-ADGroup -Instance $Update)
    Import-Module ActiveDirectory
    <#
    The .csv file should have the following headers (first line)
    GroupName,Status,Approver1,Approver2,Owner
    #>
    #Import CSV
    $date = get-date -Format "MMddyyyymm"
    $csv = @()
    $csv = Import-Csv -Path "C:\Temp\Add_Grp_Attrib2.csv"
    #Loop through all items in the CSV
    ForEach ($item In $csv)
    $Update=(Get-ADGroup $item.GroupName -Properties extensionAttribute2,extensionAttribute3,extensionAttribute4,ManagedBy);
    $Update."extensionAttribute2"=$item.Status
    $Update."extensionAttribute3"=$item.Approver1
    $Update."extensionAttribute4"=$item.Approver2
    # Set-ADGroup -instance $Update
    Set-ADGroup -Identity $item.groupName -ManagedBy $item.Owner
    Get-ADGroup $item.GroupName -Properties extensionAttribute2,extensionAttribute3,extensionAttribute4,ManagedBy | select name,extensionAttribute2,extensionAttribute3,extensionAttribute4,ManagedBy | Export-Csv "C:\temp\Add_Grp_Attrib_Updates_$date.csv" -NoTypeInformation
    mamadukes

  • How do I remove one failing hard drive from raid set and replace with new one

    Last Friday apparently one of my raid drives started failing.
    As I mentioned on this forum I started getting continous beeping.
    I was finally able to get the raid working at a degraded level.  I ordered a replacement hard drive which is arriving today.
    (In the meantime I made twice daily backups of my work.....)
    Below was the message I got from the browser based raid software:
    Blahblah 09    1000.2GB   RaidSet Member SamSung HD103SJ
    Blahblah 10    1000.2GB     Free                 SamSung HD103SJ
    Blahblah 11    1000.2GB   RaidSet Member SamSung HD103SJ
    Blahblah 12    1000.2GB   RaidSet Member SamSung HD103SJ
    (See this earlier thread if you wish!)
    http://forums.adobe.com/thread/727867?tstart=0
    At one point when I did the checked the browser interface I saw the message Failed and Degraded
    As I said, I was able to work over the weekend on the degraded system.
    This morning I got the beeping again and did the rescue and now I am running a "full raid" without the notice that one raid was "Free".
    In any case, the new hard drive is arriving today.
    What steps should I take to incorporate the new drive into the raid system.
    I have one OS drive
    and 4 tb raid drives.   One needs to be replaced with the new one that I am getting today.
    Thanks
    Rowby

    Harm,
    Regarding your comment:
    Re: How do I remove one failing hard drive from raid set and replace with new one
    Please tell me how to read the serial number from an individual drive rather easily, without un-installing them:
    If you select the proper drive to change out, you only need to remove one drive and look at its serial number...
    Step 1: Identify bad drive serial number using Areca's tools
    Step 2: Turn off the computer
    Step 3: Remove what you think is the bad drive based on following your numbered cable method, marked hot-swap bays, whatever
    Step 4: Verify that the serial number matches the "bad drive" serial number from step 1; if it does great, proceed; if it does not match, go back to step 3
    Step 5: Change out the CORRECT drive - that's the bottom line for this whole procedure
    Cheers,
    Jim

  • Need help with Set-ADUser command

    I need a little help with the following command. Im new to PS and I have found this command but it is only one user at a time. I need to be able to update ALL users in AD.
    My goal is this. Someone before me set all Users Home numbers to 1234567899 and I need to remove that and leave it blank. The command below allows me to do that but only one user at a time by entering their SAMID.
    Is there a way to do this for everyone in AD ?
    Set-AdUser –Identity SAMID –HomePhone $NULL

    Yeah sure - 
    Get-Aduser -filter * -properties SamaccountName | Select SamAccountName | % {Set-Aduser -identity $_.SamaccountName -HomePhone $null}

  • Set-ADUser based on .csv file - empty attributes issue

    Hi, after a few months without working with PowerShell my knowledge is slowly fading away but fortunately every time this happened before, I was able to rebuild my knowledge again and now it is the same story. However I want to optimize my simple
    code which populates three AD user object attributes: manager, officephone and fax with values stored in .csv file. Everything works well, but my code looks not so good in my opinion. Is there any more elegant solution?
    $AddressBook = Import-CSV -Path D:\AddressBookFinal.csv
    foreach($Employee in $AddressBook)
         if([string]::IsNullOrEmpty($Employee.ManagerUserName)) {
                  Set-ADUser -Identity $Employee.EmployeeUserName -Manager $null
        } else {
                  Set-ADUser -Identity $Employee.EmployeeUserName -Manager $Employee.ManagerUserName
        <#similar code here for checking value of OfficePhone and Fax attributes and populating             AD attributes depending on if attribute value in .csv file is empty or not#> 

    Hi BoxiKG,
    If there is any other question regarding this issue, please feel free to reply this post directly so we will be notified to follow it up.
    If you have any feedback on our support, please click here.
    Best Regards,
    Anna Wang
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • "Set-aduser -clear" using variables

    Hello all,
    Is it possible to clear an attribute from a user using variables? For example, this little command works fine:
    get-aduser User31 | set-aduser -clear extensionattribute2, extensionattribute3
    However, I'd like to use this command with variables, like if I didn't know what attributes I wanted to clear beforehand, and could add these attributes to a variable and then pass them to set-aduser:
    $Variables = "extensionattribute2, extensionattribute3"
    get-aduser User31 | set-aduser -clear $Variables
    This command will not work, and I'm not sure if it's possible to use variables with the "-clear" parameter of "set-aduser"?

    Hi,
    You can do that this way:
    $attributes = 'extensionAttribute2','extensionAttribute3'
    Set-ADUser -Identity tester1 -Clear $attributes
    Examples:
    Before:
    Get-ADUser -Identity tester1 -Properties extensionAttribute2,extensionAttribute3 |
    Select SamAccountName,extensionAttribute2,extensionAttribute3
    SamAccountName extensionAttribute2 extensionAttribute3
    tester1 ex2 ex3
    After:
    SamAccountName extensionAttribute2 extensionAttribute3
    tester1
    Don't retire TechNet! -
    (Don't give up yet - 12,950+ strong and growing)

  • Set-aduser : Insufficient access rights to perform the operation

    I am a domain admin, enterprise admin, exchange admin, domain user, and others.
    While running a PS on a DC as the administrator, The commands I'm running are ...
    $expdate = get-date -date '01/01/2014'
    set-aduser -identity testmail5 -accountexpirationdate $expdate
    I get the following error ...
    set-aduser : Insufficient access rights to perform the operation
    At line:1 char:1
    + set-aduser -identity testmail5 -accountexpirationdate $expdate
        + CategoryInfo          : NotSpecified: (testmail5:ADUser) [Set-ADUser], ADException
        + FullyQualifiedErrorId : Insufficient access rights to perform the operation,Microsoft.ActiveDirectory.Management.Comm
       ands.SetADUser
    I then switch to a different DC, the command 'might' work once, but will never run again in the same window.
    Then I tried this ...
    start-process powershell -verb runas
    That gave me an additional PS window, and I then tried running the commands again.
    Same error message.
    So I tried the following command ...
    $expdate = get-date -date '01/01/2014'
    set-aduser -server XXDC03 -identity testmail5 -accountexpirationdate $expdate
    Same error message.
    Is there any way that I can get around this problem?
    Please help.

    Keep in mind that the account used to open the PowerShell session must be the same account you're using to open ADUC. The error message means that Set-ADUser is trying to set the attribute for the account, but it's failing. Make sure to test with multiple
    different accounts, in case the access control list of the object you're trying to modify is the cause of the problem.
    Your PowerShell syntax is valid, so this isn't really a scripting question but a security/directory services question.
    -- Bill Stewart [Bill_Stewart]

  • JSTL c:set tag replace single qoutes to & #039;

    Hi all,
    i'm using the JSTL-Tags to create and query a SQL-Statement.
    I use the c:set Tag to set a part of my query...
    <c:set var="selectSeveral" value="d.hardwarecode = '${param.p_macAddress}'"/>
    ...and the sql:query Tag to excecute the query:
    SELECT <c:out value="${selectValue}"/>
    FROM event e, device d, billingunit b
    WHERE e.eventdate >= to_date('<c:out value="${param.p_dateFrom}"/>', 'DD.MM.YYYY HH24:MI:SS')
    AND e.eventdate <= to_date('<c:out value="${param.p_dateTo}"/>', 'DD.MM.YYYY HH24:MI:SS')
    AND <c:out value="${selectSeveral}"/>
    AND e.deviceid = d.deviceid
    AND d.billingunitid = b.billingunitid
    GROUP BY <c:out value="${groupValue}"/>
    By excecuting the Statement with Tomcat i get a Oracle ORA-00911: invalid character Errormessage.
    I found the reason for this in the Logfile, where the Statement looks like this:
    SELECT e.eventdate, e.sessionend, e.sourceip, e.amount, d.hardwarecode, d.typecode, b.name, b.code
    FROM event e, device d, billingunit b
    WHERE e.eventdate >= to_date('17.03.2003 19:44:06', 'DD.MM.YYYY HH24:MI:SS')
    AND e.eventdate <= to_date('17.03.2003 20:54:59', 'DD.MM.YYYY HH24:MI:SS')
    AND e.sourceip = & #039;172.24.214.222& #039;
    AND e.deviceid = d.deviceid
    AND d.billingunitid = b.billingunitid
    ORDER BY eventdate asc
    As you can see JSTL replaced the single quotes with the number code of the single quotes. (& #039;)
    Any ideas how to solve this problem.
    Thanks in advance.
    Cu Daniel

    Try setting the escapeXml attribute to false - it defaults to true, and will replace XML (and HTML) special characters to their entity codes. For example:
    <c:out value="${selectValue}" escapeXml="false"/>

  • Recovery manager, Will factory setting recovery replace all the deletes i had from bad sector?

    Hello, i am curious about recovery manager and what it does.
    recently i had my old hdd removed because of increase of bad sectors. i tried to use system recovery dvd i orderd from hp web site but it did not work on my new hdd so i had to clone my old hdd to use it. while i was using old hdd i had to run chkdsk alot and i saw few of window/systm/... listed as problem and it was removed(?).
    I want to make sure my new hdd has no problem after recovering to factory setting. (I raned chkdsk before i clone my old hdd)
    will recovery manager replace all those bad sector delete i saw on chkdsk?
    This question was solved.
    View Solution.

    @Forblindmice ,
    Hello and thank you for posting on the HP support forums.  The recovery will not recover lost sectors.  Any data that has been lost is lost unless you run with some type of special recovery software and this is not always a win.
    Once you have  a bad sectors unless you can use some type of hardware low level format software to remap the sectors they will still be there.
    What I would do is pull the drive and put it in another computer and get all your data off it. 
    Once you get what you can off the drive then you can see if there is a software out there to low level format and then try getting recovery media from HP phone support to reload your OS.
    I would consider replacing the drive though.  If you are starting to get bad sectors this is usually mechanical and will mean a total crash some time soon.
    Please click the "Thumbs Up" on the bottom right of this post to say thank you if you appreciate the support I provide!
    Also be sure to mark my post as “Accept as Solution" if you feel my post solved your issue, it will help others who face the same challenge find the same solution.
    D5GR
    I work on behalf of HP

  • Cannot set up replacement iPhone with MobileMe

    I have a paid MobileMe account (now extended to 6/30/12), and a few weeks ago, had my iPhone 3GS die on me.  Got an iPhone 4, and got the 3GS replaced under warranty, and gave it to my wife.
    Tried to set up "Find My iPhone" last night on the replacement 3GS, and now I get a message saying that it found my account, but I can't set up a free MobileMe account.  (Went to settings/mail/add new account/ put in my MobileMe credentials, etc.)
    I can't set up ANY mobileme syncing with this.  The message comes back immediately, and I'm unable to set anything.
    What's the problem?  My old 3GS was still present under "Find My iPhone" yesterday, as well as my iPhone 4 and my iPad.  I deleted the 3GS from the web based MobileMe, and the message said as soon as it came back on, would be available again.
    Why can't I set this up with my PAID MobileMe account?

    I'm not attempting to set up a new "account" as in service. I'm trying to associate the 3GS with an existing account. "add new account" is the mail account on the iPhone - NOT the service for said account (gmail, yahoo, exchange, etc). 
    I'm adding a "new" account to the iPhone.
    "Settings/Mail, Contacts, Calendar/ADD ACCOUNT".   Won't let me associate it with the 3GS for existing MobileMe account.  I go thru the same process for Gmail, which doesn't create a "new account" back at the provider, or a new userid/account.
    I'm simply using the terminology on the screens.

  • Lost phone, trying to set up replacement

    Hello, I recently lost my iphone and just got my new 5S.  do I need to remove my old iphone from my account to set up my appleid and icloud on my new replacement phone?

    You can't restore a backup that was made on a device running a more recent version of iOS.  If your replacement phone is running iOS 6.0.1 and the one you backed up was running 6.1.2, for example, you would have to update your replacement phone before you could restore to the backup.  If this is the case, update your phone by connecting it to your computer, and selecting Check for Update or Update on the Summary tab of your iTunes sync settings, update the phone and set it up as New.  Then go to Settings>General>Reset, tap Erase All Content and Settings, go through the setup screens again and choose Restore from iCloud Backup.  You should then be able to restore your backup.

  • Set up replacement E1000

    I had an E1000 for a couple of years that worked OK.  Then it went nuts--sporadically dropped the signal, wouldn't show its web page, etc.--maybe a power surge, who knows?  So I tossed it and got a new one on the theory that it would be a plug in replacement.  Wrong!
    The new unit had a good signal, but also wouldn't show its web page, so I couldn't configure security.  I removed Network Magic and everything else I could see pertaining to the old unit.  However, the CD for the new unit still gives me: " Your router has already been set up.  You need to use an Easy Setup Key that you can use to get other computers connected."  Needless to say, I don't have such a thing.  Cisco Connect is not installed at this point, so I can't go into it to create one.
    How can I purge the remains of the old unit so the new one will install properly?
    Thanks.

    Thanks for the suggestions, everybody.
    To the best of my belief the problem was some piece of code still pertaining to the old router that was hiding somewhere on the workstation. The new router would not set up properly there under any circumstances--its web page could not be opened and the Cisco management software would not run because it said the router was already installed.
    What I finally had to do was set it up on my laptop, then use the settings backup file to move the router to the desktop.  That seems to have worked--I've had stable wireless for about an hour now.
    Just for curiosity, and maybe future reference--does anybody know where router settings/drivers hide in Windows?  During this process I realized that I've never seen a router, wired or wireless, show up in Control Panel or Device Manager, and under Network Settings you just see adapters.  Is there no way to uninstall or manage these devices from Windows?

  • IPad set up replace old iPad

    I've just received my IPad 2, a replacement for my original iPad, since lost. How do I set up the replacement to sync with all the old stored data on my laptop?

    Thanks, Phil. Since my data was still there, I just plugged it into the laptop, opened iTunes and when the screen came up, synched from Restore from Back Up option. The new iPad now has all the old data, including the old Device name. It doesn't have some stored passwords like to my mail servers, apps, iCloud access, etc., which have to be re-entered. But otherwise this seems relatively painless. Thanx, Apple; thanx Phil.

  • Setting up replacement ipad

    Apple replaced my 2,5 ipad mini today as the calender was not opening and screen was flashing between my screen lock page and black page with white apple icon. Should I set up the replacement with back up or set up as new??

    Thanks Amish Cake!
    I was just concerned incase something in the back up might cause probs with the new i pad but more lightly I just had a faulty one so thinK I will use the back up .

  • How do I remove a favicon once set and replace with a new one?

    I want to replace an existing favicon with a new one and it won't allow me.  does anyone have a work around?

    File > Site Properties & select the layout tab. You can delete and upload a new favicon image at the bottom

Maybe you are looking for

  • Help....Help....Help I'm the newone in JSP

    I have some questions: 1. The problem is, how can I define how much results of sql(mySQL) query will be show on html page (something like we see on many search engines like Google or Altavista etc.), in the bottom of page: Result Page: 1 2 3 4 5 Next

  • Appending Objects in an internal Table

    Hallo Guru, I'm looking for a way to append newly created objects of a class "XYZ" in an internal table. Best Regards, Kais

  • Is there an outage in 43449?

    Going from 1x to 1x Extended to No Service. What is going on?

  • R3 replication to CRM problem

    Hello, Firstly I'm not sure if this is the proper place for my post, but I'll give a try. We've set replication mechanisms, between R3 and CRM, so that whenever a customer is changed in R3, those changes are replicated by RFC from R3 to CRM system. E

  • I am Being Charged For a Number I Have Never Rang.

    Please can anyone help me with this issue; below is a copy of a message I sent tonight to BT, which explains my problem. I only discovered this today after checking my recent bill. My phone bills have significantly increased since Sept 2010. I haven'