I was hoping someone could help with what I thought was somthing simple. I have a PowerShell script that reads a file of email addresses then executes an Exchange O365 command and creates a CSV file. This works great. However, I was hoping to include in the output line the contents of the variable used in the input. In other words possibly concatenate it to the output of the command.
$Emails = Get-Content "C:\Allqueue.csv"
foreach ($Email in $Emails) {
Get-MoveRequest $Email |
select displayname, alias, UserPrincipalName |
Export-Csv -Append "C:\AllqueueResults.txt"
}
Unfortunately, the Get-Mailbox
results do not include the email address, so it can't be used in the select statement.
My initial attempt was to just add $Email
to the select statement like this.
select displayname, alias, UserPrincipalName, $Email
But that just created a column.
Any help would be greatly appreciated.
您可以使用带有计算属性的电子邮件地址添加新列:
select displayname, alias, UserPrincipalName, @{n='Email';e={$Email}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.