Hi all, what am I missing here? how do I make this script output each of the users in $file? Did I set the array up wrong or something? When this is run, both users should show in output. I can only get one user to show.
$ErrorActionPreference = "SilentlyContinue" $file = "kari.nordmann", "ola.nordmann" foreach ($user in $file) { $aduser = get-aduser -identity $user ` -properties DisplayName, SamAccountName, LastLogonDate, WhenChanged, PasswordLastSet, Modified, ProxyAddresses | select DisplayName, SamAccountName, LastLogonDate, WhenChanged, PasswordLastSet, Modified , ProxyAddresses $properties = @{ DisplayName = $aduser.DisplayName Email = $aduser | select -ExpandProperty ProxyAddresses | ? {$_ -clike "SMTP:*"} } $output = New-Object -TypeName PSObject -Property $properties } $output
submitted by /u/nappetass
[link] [comments]
The post get-aduser with custom properties output only one user or the last appeared first on How to Code .NET.