samwells1234 Posted January 28, 2015 Posted January 28, 2015 Hi Guys, Anyone know how to extract pagers numbers from active directory. Reason being that the pager numbers are linked to paper cut as pin codes. I need to print out a list of the users with their pin codes. Kind Regards Sam Wells
benjie Posted January 28, 2015 Posted January 28, 2015 (edited) Hi, Hope this helps. This is a powershell script that gets the Firstname, Surname, SamAccountName and Pager number from AD and outputs it to a CSV file. Import-Module ActiveDirectory $user=Get-ADUser -SearchBase "OU=OU,OU=OF,OU=Student,OU=Users,DC=domain" -filter * -Properties Pager $outArray = @() foreach ($i in $user) { $outArray += New-Object PsObject -Property @{ 'Firstname' = $i.GivenName 'Surname' = $i.Surname 'Username' = $i.SamAccountName 'Pager' = $i.Pager } } $outArray | Export-Csv "C:\Pager.csv" Edited January 28, 2015 by benjie
benjie Posted January 29, 2015 Posted January 29, 2015 I forgot to mention you need to change the second line where it say "OU=OU,OU=OF,OU=Student,OU=Users,DC=domain" to the actual path of the OU you want to export. You can also change the path it exports to on the last line. I have just set it to export to "C:\Pager.csv"
samwells1234 Posted January 29, 2015 Author Posted January 29, 2015 I am new to this scripting and network so im not sure what you mean by the path but these are the changes i have made Import-Module ActiveDirectory$user=Get-ADUser -SearchBase "OU=OU,OU=OF,OU=staff,OU=Users,DC=wpdomain.local" -filter * -Properties Pager $outArray = @() foreach ($i in $user) { $outArray += New-Object PsObject -Property @{ 'Firstname' = $i.GivenName 'Surname' = $i.Surname 'Username' = $i.SamAccountName 'Pager' = $i.Pager } } $outArray | Export-Csv "C:\Pager.csv"
benjie Posted January 29, 2015 Posted January 29, 2015 Using this instead, it will export all users in your domain: Import-Module ActiveDirectory $user=Get-ADUser -filter * -Properties Pager $outArray = @() foreach ($i in $user) { $outArray += New-Object PsObject -Property @{ 'Firstname' = $i.GivenName 'Surname' = $i.Surname 'Username' = $i.SamAccountName 'Pager' = $i.Pager } } $outArray | Export-Csv "C:\Pager.csv"
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now