mirror of
https://github.com/admindroid-community/powershell-scripts.git
synced 2025-12-17 16:35:19 +00:00
Export Microsoft 365 Shared Mailbox Report
Export Microsoft 365 Shared Mailbox Report
This commit is contained in:
parent
2c458a851b
commit
6ebd02f2f4
@ -1,12 +1,31 @@
|
|||||||
#Accept input paramenters
|
<#
|
||||||
|
=============================================================================================
|
||||||
|
Name: Get Shared Mailbox Permission Report
|
||||||
|
Version: 2.0
|
||||||
|
Website: o365reports.com
|
||||||
|
|
||||||
|
Script Highlights:
|
||||||
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
1.The script display only “Explicitly assigned permissions” to mailboxes which means it will ignore “SELF” permission that each user on his mailbox and inherited permission.
|
||||||
|
2.Exports output to CSV file.
|
||||||
|
3.The script can be executed with MFA enabled account also.
|
||||||
|
4.You can choose to either “export permissions of all mailboxes” or pass an input file to get permissions of specific mailboxes alone.
|
||||||
|
5.Allows you to filter output using your desired permissions like Send-as, Send-on-behalf or Full access.
|
||||||
|
6.This script is scheduler friendly. I.e., credentials can be passed as a parameter instead of saving inside the script
|
||||||
|
|
||||||
|
For detailed script execution: https://o365reports.com/2020/01/03/shared-mailbox-permission-report-to-csv/
|
||||||
|
============================================================================================
|
||||||
|
#>
|
||||||
|
|
||||||
|
#Accept input paramenters
|
||||||
param(
|
param(
|
||||||
[switch]$FullAccess,
|
[switch]$FullAccess,
|
||||||
[switch]$SendAs,
|
[switch]$SendAs,
|
||||||
[switch]$SendOnBehalf,
|
[switch]$SendOnBehalf,
|
||||||
[string]$MBNamesFile,
|
[string]$MBNamesFile,
|
||||||
[string]$UserName,
|
[string]$UserName,
|
||||||
[string]$Password,
|
[string]$Password
|
||||||
[switch]$MFA
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -110,68 +129,35 @@ function Get_MBPermission
|
|||||||
}
|
}
|
||||||
|
|
||||||
function main{
|
function main{
|
||||||
#Connect AzureAD and Exchange Online from PowerShell
|
#Check for Exchange Online management module inatallation
|
||||||
Get-PSSession | Remove-PSSession
|
$Module = Get-Module ExchangeOnlineManagement -ListAvailable
|
||||||
|
if($Module.count -eq 0)
|
||||||
#Authentication using MFA
|
|
||||||
if($MFA.IsPresent)
|
|
||||||
{
|
{
|
||||||
$MFAExchangeModule = ((Get-ChildItem -Path $($env:LOCALAPPDATA+"\Apps\2.0\") -Filter CreateExoPSSession.ps1 -Recurse ).FullName | Select-Object -Last 1)
|
Write-Host Exchange Online PowerShell V2 module is not available -ForegroundColor yellow
|
||||||
If ($MFAExchangeModule -eq $null)
|
$Confirm= Read-Host Are you sure you want to install module? [Y] Yes [N] No
|
||||||
|
if($Confirm -match "[yY]")
|
||||||
{
|
{
|
||||||
Write-Host `nPlease install Exchange Online MFA Module. -ForegroundColor yellow
|
Write-host "Installing Exchange Online PowerShell module"
|
||||||
Write-Host You can install module using below blog :https://o365reports.com/2019/04/17/connect-exchange-online-using-mfa/ `n `nOR you can install module directly by entering "Y"`n
|
Install-Module ExchangeOnlineManagement -Repository PSGallery -AllowClobber -Force
|
||||||
$Confirm= Read-Host Are you sure you want to install module directly? [Y] Yes [N] No
|
Import-Module ExchangeOnlineManagement
|
||||||
if($Confirm -match "[y]")
|
|
||||||
{
|
|
||||||
Write-Host Yes
|
|
||||||
Start-Process "iexplore.exe" "https://cmdletpswmodule.blob.core.windows.net/exopsmodule/Microsoft.Online.CSE.PSModule.Client.application"
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Start-Process 'https://o365reports.com/2019/04/17/connect-exchange-online-using-mfa/'
|
Write-Host EXO V2 module is required to connect Exchange Online.Please install module using Install-Module ExchangeOnlineManagement cmdlet.
|
||||||
Exit
|
|
||||||
}
|
|
||||||
$Confirmation= Read-Host Have you installed Exchange Online MFA Module? [Y] Yes [N] No
|
|
||||||
|
|
||||||
if($Confirmation -match "[y]")
|
|
||||||
{
|
|
||||||
$MFAExchangeModule = ((Get-ChildItem -Path $($env:LOCALAPPDATA+"\Apps\2.0\") -Filter CreateExoPSSession.ps1 -Recurse ).FullName | Select-Object -Last 1)
|
|
||||||
If ($MFAExchangeModule -eq $null)
|
|
||||||
{
|
|
||||||
Write-Host Exchange Online MFA module is not available -ForegroundColor red
|
|
||||||
Exit
|
Exit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
Write-Host Connecting to Exchange Online...
|
||||||
{
|
#Storing credential in script for scheduling purpose/ Passing credential as parameter - Authentication using non-MFA account
|
||||||
Write-Host Exchange Online PowerShell Module is required
|
|
||||||
Start-Process 'https://o365reports.com/2019/04/17/connect-exchange-online-using-mfa/'
|
|
||||||
Exit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#Importing Exchange MFA Module
|
|
||||||
. "$MFAExchangeModule"
|
|
||||||
Connect-EXOPSSession -WarningAction SilentlyContinue
|
|
||||||
Write-Host `nReport generation in progress...
|
|
||||||
}
|
|
||||||
|
|
||||||
#Authentication using non-MFA
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#Storing credential in script for scheduling purpose/ Passing credential as parameter
|
|
||||||
if(($UserName -ne "") -and ($Password -ne ""))
|
if(($UserName -ne "") -and ($Password -ne ""))
|
||||||
{
|
{
|
||||||
$SecuredPassword = ConvertTo-SecureString -AsPlainText $Password -Force
|
$SecuredPassword = ConvertTo-SecureString -AsPlainText $Password -Force
|
||||||
$Credential = New-Object System.Management.Automation.PSCredential $UserName,$SecuredPassword
|
$Credential = New-Object System.Management.Automation.PSCredential $UserName,$SecuredPassword
|
||||||
|
Connect-ExchangeOnline -Credential $Credential
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$Credential=Get-Credential -Credential $null
|
Connect-ExchangeOnline
|
||||||
}
|
|
||||||
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Credential -Authentication Basic -AllowRedirection
|
|
||||||
Import-PSSession $Session -CommandName Get-Mailbox,Get-MailboxPermission,Get-RecipientPermission -FormatTypeName * -AllowClobber | Out-Null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#Set output file
|
#Set output file
|
||||||
@ -219,7 +205,11 @@ function main{
|
|||||||
Write-Host `nScript executed successfully
|
Write-Host `nScript executed successfully
|
||||||
if((Test-Path -Path $ExportCSV) -eq "True")
|
if((Test-Path -Path $ExportCSV) -eq "True")
|
||||||
{
|
{
|
||||||
Write-Host "Detailed report available in: $ExportCSV" -ForegroundColor Green
|
Write-Host ""
|
||||||
|
Write-Host " Detailed report available in:" -NoNewline -ForegroundColor Yellow
|
||||||
|
Write-Host $ExportCSV
|
||||||
|
Write-Host `n~~ Script prepared by AdminDroid Community ~~`n -ForegroundColor Green
|
||||||
|
Write-Host "~~ Check out " -NoNewline -ForegroundColor Green; Write-Host "admindroid.com" -ForegroundColor Yellow -NoNewline; Write-Host " to get access to 1800+ Microsoft 365 reports. ~~" -ForegroundColor Green `n`n
|
||||||
$Prompt = New-Object -ComObject wscript.shell
|
$Prompt = New-Object -ComObject wscript.shell
|
||||||
$UserInput = $Prompt.popup("Do you want to open output file?",`
|
$UserInput = $Prompt.popup("Do you want to open output file?",`
|
||||||
0,"Open Output File",4)
|
0,"Open Output File",4)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user