I am collecting birthday and other informations from Activedirectory
using this
Get-ADUser -Filter {(extensionAttribute4 -like "Aktiv") -and (Enabled -eq $true)} -SearchBase "OU=*****,OU=*****,OU=*****,DC=*****,DC=****" -Properties * | select name, mail, extensionAttribute1
extensionAttribute1 is the birthday and are type duble. It is possible to convert the double to a date with this:
$date.AddDays(+27137).ToString("dd-MM-yyyy")
but how do I use it in this code:
Get-ADUser -Filter {(extensionAttribute4 -like "Aktiv") -and (Enabled -eq $true)} -SearchBase "OU=*****,OU=*****,OU=*****,DC=*****,DC=****" -Properties * | select name, mail, extensionAttribute1
未经测试,但是您可以尝试-
Get-ADUser -Filter {(extensionAttribute4 -like "Aktiv") -and (Enabled -eq $true)} -SearchBase "OU=*****,OU=*****,OU=*****,DC=*****,DC=****" -Properties * | select name, mail, @{ Name = 'Birthday'; Expression = {$date.AddDays(+27137).ToString("dd-MM-yyyy")}}
Given your extra information, and @VivekKumarSingh's answer, the following should show the correct information:
Get-ADUser -Filter {(extensionAttribute4 -like "Aktiv") -and (Enabled -eq $true)} `
-SearchBase "OU=*****,OU=*****,OU=*****,DC=*****,DC=****" `
-Properties * |
Select-Object Name, Mail, @{ Name = 'Birthday'; Expression = {$date.AddDays($_.extensionAttribute1).ToString("dd-MM-yyyy")}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.