Would like to automate this Powershell command that sets the UPN of all mail enabled users

I have command that changes the UPN of all mailbox users
Get-ADUser -Filter * -properties homemdb | where {$_.homemdb -ne $null} | ForEach-Object ($_.SamAccountName) {$CompleteUPN = $_.SamAccountName + “@contoso.com”; Set-ADUser -Identity $_.DistinguishedName -UserPrincipalName $CompleteUPN}
The command works using the AD module for
powershell. What I would like to do it write a script that does the following.
Runs the command above
Only applies changes to users that need it. (I think this applies the setting to all users with the "homemdb")
I was thinking of setting it as a scheduled task on one of the Domain Controllers. My
powershell skills are lacking at best, so any guidance on how to set this up would be much appreciated. 
Thanks

Cannot bind parameter 'Filter' to the target.
Exception setting "Filter":
"Invalid filter syntax. For a description of
the filter parameter syntax see the command help.
"(RecipientType -eq
'UserMailbox') -and
(UserPrincipalName -notlike
('*@{1}' -f $UPNSuffix))" at position 68."
    + CategoryInfo         
: WriteError:
(:) [Get-User],
ParameterBindingException
    + FullyQualifiedErrorId
: ParameterBindingFailed,Microsoft.Exchange.Management.RecipientTasks.GetUser
Read the error very carefully: "Invalid filter syntax"
You filter: "(RecipientType -eq
'UserMailbox') -and
(UserPrincipalName -notlike
('*@{1}' -f $UPNSuffix))"
This is not a good filter for anything.
This is not legal in a filter: (UserPrincipalName
-notlike ('*@{1}'
-f $UPNSuffix))"
See filter syntax for rules on the limited support for PowerShell syntax.   filters are a subset.
¯\_(ツ)_/¯

