Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions Get-O365RoleReport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@
Array of roles to exclude from the report. Default is AAD role of "Directory Synchronization Accounts".
.PARAMETER Output
Path and filename of the report. Default is O365RoleReport.html in the current directory.
.PARAMETER UseIEProxyConfig
When a proxy is required, you may need to use the proxy configuration from IE to connect.
This creates a PSSession Option which is used for Remote PowerShell.
.NOTES
Version 2.2
January 6, 2022
Version 2.3
April 27, 2022

This script uses Bootstrap to format the report. For more information https://www.getbootstrap.com/

Expand All @@ -45,7 +48,8 @@ Param(
[String]$Output = "O365RoleReport.html",
[Array]$IgnoredRoles="Directory Synchronization Accounts",
[ValidateSet('AAD','SCC','EXO')]$SkipWorkload,
[string]$AdminUPN
[string]$AdminUPN,
[Switch]$UseIEProxyConfig
)


Expand Down Expand Up @@ -175,6 +179,13 @@ if ($SkipWorkload -contains 'AAD' -and $SkipWorkload -contains 'SCC' -and $SkipW
exit
}

If ($UseIEProxyConfig) {
Write-Host "$(Get-Date) [INFO] Engineer has specified using IE Proxy Settings" -ForegroundColor Green
$ProxySetting = New-PSSessionOption -ProxyAccessType IEConfig -IdleTimeout 9000000 -OperationTimeout 9000000
} Else {
$ProxySetting = New-PSSessionOption -ProxyAccessType None -IdleTimeout 9000000 -OperationTimeout 9000000
}

# Always connect to MSOL, if necessary, for password and MFA details. MSOL still required due to MFA details not available in AAD v2.
if (-not(Get-MsolCompanyInformation -ErrorAction SilentlyContinue)) {
Write-Host 'Connecting to Azure AD...'
Expand All @@ -186,15 +197,15 @@ if (-not(Get-MsolCompanyInformation -ErrorAction SilentlyContinue)) {
if ($SkipWorkload -notcontains 'SCC') {
if (-not(Get-Command -Name Get-SCCRoleGroup -ErrorAction SilentlyContinue)) {
Write-Host 'Connecting to Security & Compliance Center...'
Connect-IPPSSession -Prefix SCC -UserPrincipalName $AdminUPN
Connect-IPPSSession -Prefix SCC -UserPrincipalName $AdminUPN -PSSessionOption $ProxySetting
}
}

# Connect to EXO if not skipped, if necessary
if ($SkipWorkload -notcontains 'EXO') {
if (-not(Get-Command -Name Get-OrganizationConfig -ErrorAction SilentlyContinue)) {
Write-Host 'Connecting to Exchange Online...'
Connect-ExchangeOnline -UserPrincipalName $AdminUPN -ShowBanner:$false
Connect-ExchangeOnline -UserPrincipalName $AdminUPN -ShowBanner:$false -PSSessionOption $ProxySetting
}
}

Expand Down