I am working on a script that will gather user details such as basics like the DisplayName, Description, Employee ID #, and Telephone Number.
The challenge is that I have to remove some of the phone number. I want to keep only the last 8 characters, which should (in 99% of instances) be 765-4321
Can anyone help me do this? I have to query AD using Quest as we have a Windows 2003 domain with no AD Web Services running. I can get the user details for all users in the domain, but I think I've got to limit this to a 1 main OU and sub-ous under that main OU, that's the only part of the gathering data I think I need some help with. Then I think I was ok with the rest, but any help would be great. The end result is I need to send this out as an email or perhaps save it to a file share in csv format.
Thanks as always, you are all great!
It would be helpful if you could post the exact string you're getting back. You could replace the phone number with all 5's but it would help to see what you're up against.
In PowerShell generally speaking you would probably use the replace method or the -replace operator. However if you can master the discipline of regex (Regular Expresions) it is a more powerful way of dealing with this sort of an problem.
# The Replace Method takes arguments in the parenthesis 2 strings separated by a comma the left most being what you want to get rid of the right being what to replace it with
If you want to take the regex approach!
Not my specialty!
You must be logged in to reply to this topic.