Forum Discussion
Tlu01
Jul 07, 2021Copper Contributor
How to pipe a result from one command to another for Office 365 powershell
I need to show the name of users with full permission access to a shared mailbox. I found the script to export the user list, however it only shows the user ID in O365, not the Display name. I foun...
- Jul 07, 2021No need to do this in multiple steps, you can use PowerShell's "calculated property" feature:
Get-MailboxPermission shared “Shared mailbox” | Where-Object { ($_.IsInherited -eq $False) -and -not ($_.User -like “NT AUTHORITY\SELF”) } | select User,@{n="DisplayName";e={(Get-Recipient $_.User).displayName}} | Export-Csv "sharedmailbox.csv" -nti
hansleroy
Jul 07, 2021Iron Contributor
Hi,
You can run powershell scripts in a batch file, as explained in
https://social.technet.microsoft.com/Forums/en-US/e39a967d-f395-47b1-b5e0-c485b442bf48/how-do-i-run-the-following-powershell-command-in-a-batch-file?forum=winserverpowershell
That would give something like this (put the file in notepad, save as a .bat (NOT .TXT) file
powershell.exe -Command "(script 1)"
timeout 10
powershell.exe -Command "(script 2)"
Make sure the batch file is in a folder where you can write, so the CSV file can be saved.
Ah, and I put a pause of 10 seconds because the script might need some time to execute and save the file.
Kind regards
Hans
You can run powershell scripts in a batch file, as explained in
https://social.technet.microsoft.com/Forums/en-US/e39a967d-f395-47b1-b5e0-c485b442bf48/how-do-i-run-the-following-powershell-command-in-a-batch-file?forum=winserverpowershell
That would give something like this (put the file in notepad, save as a .bat (NOT .TXT) file
powershell.exe -Command "(script 1)"
timeout 10
powershell.exe -Command "(script 2)"
Make sure the batch file is in a folder where you can write, so the CSV file can be saved.
Ah, and I put a pause of 10 seconds because the script might need some time to execute and save the file.
Kind regards
Hans
Tlu01
Jul 07, 2021Copper Contributor
Thank you for the suggestion.