I made a CSV file (files1.csv) each day with the following command (I want to reuse this files for generate others reports).
Get-Mailbox -ResultSize 1000 | Get-MailboxStatistics |Select * | Sort "DisplayName" -Descending | Export-CSV files1.csv -Encoding UTF8 -NoTypeInformation -Delimiter ";"
The result is a file with more than 100 columns and many lines with data of my AD365 account.
I want to produce reports but with only certain columns (not all).
Is it possible to put the columns I want in a variable $M_COLUMNS and use a FOR to display the content of this columns.
$M_COLUMNS = "DisplayName","ObjectId","ObjectType","AccountEnabled","IsCompromised","PasswordPolicies"
I know I can use this command :
$_.DisplayName+";"+$_.ObjectId+";"+$_.ObjectType+";"+$_.AccountEnabled+";"+$_.IsCompromised+";"+$_.PasswordPolicies | Out-File -FilePath reports1.csv -Append -NoNewline
But if I can replace the above line with a FOR, I would appreciate…