Skip to content

Instantly share code, notes, and snippets.

@jeremytbrun
Created February 27, 2019 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremytbrun/e08f7e52ae5a5a15035017ac1f210a56 to your computer and use it in GitHub Desktop.
Save jeremytbrun/e08f7e52ae5a5a15035017ac1f210a56 to your computer and use it in GitHub Desktop.
Get-MailboxShowNulls
$empid = import-csv c:\Temp\Emp_ID_Import.csv
$empid | ForEach-Object {
$PSObj = New-Object PSObject -Property @{
SamAccountName_Input = $_.SamAccountName
}
$Mbx = Get-Mailbox -Identity $_.SamAccountName -ErrorAction SilentlyContinue
if ($Mbx) {
$PropHash = @{}
$Mbx.PSObject.Properties | ForEach-Object {$PropHash[$_.Name] = $_.Value}
$PSObj | Add-Member -NotePropertyMembers $PropHash
}
Write-Output $PSObj
} | Select SamAccountName_Input, Name, Alias, UserP* | Export-Csv C:\PSExport\MailEXP.csv -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment