-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b4b948
commit 7359381
Showing
13 changed files
with
254 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Import-Module .\O365Essentials.psd1 -Force | ||
|
||
if (-not $Credentials) { | ||
$Credentials = Get-Credential | ||
} | ||
# This makes a connection to Office 365 tenant | ||
# since we don't want to save the data we null it out | ||
# keep in mind that if there's an MFA you would be better left without Credentials and just let it prompt you | ||
$null = Connect-O365Admin -Verbose -Credential $Credentials | ||
|
||
$CA = Get-O365AzureConditionalAccess | ||
$CA | Format-Table | ||
#$CA | Format-List | ||
|
||
|
||
$CA = Get-O365AzureConditionalAccess -Details | ||
$CA | Format-Table | ||
|
||
|
||
#Get-O365AzureConditionalAccessPolicy -PolicyID '7eac83fb-856b-45bf-9896-4fc78ea686f1' | ||
Get-O365AzureConditionalAccessPolicy -PolicyName 'Guest Access Policy 1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$Script:O365PolicyState = @{ | ||
'2' = 'Report-only' | ||
'1' = 'Off' | ||
'0' = 'On' # i think | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
function Get-O365AzureConditionalAccess { | ||
[cmdletbinding()] | ||
param( | ||
[alias('Authorization')][System.Collections.IDictionary] $Headers, | ||
[switch] $Details | ||
) | ||
#$Uri = 'https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies' | ||
# Need to figure out scopes and use graph instead. But till then... | ||
#$Uri = 'https://main.iam.ad.ext.azure.com/api/Policies/Policies?top=10&nextLink=null&appId=&includeBaseline=true' | ||
# "https://main.iam.ad.ext.azure.com/api/Policies/7eac83fb-856b-45bf-9896-4fc78ea686f1" | ||
|
||
# move it later on | ||
$Script:O365PolicyState = @{ | ||
'2' = 'Report-only' | ||
'1' = 'Off' | ||
'0' = 'On' # i think | ||
} | ||
|
||
$QueryParameters = @{ | ||
top = 10 | ||
nextLink = $null | ||
#appID = '' | ||
includeBaseline = $true | ||
} | ||
$Uri = 'https://main.iam.ad.ext.azure.com/api/Policies/Policies' | ||
|
||
$Output = Invoke-O365Admin -Uri $Uri -Headers $Headers -QueryParameter $QueryParameters | ||
if ($Output.items) { | ||
foreach ($Policy in $Output.items) { | ||
if (-not $Details) { | ||
[PSCustomObject] @{ | ||
PolicyId = $Policy.policyId #: 7eac83fb-856b-45bf-9896-4fc78ea686f1 | ||
PolicyName = $Policy.policyName #: Guest Access Policy 1 | ||
ApplyRule = $Policy.applyRule #: False | ||
PolicyState = $O365PolicyState[$Policy.policyState.ToString()] #: 1 | ||
UsePolicyState = $Policy.usePolicyState #: True | ||
BaselineType = $Policy.baselineType #: 0 | ||
CreatedDate = $Policy.createdDateTime #: 11.09.2021 09:02:21 | ||
ModifiedDate = $Policy.modifiedDateTime #: 11.09.2021 17:38:21 | ||
} | ||
} else { | ||
$PolicyDetails = Get-O365AzureConditionalAccessPolicy -PolicyID $Policy.policyId | ||
if ($PolicyDetails) { | ||
$PolicyDetails | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
function Get-O365AzureConditionalAccessClassic { | ||
[cmdletbinding()] | ||
param( | ||
[alias('Authorization')][System.Collections.IDictionary] $Headers | ||
) | ||
$Uri = 'https://main.iam.ad.ext.azure.com/api/ClassicPolicies' | ||
|
||
$QueryParameters = @{ | ||
top = 10 | ||
nextLink = $null | ||
filter = 1 | ||
} | ||
|
||
$Output = Invoke-O365Admin -Uri $Uri -Headers $Headers -QueryParameter $QueryParameters | ||
if ($Output.items) { | ||
$Output.items | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function Get-O365AzureConditionalAccessLocation { | ||
[cmdletbinding()] | ||
param( | ||
[alias('Authorization')][System.Collections.IDictionary] $Headers | ||
) | ||
$Uri = 'https://graph.microsoft.com/beta/conditionalAccess/namedLocations' | ||
|
||
#?`$filter=&`$orderby=displayName&`$skip=0&`$top=10&`$count=true | ||
|
||
$QueryParameters = @{ | ||
top = 10 | ||
skip = 0 | ||
orderby = 'displayName' | ||
filter = '' | ||
count = 'true' | ||
} | ||
|
||
$Output = Invoke-O365Admin -Uri $Uri -Headers $Headers -QueryParameter $QueryParameters | ||
if ($Output) { | ||
$Output | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
function Get-O365AzureConditionalAccessPolicy { | ||
[cmdletbinding()] | ||
param( | ||
[parameter(ParameterSetName = 'PolicyID')] | ||
[parameter(ParameterSetName = 'PolicyName')] | ||
[alias('Authorization')][System.Collections.IDictionary] $Headers, | ||
|
||
[parameter(Mandatory, ParameterSetName = 'PolicyID')][string] $PolicyID, | ||
[parameter(Mandatory, ParameterSetName = 'PolicyName')][string] $PolicyName | ||
) | ||
# move it later on | ||
$Script:O365PolicyState = @{ | ||
'2' = 'Report-only' | ||
'1' = 'Off' | ||
'0' = 'On' # i think | ||
} | ||
|
||
|
||
if ($PolicyID) { | ||
$Uri = "https://main.iam.ad.ext.azure.com/api/Policies/$PolicyID" | ||
} elseif ($PolicyName) { | ||
$FoundPolicy = $null | ||
$Policies = Get-O365AzureConditionalAccess -Headers $Headers | ||
foreach ($Policy in $Policies) { | ||
if ($Policy.policyName -eq $PolicyName) { | ||
$FoundPolicy = $Policy.policyId | ||
break | ||
} | ||
} | ||
if ($null -ne $FoundPolicy) { | ||
$Uri = "https://main.iam.ad.ext.azure.com/api/Policies/$FoundPolicy" | ||
} else { | ||
Write-Warning -Message "Get-O365AzureConditionalAccessPolicy - No policy with name $PolicyName" | ||
return | ||
} | ||
} else { | ||
Write-Warning -Message "Get-O365AzureConditionalAccessPolicy - No policy ID or name specified" | ||
return | ||
} | ||
|
||
$PolicyDetails = Invoke-O365Admin -Uri $Uri -Headers $Headers #-QueryParameter $QueryParameters | ||
if ($PolicyDetails) { | ||
[PSCustomObject] @{ | ||
PolicyId = $PolicyDetails.policyId #: 7eac83fb-856b-45bf-9896-4fc78ea686f1 | ||
PolicyName = $PolicyDetails.policyName #: Guest Access Policy 1 | ||
ApplyRule = $PolicyDetails.applyRule #: False | ||
PolicyState = $Script:O365PolicyState[$PolicyDetails.policyState.ToString()] #: 1 | ||
UsePolicyState = $PolicyDetails.usePolicyState #: True | ||
BaselineType = $PolicyDetails.baselineType #: 0 | ||
CreatedDate = $PolicyDetails.createdDateTime #: 11.09.2021 09:02:21 | ||
ModifiedDate = $PolicyDetails.modifiedDateTime #: 11.09.2021 17:38:21 | ||
users = $PolicyDetails.users # # : @{allUsers=2; included=; excluded=} | ||
usersV2 = $PolicyDetails.usersV2 # # : @{allUsers=2; included=; excluded=} | ||
servicePrincipals = $PolicyDetails.servicePrincipals # # : @{allServicePrincipals=1; included=; excluded=; filter=; includeAllMicrosoftApps=False; excludeAllMicrosoftApps=False; userActions=; stepUpTags=} | ||
servicePrincipalsV2 = $PolicyDetails.servicePrincipalsV2 # # : @{allServicePrincipals=1; included=; excluded=; filter=; includedAppContext=; shouldIncludeAppContext=False} | ||
controls = $PolicyDetails.controls # # : @{controlsOr=True; blockAccess=False; challengeWithMfa=True; compliantDevice=False; domainJoinedDevice=False; approvedClientApp=False; claimProviderControlIds=System.Object[]; requireCompliantApp=False; requirePasswordChange=False; requiredFe | ||
# # deratedAuthMethod=0} | ||
sessionControls = $PolicyDetails.sessionControls # # : @{appEnforced=False; cas=False; cloudAppSecuritySessionControlType=0; signInFrequencyTimeSpan=; signInFrequency=0; persistentBrowserSessionMode=0; continuousAccessEvaluation=0; resiliencyDefaults=0; secureSignIn=False} | ||
conditions = $PolicyDetails.conditions # # : @{minUserRisk=; minSigninRisk=; devicePlatforms=; locations=; namedNetworks=; clientApps=; clientAppsV2=; time=; deviceState=} | ||
clientApplications = $PolicyDetails.clientApplications # # : @{allServicePrincipals=0; filter=; includedServicePrincipals=; excludedServicePrincipals=} | ||
isAllProtocolsEnabled = $PolicyDetails.isAllProtocolsEnabled # # : False | ||
isUsersGroupsV2Enabled = $PolicyDetails.isUsersGroupsV2Enabled # # : False | ||
isCloudAppsV2Enabled = $PolicyDetails.isCloudAppsV2Enabled # # : False | ||
version = $PolicyDetails.version # # : 1 | ||
isFallbackUsed = $PolicyDetails.isFallbackUsed # # : False | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function Get-O365AzureConditionalAccessTerms { | ||
[cmdletbinding()] | ||
param( | ||
[alias('Authorization')][System.Collections.IDictionary] $Headers | ||
) | ||
|
||
# ?`$orderby=Name%20asc&`$filter=TypeId%20eq%208a76863a-a0e6-47a7-b99e-0410266eebcf | ||
# &x-tenantid=ceb371f6-8745-4876-a040-69f2d10a9d1a&{}&_=1631363067293 | ||
$Uri = 'https://api.termsofuse.identitygovernance.azure.com/v1.1/Agreements' | ||
|
||
$QueryParameter = @{ | ||
'$orderby' = 'Name asc' | ||
'$filter' = 'TypeId eq 8a76863a-a0e6-47a7-b99e-0410266eebcf' | ||
'x-tenantid' = $TenantID | ||
} | ||
|
||
$Output = Invoke-O365Admin -Uri $Uri -Headers $Headers | ||
if ($Output) { | ||
$Output | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function Get-O365AzureConditionalAccessVPN { | ||
[cmdletbinding()] | ||
param( | ||
[alias('Authorization')][System.Collections.IDictionary] $Headers | ||
) | ||
$Uri = 'https://main.iam.ad.ext.azure.com/api/Vpn/Certificates' | ||
|
||
$Output = Invoke-O365Admin -Uri $Uri -Headers $Headers | ||
if ($Output) { | ||
$Output | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function Get-O365AzureFeatureConfiguration { | ||
[cmdletbinding()] | ||
param( | ||
[alias('Authorization')][System.Collections.IDictionary] $Headers | ||
) | ||
$Uri = 'https://main.iam.ad.ext.azure.com/api/FeatureConfigurations?supportAU=false' | ||
|
||
$Output = Invoke-O365Admin -Uri $Uri -Headers $Headers | ||
if ($Output) { | ||
$Output | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function Get-O365AzureFeaturePortal { | ||
[cmdletbinding()] | ||
param( | ||
[alias('Authorization')][System.Collections.IDictionary] $Headers | ||
) | ||
$Uri = 'https://afd.hosting.portal.azure.net/iam/?bundlingKind=DefaultPartitioner&cacheability=3&clientOptimizations=true&environmentjson=true&extensionName=Microsoft_AAD_IAM&l=en&pageVersion=3.0.01692206&trustedAuthority=portal.azure.com' | ||
|
||
|
||
$Output = Invoke-O365Admin -Uri $Uri -Headers $Headers | ||
if ($Output) { | ||
$Output | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function Get-O365AzureTenantSKU { | ||
[cmdletbinding()] | ||
param( | ||
[alias('Authorization')][System.Collections.IDictionary] $Headers | ||
) | ||
$Uri = 'https://main.iam.ad.ext.azure.com/api/TenantSkuInfo' | ||
|
||
$Output = Invoke-O365Admin -Uri $Uri -Headers $Headers | ||
if ($Output) { | ||
$Output | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters