Jump to content

Recommended Posts

Posted

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

Posted (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 by benjie
Posted

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"

Posted

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"

Posted

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"

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...