This script will help to Administrator to export the AD users with required Properties.
In this given examples we have Email Address of the the AD users (called as Identity), with the help of this given Identity we will export the users with required properties .
# This is script is used to export the users Properties by any Specific given Identity in Active directory
# Here we have emmail Address of the users, we will export other properties of the users.
$Table = @()
# List of users identity like emailID,UPN,loginID etc
$list= Get-Content C:\Temp\mail.txt
foreach($item in $list){
$user=Get-ADUser -Filter{EmailAddress -like $item} -Properties *
$hitemDetails = New-Object -TypeName psobject -Property @{
username=$user.SamAccountname
Name=$user.GivenName
lastpwset=$user.PasswordLastSet
PW=$user.pwdLastSet
Email=$user.EmailAddress
}
$Table +=$hitemDetails }
# Output as CSV file
$Table|Export-Csv -Path C:\Temp\result.csv
In this given examples we have Email Address of the the AD users (called as Identity), with the help of this given Identity we will export the users with required properties .
# This is script is used to export the users Properties by any Specific given Identity in Active directory
# Here we have emmail Address of the users, we will export other properties of the users.
$Table = @()
# List of users identity like emailID,UPN,loginID etc
$list= Get-Content C:\Temp\mail.txt
foreach($item in $list){
$user=Get-ADUser -Filter{EmailAddress -like $item} -Properties *
$hitemDetails = New-Object -TypeName psobject -Property @{
username=$user.SamAccountname
Name=$user.GivenName
lastpwset=$user.PasswordLastSet
PW=$user.pwdLastSet
Email=$user.EmailAddress
}
$Table +=$hitemDetails }
# Output as CSV file
$Table|Export-Csv -Path C:\Temp\result.csv
No comments:
Post a Comment