Similar Messages

  • I have upgraded my computer to program the MAC OS X but would like to remove this update and revert to the old one. Is this possible and how do I proceed?

    I have upgraded my computer to program the MAC OS X but would like to remove this update and revert to the old one. Is this possible and how do I proceed?

    Not easily, unless you backed up your data.
    Did you?  If not, let that be a lesson to never install anything without a backup:
    https://discussions.apple.com/docs/DOC-1992
    https://discussions.apple.com/docs/DOC-1948

  • I would like make 3D text and panel that controls the bevel is missing. How can I fix this?

    I was making 3D text, and when I went to create a new project, I had written out my text and made it 3D but the panel that controls the bevel wasn't available anymore. How can I make this panel visible?

    Open the Customize window via "View > Toolbars > Customize" or via "Firefox > Options > Toolbar Layout"
    Click the "Restore Default Set" button.
    * http://kb.mozillazine.org/Toolbar_customization

  • I canot remember my security questions answers , whene ever i want to dowload any applications i am required to answer them and because i have forgot them i am not able to download any application , i would like to cancel this option

    i canot remember my security questions answers , whene ever i want to dowload any applications i am required to answer them and because i have forgot them i am not able to download any application , i would like to cancel this option and only have the option to answer my password

    It isn't an option it is a permanent part of the security protocol, so you need to write the answers down in a secure location or remember them, you will always need them in the future.
    Call Apple Care for your country and ask for the Account Security Team, then request help resetting the questions.

  • How do you shuffle the image order when creating a new slideshow in apterture 3?  i would like to do this automatically when creating a new slideshow.  i see how you do it when you just play a slideshow.

    how do you shuffle the image order when creating a new slideshow in apterture 3?  i would like to do this automatically when creating a new slideshow.  i see how you do it with presets when you just play a slideshow, but i don't see an option to randomly shuffle the slide order when you create a new slideshow.  i know you can sort it by different fields, but i want it to be random.  thanks.

    If you want to rearrange images in random order you can try an AppleScript:
    retrieve a list of selected images from Aperture
    shuffe the list properly
    create an album in Aperture and add the images from the list to the album (make sure that the album set to be orederd manually)
    Here  is a sample script that shuffles the selected images and displays them in random order in Full Screen Mode:
    on removeItem(ims, i)
      -- remove the item at position "i" from a list ims
              if ims is {} then return {}
              if (length of ims is 1) then return {}
              if i < 2 then return rest of ims
              if (i = length of ims) then return (items 1 thru (i - 1) of ims)
              if i > (length of ims) then return ims -- should be error?
              return (items 1 thru (i - 1) of ims) & (items (i + 1) thru (length of ims) of ims)
    end removeItem
    on shuffle_items(ims)
      -- shuffle the items of the list "ims" randomly
              local numitems, ims_shuffled, nextrest, nextpick, i
              set numitems to length of ims
              if length of ims < 2 then return ims
              set ims_shuffled to {}
              set nextrest to ims
              repeat until nextrest is {}
                        set i to (random number (numitems - 1)) + 1
                        set nextpick to item i of nextrest
                        set beginning of ims_shuffled to nextpick
                        set numitems to numitems - 1
                        set nextrest to removeItem(nextrest, i)
              end repeat
              return ims_shuffled
    end shuffle_items
    on shuffleIms()
      -- retrieve the selected images from Aperture
      -- and display them in random order in full screen mode
              local imageSel, shuffled, i
              tell application "Aperture"
      activate
                        set imageSel to (get selection)
                        set shuffled to my shuffle_items(imageSel)
                        set fullscreen to true
                        if imageSel is {} then error "Please select some images."
                        repeat with i from 1 to count of shuffled
                                  reveal {item i of shuffled}
      delay 3 -- chnage that to the time you want
                        end repeat
                        set fullscreen to false
                        return shuffled
              end tell
    end shuffleIms
    shuffleIms()
    Some more code snippets to go from here:
    To create an album:
                        tell library 1
                                  if not (exists album "shuffledAlbum") then
      make new album with properties {name:"shuffledAlbum", image version:shuffled}
                                  end if
                        end tell
    And to add the images from the shuffled list to the album:
                        repeat with i from 1 to count of shuffled
                                  duplicate item i of shuffled to album "shuffledAlbum"
                        end repeat
    Regards
    Léonie

  • I want to be able to totally block the FaceTime functionality in my home network.  I would like to do this at the router level.  Does anyone know the hostname or IP address that the FaceTime application uses? Or which port it connects to?

    I want to be able to totally block the FaceTime functionality in my home network so my 4 kids aren't using the Facetime feature- It was easy for Skype just had to enter the work Skype on my Router Security list- and it denies access. I would like to do this at the router level for FaceTime? Only site I find in init.ess.apple.com - is this the startup site for Facetime?   Does anyone know a site I can block, hostname or IP address that the FaceTime application uses? Or which port it connects to?

    I would presume so, but it might be worth your while to experiment and play around with different combinations to see if you can block FaceTime while keeping Game Center open.  Good luck!

  • I just updated my latest java but the update is causing problems with some externale devices. So i would like to uninstall this latest java update and get back the previous one. That should solve to problems with my external device

    i just updated my latest java but the update is causing problems with some external devices. So i would like to uninstall this latest java update and get back the previous one. That should solve to problems with my external device.
    Is this possible and how do i do that?
    Anyone who responds thanks for that!
    Juko
    I am running
    Hardware Overview:
      Model Name:          Mac Pro
      Model Identifier:          MacPro1,1
      Processor Name:          Dual-Core Intel Xeon
      Processor Speed:          2,66 GHz
      Number of Processors:          2
      Total Number of Cores:          4
      L2 Cache (per Processor):          4 MB
      Memory:          6 GB
      Bus Speed:          1,33 GHz
      Boot ROM Version:          MP11.005D.B00
      SMC Version (system):          1.7f10
      Serial Number (system):          CK7XXXXXXGP
      Hardware UUID:          00000000-0000-1000-8000-0017F20F82F0
    System Software Overview:
      System Version:          Mac OS X 10.7.5 (11G63)
      Kernel Version:          Darwin 11.4.2
      Boot Volume:          Macintosh HD(2)
      Boot Mode:          Normal
      Computer Name:          Mac Pro van Juko de Vries
      User Name:          Juko de Vries (jukodevries)
      Secure Virtual Memory:          Enabled
      64-bit Kernel and Extensions:          No
      Time since boot:          11 days 20:39
    Message was edited by Host

    Java 6 you can't as Apple maintains it, and Java 7 you could if you uninstall it and Oracle provides the earlier version which they likely won't his last update fixed 37 remote exploits.
    Java broken some software here and there, all you'll have to do is wait for a update from the other parties.

  • I am a novice.  I just bought a nikon d5200 and would like to know which Photoshop would serve me well at this juncture.  I do not plan on becoming a professional, but would like to be able to edit and enhance the photographs that I will take.  With sever

    I am a novice.  I just bought a nikon d5200 and would like to know which Photoshop would serve me well at this juncture.  I do not plan on becoming a professional, but would like to be able to edit and enhance the photographs that I will take.  With several Photoshop programs on the market please advise me as to which I should purchase for the purposes I described ?

    I am a novice.  I just bought a nikon d5200 and would like to know which Photoshop would serve me well at this juncture.  I do not plan on becoming a professional, but would like to be able to edit and enhance the photographs that I will take.  With several Photoshop programs on the market please advise me as to which I should purchase for the purposes I described ?

  • I have an old Ipod shuffle that was synched to a different apple ID on a different computer.  I would like to access this playlist and transfer the music to my current id.  Is this possible?

    I have an old Ipod shuffle that was synched to a different apple ID on a different computer.  I would like to access this playlist and transfer the music to my current id.  Is this possible?

    thanks kiltedTim its working your right it appears as they same game and now i can purchased and buy and item using my new apple id thanks a lot your a great help, Oppps i have one more questioned on it you have any idea how to changed a country regioned that still have a store credit balanced of point .23$ i want to changed it into the japanes store that which i have and itunes card, 

  • My MacBook Air's storage is full.   When I look at the storage, most of what is taking up the space is "other".  I am not sure what these application or documents are but would like to reduce this so that I can store more pictures to edit.  Any advice?

    When I look at the storage, most of what is taking up the space is "other".  I am not sure what these application or documents are but would like to reduce this so that I can store more pictures to edit.  Any advice on how to find out what takes up this much space so that I can clear some off? 

    Freeing Up Space on The Hard Drive
      1. See Lion's Storage Display.
      2. You can remove data from your Home folder except for the /Home/Library/ folder.
      3. Visit The XLab FAQs and read the FAQ on freeing up space on your hard drive.
      4. Also see Freeing space on your Mac OS X startup disk.
      5. See Where did my Disk Space go?.
      6. See The Storage Display.
    You must Empty the Trash in order to recover the space they occupied on the hard drive.
    You should consider replacing the drive with a larger one. Check out OWC for drives, tutorials, and toolkits.
    Try using OmniDiskSweeper 1.8 or GrandPerspective to search your drive for large files and where they are located.
    What is "Other" and What Can I Do About It?- Apple Support Communities

  • I have a non intel G5 and would like to download i-tune songs that I have recently purchased. I have tried everything and can't find the downloads. Did this G5 just become obsolete with itunes? If not what is the problem?

    I have a non intel G5 and would like to download i-tune songs that I have recently purchased. I have tried everything and can't find the downloads. Did this G5 just become obsolete with itunes? If not what is the problem?

    You can do it with Leopard but it depends upon the iTunes version which you did not reveal.  Also make sure you are looking in the right place for purchases.
    Consider buying a backup drive so you do not need to do this again.  If you are going to run old hardware and software you need to live differently because yes, at some time you will find your version of iTunes no longer works.  You're lucky it still works with Leopard.  As you can see, some versions still work with the iTunes Store but not for repeat downloading.
    Downloading (using iOS or computer) past purchases from the App Store, iBookstore, and iTunes Store - http://support.apple.com/kb/ht2519 - enabled with iTunes 10.3 and newer; not all media formats are available in all countries (see: iTunes in the Cloud, iTunes Match, and iTunes Radio availability by country - http://support.apple.com/kb/HT5085); apps, books (not audiobooks), music, t.v. shows, and movies (some - not all studios have permitted this).  Downloading previously purchased movies and TV shows requires iTunes 10.6 or later.  Discontinued items not available. For items not included in the iCloud list (e.g., ringtones, audiobooks), or locations or computer systems where iCloud is not (yet?) available, you only get one download per fee paid.  Apple recommends,  "... back up your iTunes library. " (http://support.apple.com/kb/ht2519).
    Additional tip at https://discussions.apple.com/message/24176756#24176756
      Select the iTunes Store on the left side of iTunes if you have the sidebar displayed, or with the button at the top right.
      Click on Purchased on the right side under Quick Links (see https://discussions.apple.com/message/26364186#26364186)
      You can re-download your available previous purchases.

  • Can I sync my iPad (purchased first) with my iPhone (purchased second). I have apps on my iPad that I would like to sync to my iPhone before giving the iPad to my little sister. Help!

    I received the iPad a little over a year ago as a gift from my parents. I loved it so much that I purchased the iPhone4S and I was wondering if it were possible to transfer the Apps that I previously purchased on the iPad to my iPhone. If this isn't possible can I ask why not? I don't understand why purchasing something and paying good money for it doesn't make it truly yours to be used on your devices. I want to give the iPad to my little sister and have my parents set up a new account and "refresh" the iPad (if you can even do that) for her but I'm afraid of losing the Apps that I paid good money for just for them to dissappear. I just want to make the iPad something my sister can call her own. Right now it is connected to me and my account so I would like to change this as well if possible. I am eager to learn more and I look forward to any responses. Thank you for your time.

    If you want to have the mostly same content on both devices - it probably makes more sense to restore your iPad from the iPhone backup. this will put all of your app settings and email settings onto the iPad and any app data and game saves as well will transfer to the iPad.
    You still want to sync the iPad so that all of the apps and photos that are in your iTunes library transfer over to the iPad. Restoring from the backup doesn't restore apps, music, synced photos, movies, books, TV shows and podcasts - you will still need to sync that content to the iPad.
    I have pretty much have the same content on my iPad and on my Touch, but I eliminated the Movies and TV shows from the Touch and some apps as well. Remember that iPhone specific apps may run OK on the iPad - they will run in the iPhone smaller screen size and while you can double the size by tapping on the 2X button in the apps, they will be lower resolution because you just doubling the size of the pixels and the apps look kind of crappy on the iPad - they may work - they just look bad.
    I do not auto sync at all. Nor does iTunes open automatically when my iDevices are connected. I start iTunes on my own and I select all of the content - piece by piece - app by app and so on - as I go along. Once you get through the initial set up - iTunes remembers each device and it's content for the next time that you sync.

  • Would like to automate open stacks as layers + run action. Possible with script??

    I would like to automate part of my workflow that involves opening stacked images as layers in Ps CS5 and running an PS action that composites the layers and processes the image. Something similar to 'Process Collection' in Bridge CS5 only with my own action instead of merge to HDR/Panorama.
    Apparently this is possible with Mac 'Automator' - is there anything I can do in Windows? I don't have any experience with writing scripts, but have friends that can help. Can someone tell me if its possible and point me in the right direction please?

    Sorry but a script can not access Lightroom so your first step isn't possible.
    Second step is Lightroom not Photoshop.
    Maybe something could be done if you could work out a Photoshop Only workflow.

  • I have a 4 gen Time Caps. and a 2nd Gen Airport Extreme I would like to extend my TC network to use the Extreme for the purpose of having internet available to my TV box wired.  Is this possible and how to I get them to work together?

    I have a 4 gen Time Caps. and a 2nd Gen Airport Extreme I would like to extend my TC network to use the Extreme for the purpose of having internet available to my TV box wired.  Is this possible and how to I get them to work together?
    How can I get my Time Cap (TC 4 gen) to recognise my 2gen Airport Extreem (AE)
    Frank

    Thanks for the info, this really helps.
    Power up the AirPort Extreme for a few minutes, then hold in the reset button on the back of the Extreme for 10 seconds and release. Allow a full minute for the Extreme to restart to a slow, blinking amber light.
    It might be possible to use wireless to configure the Extreme, but I recommend using a wired connection. Temporarily, connect an Ethernet cable from your Mac to one of the LAN <-> ports on the Extreme.
    Click the AirPort icon at the top of the Mac's screen and wait a few seconds for a listing of New AirPort Base Station to appear. Just below that, click on  AirPort Extreme.
    The illustration below shows an AirPort Express. You will see AirPort Extreme on your screen.
    AirPort Setup will open up automatically and take a minute to analyze the network, then announce that the Extreme will be configured to extend the Time Capsule network.
    Enter a device name that you want to use for the Extreme and click Next
    Wait a minute while AirPort Setup configures things for you. When you see the message of Setup Complete, click Done.
    You can disconnect the Ethernet cable that you used for the set up now. Things should be working. The Extreme is providing additional wireless coverage the the Ethernet ports are enabled. You can connect to any port that you want since they all operate the same in this type of setup.

  • TS3682 i have recently update ios6 but it's not responding so i would like to backup this update, how colud i do so?

    i have recently update ios6 but it's not responding so i would like to backup this update, how colud i do so?

    What is not responding?
    Did you perform the update via iTunes orover the air?
    If iTunes, then all your data is backed up automatically.
    Did you make sure to use only the latest version of iTunes (10.7 for PC users)?
    If you are saying you want to leave IOS 6 and go back to 5, that is not possible. Apple stops signing previous builds typically within 24 hours from launch.

Maybe you are looking for

  • Can't select/change layers in main work area

    Been working with PSE11 for a few months.  Yesterday it developed a problem.  I can no longer click on the layer in the main work area but have to go to the layer panel to select it.  What do I need to do to change this back to where it works like it

  • "1046: Type was not found" for a custom class calling a custom class

    This should be easy... but I've spent two days on nothing but this error.... I am absolutely at my wit's end. Basically, I've got a "character" container linked to a MovieClip in the library that is supposed to act as a container for various body par

  • Enserver not starting up during installation of CE 7.1

    Hi, I am trying to install Netweaver CE version 7.1 SP5 on windows XP. In the installing phase configure UME it stops saying "Instance CE1/SCS01 [PARTIAL] did not start after 5:00 minutes. Giving up.)". and when i checked the log i can see the server

  • BAPI returns PDF

    Hi all, Am trying to implement a BAPI that rerutrns a PDF to a webdynpro. I create the PDF from a smartform through FM 'CONVERT_OTF_2_PDF'. Now this FM returns a table of type TLINETAB, and when a try to put a parameter of the same type in my BAPI i

  • After installing Adobe Flash Player latest update unable to watch iplayer due to "plug-in failure"

    the Adobe Flash player update instruction showed on screen.  I followed the simple install instructions.  It stated everything had installed successfully, but when I tried to watch iplayer programme the message: plug-in failure appeared, and I was un