Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Going Crazy, Need help with Powershell script

$
0
0

Here's the relevant section.  The problem I'm having is the calculated property for Manager Name and Manager Email is inconsistent.

For some users the below is returning empty values.  Check the #comment section, I've tried that way to.

I don't get what's going on, if I query those individual users (Get-Mailbox user then pipe the rest) it will come back with the calculated property just fine. 

If I run this section and watch the output, it looks like its walking the domain each time for the calculated value which is odd since the $_.manager is a DN value (assuming it isn't null) so the value should also be returned immediately.

FYI, This is Exchange Cmd-lets opened by Remote Powershell

Get-Mailbox -OrganizationalUnit someOU -ResultSize Unlimited | Get-User | Select @{N="Email Address";E={$_.WindowsEmailAddress}},
     @{N="First Name";E={$_.FirstName}},
     @{N="Last Name";E={$_.LastName}},
     @{N="Department";E={$_.Department}},
     @{N="Job Title";E={$_.Title}},
     @{N="Manager Name";E={Get-User $_.Manager | Select -ExpandProperty DisplayName}},
     @{N="Manager Email";E={Get-User $_.Manager | Select -ExpandProperty WindowsEmailAddress}} | Export-Csv -notype $path$file
     #@{N="Manager Name";E={$mgr = Get-User $_.Manager;$mgr.DisplayName}},
     #@{N="Manager Email";E={$mgr = Get-User $_.Manager;$mgr.WindowsEmailAddress}} | Export-Csv -notype $path$file




Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>