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
return $CsTeamsMessagingPolicy
}
default {
Write-Output "No matching action found"
}
default { throw "No match found for test: $Rec" }
}
}
end {

View File

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