Replacing all addresses in proxyaddresses with array

we have local AD that synchronizes to O365
we are adding a new email address with new domain to all users in two phases.
1) add new email address and let settle.
2) make new email address the primary email address (smtp: -> SMTP:)
I have a script I found where everything seems to work until the last command:
Set-ADUser -identity $UserName -Replace @{ProxyAddresses=$NewProxyAddresses}
The error I get with this command is:
Invalid type 'System.Management.Automation.PSObject'.
Parameter name: ProxyAddresses
    + CategoryInfo          : InvalidArgument: (user:ADUser) [Set-ADUser], ArgumentException
    + FullyQualifiedErrorId : Invalid type 'System.Management.Automation.PSObject'.
Parameter name: ProxyAddresses,Microsoft.ActiveDirectory.Management.Commands.SetADUser
The output of $NewProxyAddresses is:
smtp:[email protected]
smtp:[email protected]
X400:C=us;A= ;P=Company;O=Exchange;S=surname;G=givenname;
SMTP:[email protected]
The output of the $newProxyAdderesses is correct, but I am unable to run the set-aduser command

If I read the existing value into a variable:
$proxy = get-aduser identity $username -property proxyAddresses | select -expand proxyAddresses
And try to add or replace using that variable I get the same error.  If I read each of those values into a new variable, I can't add a single one of them without getting the same error:
$j = @()
foreach ($y in $proxy){$j+= $y}
If I copy the individual addresses text on screen and create a new array with those it works:
$newproxy = @()
$newproxy += "smtp:[email protected]"
$newproxy += "SMTP:[email protected]"
$newproxy += "X400:c=US;a= ;p=company;o=city;s=last;g=first;"
Both variables are the same type:
PS C:\Windows\system32> $proxy.gettype()
IsPublic IsSerial Name                                     BaseType
True     True     Object[]                                 System.Array
PS C:\Windows\system32> $newproxy.gettype()
IsPublic IsSerial Name                                     BaseType
True     True     Object[]                                 System.Array
If I output the contents of both variables to text files and compare them with Notepad++ they are the same.  So I am stumped as to a specific explanation, but what I can tell you is how you construct your variable is most likely what's causing
the problem.
Also, when you do construct your variable, build it in reverse order.  The address you want listed first should be the last one in the array, as the top of the list shows the most recently added address.
I hope this post has helped!

