• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 398
  • Last Modified:

How do I write a simple Exchange Management Shell Script

How do I write a simple script in Exchange Management 2007 Shell and save the results to a file?  The results should have the following headings User's Name (not username), Title, Department and email address.  And the filter should be based on 3 different departments in the same report.  Your help is greatly appreciated!
0
silviomel
Asked:
silviomel
  • 2
1 Solution
 
Chris DentPowerShell DeveloperCommented:

Something like this:

Get-User -Filter "Department -Like '*Department*' -Or Department -Like '*OtherDepartment*' `
  | Select-Object Name, WindowsEmailAddress, Title, Department

To export that to a file you can change it to:

Get-User -Filter "Department -Like '*Department*' -Or Department -Like '*OtherDepartment*' `
  | Select-Object Name, WindowsEmailAddress, Title, Department | Export-CSV "out.csv"

Chris
0
 
Chris DentPowerShell DeveloperCommented:

Sorry, I missed a closing " from the command above which will cause it to fail. Corrections here:

Get-User -Filter "Department -Like '*Department*' -Or Department -Like '*OtherDepartment*'" `
  | Select-Object Name, WindowsEmailAddress, Title, Department

To export that to a file you can change it to:

Get-User -Filter "Department -Like '*Department*' -Or Department -Like '*OtherDepartment*'" `
  | Select-Object Name, WindowsEmailAddress, Title, Department | Export-CSV "out.csv"

Chris
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now