Hi, I'm trying to combine a double filter to get a selection of users from a securitygroup. In the script below I want to ad a filter like I'm using in Objectscipt but I can't find the right format. I want the users with no initials to be excluded
in the result.
How can I fix this?
This is the part from the objectscript:
ForEach-Object {Get-ADUser -Filter * -Properties * | Where {($_.Initials -ne $null)}
This is my script for exporting nested users:
Import-Module ActiveDirectory
$securitygroup=Read-Host "Please enter the securitygroup to export"
$path =Read-Host "Please enter the existing (local) export path (like c:\temp)"
Get-ADGroupMember -Recursive $securitygroup |
#----------------------------------------------------------------------------------------
ForEach {Get-ADUser -filter {samaccountname -eq $_.SamAccountName} -Properties Department, info, description, Office, MobilePhone, ipPhone, company, initials, GivenName, EmailAddress, Surname, SamAccountName
} | Sort-Object company,displayName |
#----------------------------------------------------------------------------------------
#Format-Table Department, info, description, Office, MobilePhone, ipPhone, company, initials, GivenName, EmailAddress, Surname, SamAccountName -AutoSize |
select Department, info, description, Office, MobilePhone, ipPhone, company, initials, GivenName, EmailAddress, Surname, SamAccountName | export-CSV -path $path\"$securitygroup.csv" -Encoding UTF8 -NoTypeInformation