add: Error handling to output functions

This commit is contained in:
DrIOS
2024-06-23 16:06:02 -05:00
parent b6423c8a7d
commit 4dd65a0140
2 changed files with 7 additions and 8 deletions

View File

@@ -266,9 +266,7 @@ function Get-CISMSTeamsOutput {
$CsTeamsMessagingPolicy = Get-CsTeamsMessagingPolicy -Identity Global | Select-Object -Property AllowSecurityEndUserReporting $CsTeamsMessagingPolicy = Get-CsTeamsMessagingPolicy -Identity Global | Select-Object -Property AllowSecurityEndUserReporting
return $CsTeamsMessagingPolicy return $CsTeamsMessagingPolicy
} }
default { default { throw "No match found for test: $Rec" }
Write-Output "No matching action found"
}
} }
} }
end { end {

View File

@@ -39,6 +39,11 @@ function Get-CISMgOutput {
} }
process { process {
switch ($rec) { switch ($rec) {
'1.1.1' {
# 1.1.1
$AdminRoleAssignmentsAndUsers = Get-AdminRoleUserAndAssignment
return $AdminRoleAssignmentsAndUsers
}
'1.1.3' { '1.1.3' {
# Step: Retrieve global admin role # Step: Retrieve global admin role
$globalAdminRole = Get-MgDirectoryRole -Filter "RoleTemplateId eq '62e90394-69f5-4237-9190-012177145e10'" $globalAdminRole = Get-MgDirectoryRole -Filter "RoleTemplateId eq '62e90394-69f5-4237-9190-012177145e10'"
@@ -84,11 +89,7 @@ function Get-CISMgOutput {
return $null return $null
} }
} }
Default { default { throw "No match found for test: $Rec" }
# 1.1.1
$AdminRoleAssignmentsAndUsers = Get-AdminRoleUserAndAssignment
return $AdminRoleAssignmentsAndUsers
}
} }
} }
end { end {