Similar Messages

  • I have a sequence on tcp that is Standard Def. I have a new set of files in High Def that match the old files. I would like to replace all the SD footage with the HD footage. Anyone know of a workflow to do this task?

    I have a sequence on tcp that is Standard Def. I have a new set of files in High Def that match the old SD files. I would like to replace all the SD footage with the HD footage. Anyone know of a workflow to do this task?

    Do a media manage of the sequence converting the files to the appropriate HD format making the clips offline.  Then simply reconnect the offline clips to the HD clips.  There may be issues in the file names, but they can usually be worked out either with the naming options in media manager or renaming your hd files.  There are many utilities that allow you to batch rename files. 

  • Search and replace all spaces between quotes with uderscore

    Hello,
    I'm new on Powershell and I'm trying to make the script that:
    searches over file and replaces all the spaces which have been found between quotes;
    removes all quotes (except these which has not value eg "").
    For example:
    Source file:
    string3=string4 string="string1 string2 string23" string8="" string5="string7 string8"
    Destination file:
    string3=string4 string=string1_string2_string23 string8="" string5=string7_string8
    I have been created script that searches the data correctly
    $file="c:\scripts\mk.txt"
    $data=Get-Content $file
    $1
    $regex = [regex]@'
    (?x) # ignore pattern whitespace option
    (?<test>(["'])(?:(?=(\\?))\2.)*?\1)
    $data |% {
    if ($_ -match $regex){
    new-object psobject -property @{
    test = $matches['test']
    }#when adding "|select-object test" I'm getting the correct data
    I have stopped here on search / replace operation (from space to underscore, and by removing the quotes leaving the empty quotes non touched). Can you help me to finish the script?
    Thanks!

    Try this.  It uses the [Regex] Replace static method, with a script block delegate:
    $file="c:\scripts\mk.txt"
    $data=Get-Content $file
    $regex = '(\S+=[^"\s]+)|(\S+="[^"]+")'
    $delegate = { $args[0].value.replace(' ','_') -replace '"(.+)"','$1' }
    $data |% { [regex]::Replace($_,$regex,$delegate) }
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • Replacing all text in book with sample text

    Hello fellows,
    Is there a way to replace all the textual content in a book with some sample text using Extendscript?
    If yes, could you please point me to the relevant APIs?
    Thank you for your help in advance!

    Yes, the point that Rick was making crossed my mind, too. Using regular expressions, you can easily specify which characters should be replaced. Listing a number of same-width characters and replacing them with an "x" is as easy as this:
    sTextString.replace ( /[abcdefghknopqrsuvyz]/g, "x" );
    This would leave the non-mentioned characters as they are. Depending a little bit on the fonts that are used, of course, as they might have different character widths for more than the ones I left out. But even if you only replace a couple of characters throughout the doc, it would be enough to get the desired effect.
    The difficulty is getting to the text strings and also to replace them. There are many objects for which a GetText method exists, but you have to set the flags such that you actually get the right text strings out of that method. And then you have to figure out where in the doc the text string is, then delete the existing one and add the replacement. All of this has to be done without deleting any markers or anchors.
    Another approach might be to set the text location to the first character in the main flow and then walking through the entire document character by character, testing each one and replacing it where required. But I don't think you would get into tables with that method, as those are linked to the running text via an anchor in that running text. So the table cells will have to be processed separately. And if you do have a method to change text in table cells, you can use that method on all paragraphs.
    I think Rick has more experience in tweaking text strings. I am usually working on structured documents and only handling the element objects and their hierarchy, not so much changing the text content of documents. Rick, do you have an approach to walk through all text strings in a document and replace them without breaking anything ?
    Ciao
    Jang

  • HT201320 How do I sync my email contacts from my iPad and my Mac so all addresses are shared with my iPhone as well?

    I want my email addresses from my Mac and my iPad to appear in my contacts on my iPhone. Can you please tell me how I set it up so all my devices share the same contacts?

    Your email provider needs to support IMAP. IMAP email accounts are kept in sync across devices. Older POP accounts are not. Check with your provider.
    Best of luck.

  • ICloud saved my daughter's Pages documents and replaced all of my documents with hers. My documents are not on iCloud, how do I get them back?

    My daughter saved her Pages documents to my iCloud account on her iPhone while my documents were apparently saved only to my phone. Never had a problem with that until tonight when iCloud synched so now I have all of my daughter's homework but all of my paperwork is gone! I logged into iCloud and it is only her documents there. How do I get my Pages documents back without a backup?
    iphone 4s, version 6.1.3

    If you took the picture on your iPhone, they are still there on your iPhone, unless you specifically deleted a particular picture from your iPhone. And likewise, if the picture was taken on your iPad, it is still there on your iPad, unless you specifically deleted that picture from the iPad.
    Now ... if you're counting on pictures still "being there" from being on the Photostream ... don't count on that, because that's only a temporary place and it has a time limit and a count limit for how many picture it will have. While the pictures you took on your iPhone and iPad will remain on each one respectively (so you won't lose those), it won't necessarily remain on the Photostream part ... which is only for sharing anyway ... and not meant for storage.
    Whatever pictures you had on your Camera Roll and thus is in the backup in iCloud, will still be there.

  • Replace all special characters in a String with underscore

    I have a String which contains some special characters even(!,$,@,*....).
    I need to replace all the special characters with _ in my String. I do have an idea of using String.replace() and analogous forms, but I would be thankful if anyone can suggest me of a better and an efficient way.
    regards,
    fun_one

    Kaj,
    Thx for your earnest reply. I did have a peep into the API on this method. But the regular expression that I need to use here was beyond my understanding. It did specify some regex that I put to use (something like myString("\D","_"), assuming that I need to replace all non-digit characters ), but it really did not help me getting the result.
    Would you spare some code for me reg. the usage of regular expressions in such a scenario?
    cheers,
    fun_one

  • How use replace all grid row with variable value

    hi master
    sir i have master detail form
    in detail form i have 5 column grid thate have 25 row at time
    one column name id
    such as id have value 23
    but i want replace all id row with 555
    how i replace all id in grid with 555 befor commit_form
    how i use loop for grid
    or any other method
    please give me idea
    thank's
    aamir

    Go_Block('Detail');
    First_Record;
    Loop
      :detail.item := '...' ;
      Exit when :system.last_Record = 'TRUE' ;
      Next_record;
    End loop;
    First_Record ;Francois

  • Preprocessing xml to replace all xpath references with the referred elements

    Hi,
    Is it possible to sort of pre-process xml before querying such as we replace all internal xpath references with the referred elements?
    So below is the xml and as we see the typeId element of second app.test.module.library.Publisher element refers to the typeId element in the first app.test.module.library.Publisher element through xpath reference . Seems this is done by XStream(which we
    use for xml-java) to reduce the size of resulting xml. This is all fine and in java one can easily traverse through such xpath references, but the challenge i am facing is in sql where i use node() function to get each of app.test.module.library.Publisher
    element and fetch value of selectedText element of both the children of app.test.module.library.Publisher - (typeId, regionCode). 
    declare @publishers xml
    set @publishers = '
    <publishers>
      <app.test.module.library.Publisher>
        <typeId>
          <selectedId>101</selectedId>
          <selectedText>Book</selectedText>
        </typeId>
        <regionCode>
          <selectedId>102</selectedId>
          <selectedText>NWD</selectedText>
        </regionCode>
      </app.test.module.library.Publisher>
      <app.test.module.library.Publisher>
        <typeId reference="../../app.test.module.library.Publisher/typeId" />
        <regionCode>
          <selectedId>101</selectedId>
          <selectedText>UWY</selectedText>
        </regionCode>
      </app.test.module.library.Publisher>
      <app.test.module.library.Publisher>
        <typeId>
          <selectedId>100</selectedId>
          <selectedText>Deposit</selectedText>
        </typeId>
        <regionCode>
          <selectedId>100</selectedId>
          <selectedText>WHU</selectedText>
        </regionCode>
      </app.test.module.library.Publisher>
    </publishers>';
    select typeId = el.e.value('(typeId/selectedText)[1]','varchar(max)')
          ,regionCode = el.e.value('(regionCode/selectedText)[1]','varchar(max)')
    from @publishers.nodes('/publishers/app.test.module.library.Publisher') as el(e)
    If you execute this, the second typeId value will be null but ideally I should be able to reach to the reference, which is typeId of first app.test.module.library.Publisher element and should be able to fetch selectedText of it, which is correct value (Book).
    In other words first two app.test.module.library.Publisher elements are of same type (Book).
    Since I am not able to find the way to do it, I thought I should have some way to process this xml to replace all such references with the referred element and that will eliminate the need to go for tedious xpath reference based access.
    Thanks

    I was able to get a result using dynamic SQL, but my guess is if you have more complicated examples it probably won't work.  I also make an assumption you know the full path of the first reference you want.  Anyway, try this:
    DECLARE @xml XML = '<publishers>
    <app.test.module.library.Publisher>
    <typeId>
    <selectedId>101</selectedId>
    <selectedText>Book</selectedText>
    </typeId>
    <regionCode>
    <selectedId>102</selectedId>
    <selectedText>NWD</selectedText>
    </regionCode>
    </app.test.module.library.Publisher>
    <app.test.module.library.Publisher>
    <!--<typeId reference="../../app.test.module.library.Publisher/typeId" />-->
    <typeId reference="../../app.test.module.library.Publisher/typeId" />
    <regionCode>
    <selectedId>101</selectedId>
    <selectedText>UWY</selectedText>
    </regionCode>
    </app.test.module.library.Publisher>
    <app.test.module.library.Publisher>
    <typeId>
    <selectedId>100</selectedId>
    <selectedText>Deposit</selectedText>
    </typeId>
    <regionCode>
    <selectedId>100</selectedId>
    <selectedText>WHU</selectedText>
    </regionCode>
    </app.test.module.library.Publisher>
    </publishers>'
    -- So you basically need to create and execute this string;
    -- but how do you work out the first bit of the string ?
    --SELECT @xml.query('(publishers/app.test.module.library.Publisher/typeId/../../app.test.module.library.Publisher/typeId)[1]');
    DECLARE @fullPath NVARCHAR(MAX) = 'publishers/app.test.module.library.Publisher/typeId/@reference' -- the full path of the reference
    DECLARE @shortPath NVARCHAR(MAX) = LEFT( @fullPath, CHARINDEX( '@', @fullPath ) - 1 ) -- full path without attribute name
    IF @shortPath IS NULL
    RAISERROR ( 'Unable to get @shortPath.', 16, 1 )
    -- Start processing the XML
    DECLARE @sql NVARCHAR(MAX), @reference NVARCHAR(MAX)
    -- Extract the reference
    SET @reference = @xml.value('(publishers/app.test.module.library.Publisher/typeId/@reference)[1]', 'NVARCHAR(MAX)')
    -- Construct the sql
    SET @sql = 'SELECT @xml.query(''(' + @shortPath + @reference + ')[1]'')'
    -- Execute the SQL
    EXEC sp_executesql @sql, N'@sql NVARCHAR(MAX), @xml XML', @sql, @xml
    Post back any issues you have with that approach and your real data.

  • I duplicated a picture and now iPhoto (11) is cloning that picture replacing all the other photos and only when I click directly on them I can see the real picture! How can I solve the problem without losing any saved picture? Shall I re-install? Thanx

    I duplicated a picture selecting CMD and D but, suddenly, iPhoto (latest version '11) started cloning that picture and replacing all the other photos with it.
    Only when I click directly on one photo I can open it and see the real picture it is.
    But the preview is always the duplicated one...
    I tryed to duplicate another picture just to see if it turned out ok but the only changement was the duplicated picture!
    I started repeating the second duplicated one instead of the previous one but my issue remained the same.
    So, how can you help me to solve this problem without losing any saved picture?
    Shall I re-install iPhoto completely?
    Thank you very very much in advance!!

    As Larry says, restoring the back up is the fastest and best solution. Otherwise:
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Rebuild iPhoto Library Database from automatic backup.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. .
    Regards
    TD

  • Replace dynamic proxies and reflection with invokedynamic

    I have an application that extensively uses reflection and dynamic proxies. It was built on Java 6. Now, I rebuilt it on Java 7, and I am thinking of replacing all reflection and proxies with new invokedynamic.
    Can anybody tell me if it's worth the trouble? I mean, will I get any significant performance boost, and will it complicate or simplify my source code?
    Also, can you recommend some good tutorials or articles to get me started? I found some, but they confuse me more then they help :-). I think I have an idea how to replace reflection calls, but can't really figure out how to replace dynamic proxies (is there a replacement for InvocationHandler, or something like that?).
    Thanks for any help.

    the MethodHandle javadocs have pretty straightforward examples on usage http://docs.oracle.com/javase/7/docs/api/java/lang/invoke/MethodHandle.html . It looks like you can use Lookup.unreflect to convert a Method to a MethodHandle (this seems like the most straightforward conversion for existing code): http://docs.oracle.com/javase/7/docs/api/java/lang/invoke/MethodHandles.Lookup.html#unreflect(java.lang.reflect.Method) .

  • Replacing all entries on computer.

    I have BB Desktop Manager 7.0.0.59
    On one of my computers I sync my BB Bold 9900 to "Replace all entires on computer with the entries on your device". Everytime I sync I have to click the organizer tab and configure the contacts, calendar, tasks and memos to "Replace all entires on computer with the entries on your device".
    Any tips on how to leave this option ON without having to configure every single time I sync??

    Hi guys,
    I would also like to know if and how this can be set, please, but in the opposite direction (replace all entries on the handset).
    Running the same version of BB Desktop Software.
    Cheers

  • Replacing Xserve, how to deal with RAID5+0 array

    We're finally looking at replacing our 8+ year old Xserve, which has served us faithfully, with a new Nehalem model. The question is what to do about the two XRAID arrays that we have attached via fibrechannel. Both are fully stocked with 14 disks apiece, configured as RAID5 but then combined into a single logical drive via software RAID0.
    The question is - if we replace the old XServe with a new one, will we have to completely rebuild the RAID5+0? If so, can this be done without data loss?
    We do have the means to migrate all the data off and then back on after reconstruction but that is, of course, a lengthy and thus unappealing option.
    Any help will be most appreciated.
    Thanks,
    Cary Talbot
    Vicksburg, MS

    Hi Tony -
    Many thanks for the reply but unfortunately neither thread you referenced addressed the issue at hand.
    What I've got is two XRAID boxes with 14 disks each. All four of the RAID arrays (2 per box of course) are RAID5. However, rather than having 4 separate logical volumes, we combined the RAID5 arrays together with a software RAID0 on the Xserve host. I understand that switching out the Xserve box shouldn't have any effect on the data stored in the XRAID disks themselves but the question becomes can we simply reconstruct the software RAID0 on the new XServe and not loose all the data stored on the four RAID5 arrays? Has anyone tried this?
    Thanks for any advice/tips/experiences anyone can offer.
    Cary

  • How can I replace ALL Contacts on the iPhone with my MobileMe Contacts?

    I have removed all duplicates in AddressBook on my various Macs and have uploaded the master copy to MobileMe. I would now like to replace all Contacts on my iPhone with that MobileMe master.
    I have followed the steps in the KB article for syncing the iPhone but when I get to the step of turning on the iPhone Settings for the Contacts it looks like the sync wants to merge the contacts. Of course, I do not want to "merge" since that will reintroduce all those duplicates.
    I suppose I could manually delete each of the the hundreds of contacts that are on my phone until it is empty ... and then turn on the iPhone setting for Contacts. That way it will have no option other than "add." But surely there is a more efficient way.
    (FWIW, when I turned OFF the setting for the Calendar it did empty the iPhone's calendar, which is what I wanted. But it didn't do that for the Contacts -- I turned that setting off but I was not asked if I wanted to keep or toss the Contacts. They are all still on the phone.)
    This is an OG iPhone, if that matters.

    Matthew Smith wrote:
    ... The only way I can think of doing it otherwise is possibly by syncing via iTunes via another Mac OS X user account where the address book is empty and then deleting them there and resyncing. ...
    Brilliant! That worked like a charm.
    I created a new User Account on one of my Macs and logged into it. I connected my iPhone to its iTunes and checked my iPhone's Sync Contacts option in iTunes. Since that account's address book was basically empty (two dummy contacts, one for Apple and one for this new user), I ended up with only those two Contacts on the phone. Then, going back to my real User account (which does not have syncing turned on in iTunes) the phone synced nicely with the MobileMe account and populated the phone with all the MobileMe contacts and groups.

  • Hello can someone help me I have an iphone 4 and my daughter has an ipod touch we are on the same email address but somehow with in the last 25hrs all of my contacts are gone and only hers on on my phone is there a way for me to get all my contacts back?

    Hello can someone help me I have an iphone 4 and my daughter has an ipod touch we are on the same email address but somehow with in the last 25hrs all of my contacts are gone and only hers on on my phone is there a way for me to get all my contacts back?

    If you need assistance with finding any of your restores or attempting to restore from any that happened prior to his incident follow this article
    http://support.apple.com/kb/ht1766
    IF you do find a backup that has your contacts; I'd /highly/ recommand turning off your wifi network after the restore is finished because if the issue is with your iCloud your contacts may merge back with her's.
    With iCloud you DO NOT want to share the account; bad things happen Evil evil thigns...
    But in all seriousness; if two devices have the same iCloud; iCloud is told to merge and sync infomation between hte two and can't tell that it doesn't belong to the same person

Maybe you are looking for

  • Can't access FIOS DVR from the web or moble phone

    Whenever I try to access my multiroom DVR in my MyVerizon account, I get a "Bad Gateway" error.  I have tried rebooting DVR and router without any luck.   I ran the DVR self diagnostic, then tried the disable then enable remote web DVR setting...stil

  • SAPScript Page

    Hi everyone,   I want to develop a general invoice form which include the header and line item.  If the line items cannot be display within one page. Then, those records will then be displayed in subsequence page.  Can i do this with one PAGE Sap Scr

  • Restore unsaved file after power outage

    I have a previously saved file (backed up in Time Machine)on which I was working when we had a power cut. The changes I had made had not been re-saved although a Time Machine backup had just run prior to the power cut. My question is (and I think the

  • LMS 4.2 user tracking

    Hello, I have a problem with LMS 4.2 user tracking. When I generate a report on all my network all mac address are ok but there is no Hostname/Ip address in the result, except for 2 equipments. the only difference between these 2 equipements and the

  • Difference between business area and sales area

    Hi I am swetha i have one doubt 1) what is the buisiness area and what purpose we use the business area 2)  what is sales area and what purpose we use the sales area 3)what is the main Difference between business area and sales area. Regards Swetha