mirror of
https://github.com/admindroid-community/powershell-scripts.git
synced 2025-12-18 08:55:19 +00:00
Export Conditional Access Policies
While converting object Ids to name, error thrown for deleted objects-fixed
This commit is contained in:
parent
71c8c409e3
commit
e81c613096
@ -2,7 +2,7 @@
|
|||||||
=============================================================================================
|
=============================================================================================
|
||||||
Name: Export Conditional Access Policies to Excel using PowerShell
|
Name: Export Conditional Access Policies to Excel using PowerShell
|
||||||
Description: The script exports all Conditional Access policies to an Excel file.
|
Description: The script exports all Conditional Access policies to an Excel file.
|
||||||
Version: 2.0
|
Version: 2.2
|
||||||
Website: o365reports.com
|
Website: o365reports.com
|
||||||
|
|
||||||
Script Highlights:
|
Script Highlights:
|
||||||
@ -98,10 +98,22 @@ Function ConvertTo-Name {
|
|||||||
}
|
}
|
||||||
# Retrieve the display name for the directory object with the given ID
|
# Retrieve the display name for the directory object with the given ID
|
||||||
else{
|
else{
|
||||||
$Name = (Get-MgBetaDirectoryObject -DirectoryObjectId $Id).AdditionalProperties["displayName"]
|
try
|
||||||
|
{
|
||||||
|
$Name = ((Get-MgBetaDirectoryObject -DirectoryObjectId $Id ).AdditionalProperties["displayName"] )
|
||||||
|
if($Name -ne $null)
|
||||||
|
{
|
||||||
$DirectoryObjsHash[$Id]=$Name
|
$DirectoryObjsHash[$Id]=$Name
|
||||||
}
|
|
||||||
$ConvertedNames += $Name
|
$ConvertedNames += $Name
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Write-Host "Deleted object configured in the CA policy $CAName" -ForegroundColor Red
|
||||||
|
Write-Host "Processing CA policies..."
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $ConvertedNames
|
return $ConvertedNames
|
||||||
}
|
}
|
||||||
@ -235,7 +247,7 @@ Get-MgBetaIdentityConditionalAccessPolicy -All | Foreach {
|
|||||||
}
|
}
|
||||||
$IncludeUsers=$IncludeUsers -join ","
|
$IncludeUsers=$IncludeUsers -join ","
|
||||||
|
|
||||||
if($ExcludeUsers.Count -ne 0)# -and ($ExcludeUsers -ne 'GuestsOrExternalUsers' ))
|
if(($ExcludeUsers.Count -ne 0) -and ($ExcludeUsers -ne 'GuestsOrExternalUsers' ))
|
||||||
{
|
{
|
||||||
$ExcludeUsers=ConvertTo-Name -InputIds $ExcludeUsers
|
$ExcludeUsers=ConvertTo-Name -InputIds $ExcludeUsers
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user