Skip to content

Commit c5e9b5e

Browse files
Remove redundant func, fix phone revoke, impr. audit msg (#25)
1 parent 911762b commit c5e9b5e

File tree

4 files changed

+3
-111
lines changed

4 files changed

+3
-111
lines changed

permissions/emailAuthenticationMethods/grantPermission.ps1

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,6 @@ $InformationPreference = "Continue"
1515
$WarningPreference = "Continue"
1616

1717
#region functions
18-
function Convert-StringToBoolean($obj) {
19-
if ($obj -is [PSCustomObject]) {
20-
foreach ($property in $obj.PSObject.Properties) {
21-
$value = $property.Value
22-
if ($value -is [string]) {
23-
$lowercaseValue = $value.ToLower()
24-
if ($lowercaseValue -eq "true") {
25-
$obj.$($property.Name) = $true
26-
}
27-
elseif ($lowercaseValue -eq "false") {
28-
$obj.$($property.Name) = $false
29-
}
30-
}
31-
elseif ($value -is [PSCustomObject] -or $value -is [System.Collections.IDictionary]) {
32-
$obj.$($property.Name) = Convert-StringToBoolean $value
33-
}
34-
elseif ($value -is [System.Collections.IList]) {
35-
for ($i = 0; $i -lt $value.Count; $i++) {
36-
$value[$i] = Convert-StringToBoolean $value[$i]
37-
}
38-
$obj.$($property.Name) = $value
39-
}
40-
}
41-
}
42-
return $obj
43-
}
44-
4518
function Resolve-MicrosoftGraphAPIError {
4619
[CmdletBinding()]
4720
param (
@@ -351,7 +324,7 @@ try {
351324

352325
$outputContext.AuditLogs.Add([PSCustomObject]@{
353326
# Action = "" # Optional
354-
Message = "Skipped setting email authentication method [$($actionContext.References.Permission.Name)] for account with AccountReference: $($actionContext.References.Account | ConvertTo-Json). Old value: [$($currentEmailAuthenticationMethod)]. New value: [$($email)]. Reason: Configured to only update when empty and already contains data."
327+
Message = "Skipped setting email authentication method [$($actionContext.References.Permission.Name)] for account with AccountReference: $($actionContext.References.Account | ConvertTo-Json). Old value: [$($currentEmailAuthenticationMethod)]. New value: [$($email)]. Reason: Configured to only update when empty but already contains data."
355328
IsError = $false
356329
})
357330
#endregion Existing data, skipping update

permissions/emailAuthenticationMethods/revokePermission.ps1

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,6 @@ $InformationPreference = "Continue"
1515
$WarningPreference = "Continue"
1616

1717
#region functions
18-
function Convert-StringToBoolean($obj) {
19-
if ($obj -is [PSCustomObject]) {
20-
foreach ($property in $obj.PSObject.Properties) {
21-
$value = $property.Value
22-
if ($value -is [string]) {
23-
$lowercaseValue = $value.ToLower()
24-
if ($lowercaseValue -eq "true") {
25-
$obj.$($property.Name) = $true
26-
}
27-
elseif ($lowercaseValue -eq "false") {
28-
$obj.$($property.Name) = $false
29-
}
30-
}
31-
elseif ($value -is [PSCustomObject] -or $value -is [System.Collections.IDictionary]) {
32-
$obj.$($property.Name) = Convert-StringToBoolean $value
33-
}
34-
elseif ($value -is [System.Collections.IList]) {
35-
for ($i = 0; $i -lt $value.Count; $i++) {
36-
$value[$i] = Convert-StringToBoolean $value[$i]
37-
}
38-
$obj.$($property.Name) = $value
39-
}
40-
}
41-
}
42-
return $obj
43-
}
44-
4518
function Resolve-MicrosoftGraphAPIError {
4619
[CmdletBinding()]
4720
param (

permissions/phoneAuthenticationMethods/grantPermission.ps1

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,6 @@ $InformationPreference = "Continue"
1515
$WarningPreference = "Continue"
1616

1717
#region functions
18-
function Convert-StringToBoolean($obj) {
19-
if ($obj -is [PSCustomObject]) {
20-
foreach ($property in $obj.PSObject.Properties) {
21-
$value = $property.Value
22-
if ($value -is [string]) {
23-
$lowercaseValue = $value.ToLower()
24-
if ($lowercaseValue -eq "true") {
25-
$obj.$($property.Name) = $true
26-
}
27-
elseif ($lowercaseValue -eq "false") {
28-
$obj.$($property.Name) = $false
29-
}
30-
}
31-
elseif ($value -is [PSCustomObject] -or $value -is [System.Collections.IDictionary]) {
32-
$obj.$($property.Name) = Convert-StringToBoolean $value
33-
}
34-
elseif ($value -is [System.Collections.IList]) {
35-
for ($i = 0; $i -lt $value.Count; $i++) {
36-
$value[$i] = Convert-StringToBoolean $value[$i]
37-
}
38-
$obj.$($property.Name) = $value
39-
}
40-
}
41-
}
42-
return $obj
43-
}
44-
4518
function Resolve-MicrosoftGraphAPIError {
4619
[CmdletBinding()]
4720
param (
@@ -399,7 +372,7 @@ try {
399372

400373
$outputContext.AuditLogs.Add([PSCustomObject]@{
401374
# Action = "" # Optional
402-
Message = "Skipped setting phone authentication method [$($actionContext.References.Permission.Name)] for account with AccountReference: $($actionContext.References.Account | ConvertTo-Json). Old value: [$($currentPhoneAuthenticationMethod)]. New value: [$($phoneNumber)]. Reason: Configured to only update when empty and already contains data."
375+
Message = "Skipped setting phone authentication method [$($actionContext.References.Permission.Name)] for account with AccountReference: $($actionContext.References.Account | ConvertTo-Json). Old value: [$($currentPhoneAuthenticationMethod)]. New value: [$($phoneNumber)]. Reason: Configured to only update when empty but already contains data."
403376
IsError = $false
404377
})
405378
#endregion Existing data, skipping update

permissions/phoneAuthenticationMethods/revokePermission.ps1

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,6 @@ $InformationPreference = "Continue"
1515
$WarningPreference = "Continue"
1616

1717
#region functions
18-
function Convert-StringToBoolean($obj) {
19-
if ($obj -is [PSCustomObject]) {
20-
foreach ($property in $obj.PSObject.Properties) {
21-
$value = $property.Value
22-
if ($value -is [string]) {
23-
$lowercaseValue = $value.ToLower()
24-
if ($lowercaseValue -eq "true") {
25-
$obj.$($property.Name) = $true
26-
}
27-
elseif ($lowercaseValue -eq "false") {
28-
$obj.$($property.Name) = $false
29-
}
30-
}
31-
elseif ($value -is [PSCustomObject] -or $value -is [System.Collections.IDictionary]) {
32-
$obj.$($property.Name) = Convert-StringToBoolean $value
33-
}
34-
elseif ($value -is [System.Collections.IList]) {
35-
for ($i = 0; $i -lt $value.Count; $i++) {
36-
$value[$i] = Convert-StringToBoolean $value[$i]
37-
}
38-
$obj.$($property.Name) = $value
39-
}
40-
}
41-
}
42-
return $obj
43-
}
44-
4518
function Resolve-MicrosoftGraphAPIError {
4619
[CmdletBinding()]
4720
param (
@@ -220,7 +193,7 @@ try {
220193
#region Calulate action
221194
$actionMessage = "calculating action"
222195
if (($currentPhoneAuthenticationMethod | Measure-Object).count -eq 1) {
223-
if ($actionContext.Configuration."$($actionContext.References.Permission.RemoveWhenRevokingEntitlement)" -eq $false) {
196+
if ($actionContext.References.Permission.RemoveWhenRevokingEntitlement -eq $false) {
224197
$actionPhoneAuthenticationMethod = "SkipDelete"
225198
}
226199
else {

0 commit comments

Comments
 (0)