2 Answers
2

There's no $_ variable when piping from one cmdlet to the next directly. So Set-Mailbox is seeing a $null for the DisplayName parameter and failing. Try wrapping the Set-Mailbox command in a ForEach-Object call (alias %) to get that $_ variable, like so: