AD user script to populate the IPPHONE attribute with the last 4 digits of the Telephonenumber attribute
Good Afternoon Scripting Guys. I have a script that I have been working with pretty much all day today and just cant quite get it to play nice. Our objective is to search AD for specific users (say filtering them out with a username that starts with a "T")
and User account is "Enabled" then grab the last four digits of their phone number (phone number is set up as follows: (800) 123 456 ) then populate the IPPHONE attribute with the last four digits of their phone number. I have read a ton of online
blogs with users successfully making this happen but it appears that they are all using Quest (as the commands are all Get-qaduser and Set-qaduser). I need something that runs strictly in native Active Directory Module PowerShell on a Windows Server 2008r2
Domain Controller. I am also trying to keep it as simple as possible by using a Get command, then piping a Set command. I have saved the script into a .ps1 file with the logic as follows:
$SelUsers = Get-ADUser -filter {(SamAccountName -like "t*")} -Properties ipphone,telephonenumber -searchbase "OU=Test Users,OU=Temporary Org,OU=Test_Domain Users,DC=mydomain,DC=com" | where {($_.enabled -eq $True)}
foreach ($user in $SelUsers)
{$user.ipphone = $user.telephonenumber(4,$User.telephonenumber.length-4)
set-aduser -instance $user}
What is happening is kind of funny, but aggravating at the same time. When we run the script, it completes with no errors. When I pull up the properties of a user in the OU, the IP Phone field is populated with the number 8. If the User
account did not have a telephone number, the IP Phone field is populated with a -4. So, apparently, the script is somehow subtracting the "-4" from the number of all of the Telephone Number field's characters. Basically 12-4 is 8.
If there is no telephone number, then 0-4 is -4. I have run the Get-ADUser portion of the script independently so I know its getting the correct users. I also know it is populating the IPPHONE attribute but not with the last 4 digits of the telephone
number. Can you guys help out and maybe get this to work correctly? Also, can you add logic to it to the script to delete any value in the IPPHONE field first, then replace it with the last 4 digits of the telephone.
Any help would be GREATLY appreciated!!!!! Thanks Guys...
Lee
First thing I would do is modify your filtering. This will remove the unneeded piping to the Where-Object cmdlet and also allow us to only return users who already have something in the telephoneNumber field. It is possible this could return all of your
users, but if you have service accounts, etc. that do not have a telephoneNumber then they will not be included in your results. It's just a little cleaner.
$SelUsers = Get-ADUser -filter {(SamAccountName -like 't*' -and Enabled -eq $True -and TelephoneNumber -like '*')}
I suspect you may have a made a mistake when you entered what your phone numbers looks like. I assume that you forgot a final digit. If this is correct, and you have a space in the phone number between the three digits and the final four then you can use
the split method to grab the last four digits.
Foreach ($User in $SelUsers) {
$Number = $User.telephoneNumber.split(' ')[-1]
Set-ADUser -Identity $User -Replace @{ipPhone=$Number}
There's no reason to delete what's in the field first because that's part of what the -Replace parameter will do anyway. This should help get you started!
Similar Messages
-
Would like to use 4nr iPads as an autocue system. Can I view the same pdf on multiple iPads at the same time with 1 iPad operating as the master (controlling page turns etc) and the others operating as slaves? Can this be done without the use of 3G or a remote Wifi hub? I would appreciate your input.................
Open the document in Acrobat Reader and use the menu Window > New Window.
-
I have 2 ipod touches. I backed up the new one with old's info. The old one will not unlock with the password I had wrote down and I tried my new ones password. How can I reset the old ipod without affecting the new one and how can I unlock the old one?
Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
iOS: Wrong passcode results in red disabled screen
If recovery mode does not work try DFU mode.
How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
For how to restore:
iTunes: Restoring iOS software -
My IPOD Touch initially had a white screen. I tried correcting this by restoring default settings via ITunes. The Restore Failed with error 1602 and now the IPOD touch is completely dead. It will not power on or respond when I plug it into my PC via USB. I get an error on my PC stating that device attached to USB port is not recognizable. Can anyone help?
Error 1602: Try the following steps to resolve this error:
Ensure proper USB isolation troubleshooting has been performed, and test with a known-good cable.
Follow the steps listed for Error 1604.
This error may be resolved by disabling, deactivating, or uninstalling third-party security, antivirus, and firewall software. See steps in this article for details on troubleshooting security software.
Above from:
http://support.apple.com/kb/TS3694 -
I have a problem with iphoto (have a mac book pro): the icon in the dock appears with a question mark, and the application is gone!!! Can someone tell what's going on? Yesterday I had the same problem with itunes: I downloaded the last version (it's free), but I cannot do the same with iphoto, and more important: I need to know what is happening!!! Please help me!
Applications should not disappear all by themselves.
If they are then that coud indicate serious problems with your hard drive.
Backup everything up as quickly as possible.
Using Disk Utility verify your system disk.
Allan -
The BPM stops, with a "green flag " in the sxmb_moni enrty
i have a file to file with a BPM,
the BPM contains:
1. a loop which runs five times which contains a receive step with [start transaction] and a using and activating correlation value.
2. a container step that appneds the messages picked one by one through each iteration of loop into a multiline container.
3. a send step.
the purpose is to collect 5 files with a particular correlation value and merge them and send them,
the problem is, as soon as the file is picked and the message is received at the receive step, the BPM stops, with a "green flag " in the sxmb_moni enrty,
i cant make out anything from the PE in the moni entry....
is it some problem with the correlation......help me out...yes Raj,
i have a transformation step ...that transforms the content of the multiline container into a normal container before sending.............
this is the problem, i can never see the wait symbol, and
its sometimes strange, some times the process ends with "red flag" on the outbound side (right hand side of the moni entry)...
i can see the graphical............
i forgot to mention...all the steps are in a block....
so in the graphical wf log, i can see an error at the entry of the block, except that there is no error..... -
about a yar ago my ipod went off and wouldnt turn on. i can finallly get it to turn on now but all it will show is a screen of the aple charger with and arrow pointing to the circle itunes app. does anyone know how to fix this?
Connect the iPod to your computer and restore via iTunes
iTunes: Restoring iOS software -
I use a mac ios and shoot raw in a cannon 5d mark ii and shortly upon import of my images lightroom darkens and changes my images. This has happened before but not every time. The strange part is my last shoot had the same camera setting but this did not happen. The images i have now i can not use after lightroom has automatically altered them even if i try editing back to how they looked upon import
First thing to do is to change the default camera profile applied in Lightroom to camera standard (assuming that you shoot Canon or Nikon). Also make sure that your camera is NOT set up to use any of the HDR modes. Nikon calls those Active Dynamic Lighting. On Canons you often see things like highlight priority mode or "Auto Lighting Optimizer". Make sure that the picture style is set to standard and that for newer Canons the HDR mode is turned off. Most of the HDR modes simply underexpose the image and then add an instruction in the raw file to compensate for this to prevent highlights from being blown out. This causes more noise in the shadows and if you know what you are doing there is no point to this as you should simply expose correctly and get the highest quality raw.
Lastly, make sure that in Lightroom you have not checked "Apply Auto Tone Adjustments" in Preferences->Presets. This should make the default rendering of the raw files the same as the in-camera jpeg (what the camera shows on the back even if you shoot raw) but still give you all the latitude of raw files. -
I purchased a song on iTunes and it shows up in the song list with an exclamation point on the side of it. It says the song could not be found. I have done a search and can't find it but iTunes won't let me download or buy it again. Help!!
Hello levon10
Just delete the song and then go through the process of downloading the purchase again.
Downloading past purchases from the App Store, iBookstore, and iTunes Store
http://support.apple.com/kb/ht2519
Thanks for using Apple Support Communities.
Regards,
-Norm G. -
Enhancing the component ERP_H with a custom field in the web UI
Hi,
I'm facing an error when enhancing the component ERP_H with a custom field in the web UI.
I've followed the steps mentioned in the pdf document called "Enhancement Options for the Lean Order Interface" (Note
1224179):
I´ve done a enhacement on ERP_H component.
I added a field to the view Headerdetail called "ZZCCTYPE1", but when I set a value in UI, I haven´t read this field in abap code.
The SET method (SET_ZZCCTYPR1) in the context node is ok, in debug I see that the method current->set_property, is working fine.
I've tried to read the atribute with lr_entity->get_property_as_string ( 'ZZCCTYPR1' ), but doesn´t work. When I read other "standard field", the statement is ok and it has value.
When I set the value of the field from ECC (VA01/VA02), it is kept by the system.
Could anybody help me?
Thanks in advance,
Regards,
Andrea RicciHi Pooja,
When you created your custom views, did you bind the view context nodes to the corresponding context nodes of your component controller?
From the exceptions you reported it seems that this binding is missing.
To create this binding, you can right click on your view context node , choose "Create Binding" and bind it to the context nodes of your Component Controller.
Hope this helps.
Regards,
Nisha -
Hello I have a problem in my phone The email request with Psoard forgotten I bought the phone by bringing the two years I have Vetorh with carton I want to help you thank you
Hi mylenebar!
Here is an article that will help you remove the desired photos from your phone:
iTunes: Syncing photos
http://support.apple.com/kb/ht4236
To delete synced photos and videos from your device
In iTunes, click the Device button in the upper right corner. (If viewing the iTunes Store, click the Library button in the upper-right corner first.)
Click the Photos tab in the resulting window.
Choose "Selected albums" and deselect the albums or collections you want to delete.
Note: To delete all synced photos, deselect "Sync Photos from" and, when asked, click "Remove photos."
Click Apply.
Thanks for coming to the Apple Support Communities!
Cheers,
Braden -
iPad went black and has the apple logo with a little wheel at the bottom. Tried turning on and off doesn't work.
Try a Reset...
Reset ( No Data will be Lost )
Press and hold the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears. Release the Buttons.
http://support.apple.com/kb/ht1430
If no joy...
Connect to iTunes on the computer you usually Sync with and “ Restore “...
http://support.apple.com/kb/HT1414 -
My email on my iPhone 4 doesn't notify me of a new email until I actually go into my mail. My wife's iPhone 4 shows her on the home screen with a red number on the icon. Why is this?
You don't have push enabled. Go into your settings and enable it, however many people will want to advise you that doing so will reduce your battery life.
-
I am facing a problem with my iPhone 4. I applied the first syncing with outlook 2007 by choosing the "merge" option. At the end of the process, some contacts are correctly sync, but most are only sync with the names. Numbers are lost. Any suggestion?
I would love to do this as well. All I need is my calendar appts from outlook. Right now I am using google calendar sync, but I would like to move to the cloud and away from google. I find it hard to believe there isn't an option to do this.
-
My MS outlook on the PC is sending two invites in the icloud calandar. How can I stop this? I ony want the email send with my email address not the apple email.
My phone is the 4. Not the 4s. And I went there but it's nowhere the option to delete from server.
I only see: ask before deleting and it's on. -
I have replaced an app purchased on the app store with a newer app from the app store . How can I sell/give away my old software?
iTunes App Store/Mac App Store content can't be resold or given away. If desired, click here and ask for a refund.
(119373)
Maybe you are looking for
-
File to SAP R/3 custom table using PI
Hi , Any once can help me with File to Custom table updation possibilities using PI. Regards, Kiran
-
Can I use the guest network on a AE connected to a Cisco RV180?
I have not been able to connect to the guest network on my AE with a Cisco RV180 as the gateway. I read in an older post that the guest network my not work on all equipment, that it must be connected to a "simple" modem. Just want to find out if the
-
Hi, i just upgraded from a curve 8520 to a bold 9700 and its going really slow, so i want to update the software. I have desktop manager but when i plug my phone in it says that there are no new software updates. how do i update the software then. do
-
Comment optimiser vitesse de boucle pour grab
Bonjour, J'ai construis un VI qui a pour but de faire le grab d'une camera GigE (1946*1436 ; 40FPS), de pouvoir faire un zoom sur une ROI et de piloter 2 boitiers de commande de platines de translation (GPIB). Le problème que j'ai est le suivant : La
-
IPhoto 7.1 and Spotlight in OS X 10.4.11
I've invested considerable time and energy in endowing photos in iPhoto 7.1 with keywords and comments, only to discover that Spotlight doesn't seem to be using all this information. I'm only able to find photos with names that contain the character