Skip to content

Commit

Permalink
Remove Get-ErrorDetail function
Browse files Browse the repository at this point in the history
  • Loading branch information
vreguibar committed Oct 8, 2024
1 parent 94bf0ef commit 5af45c6
Show file tree
Hide file tree
Showing 23 changed files with 66 additions and 65 deletions.
2 changes: 1 addition & 1 deletion Private/Convert-SidToName.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@

} catch {
Write-Error -Message ('An unexpected error occurred: {0}' -f $_)
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
$FoundName = $null
throw
}#end Try-Catch
Expand Down
14 changes: 8 additions & 6 deletions Private/ConvertTo-AccountName.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@
} #end If-Else

} catch {
Write-Warning -Message ('
Failed to convert SID: {0} to account name.
This account should not be processed further.' -f
$PSBoundParameters['SID']
)
Get-ErrorDetail -ErrorRecord $_
$txt = [System.Text.StringBuilder]::new()
[void]$txt.AppendLine($Constants.NL)
[void]$txt.AppendLine('Failed to convert SID: { 0 } to account name.' -f $PSBoundParameters['SID'])
[void]$txt.AppendLine('This account might not be processed further.')
[void]$txt.AppendLine($Constants.NL)

Write-Warning -Message $txt
##Get-ErrorDetail -ErrorRecord $_
return $null
} #end Try-Catch

Expand Down
2 changes: 1 addition & 1 deletion Private/ConvertTo-SID.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

} catch {
Write-Error -Message ('Failed to convert {0} to SID. Error: {1}' -f $AccountName, $_.Exception.Message)
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
return $null
} #end Try-Catch
} #end Process
Expand Down
2 changes: 1 addition & 1 deletion Private/Get-AdWellKnownSID.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
Write-Verbose -Message (' Description: {0}' -f $sidDescription)
} catch {
Write-Error -Message 'Error when checking WellKnownSid'
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand Down
6 changes: 3 additions & 3 deletions Private/Get-GptTemplate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function Get-GptTemplate {
Error while trying to create the folder for {0}' -f
$gpo.DisplayName
)
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
} #end Try-Catch

} #end if
Expand All @@ -95,7 +95,7 @@ function Get-GptTemplate {
Error while trying to create GptTmpl.inf file within folder for {0}' -f
$gpo.DisplayName
)
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
} #end Try-Catch

} #end if
Expand All @@ -116,7 +116,7 @@ function Get-GptTemplate {

} catch {
Write-Error -Message ('An error occurred while handling the GPT template path.')
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
return $null
} #end Try-Catch

Expand Down
6 changes: 3 additions & 3 deletions Private/Set-AclConstructor4.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function Set-AclConstructor4 {

} Catch {
Write-Error -Message ('Error while trying to access LDAP object {0}' -f $PSBoundParameters['LDAPPath'])
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand All @@ -219,7 +219,7 @@ function Set-AclConstructor4 {

} Catch {
Write-Error -Message ('Error while trying to Get a copy of the current DACL {0}' -f $object.DistinguishedName)
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand Down Expand Up @@ -278,7 +278,7 @@ function Set-AclConstructor4 {

} Catch {
Write-Error -Message ('Error when trying to re-apply the modified DACL to the {0}' -f $objectDN.DistinguishedName)
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch
} #end Process
Expand Down
6 changes: 3 additions & 3 deletions Private/Set-AclConstructor5.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ function Set-AclConstructor5 {

} Catch {
Write-Error -Message ('Error while trying to access LDAP object {0}' -f $PSBoundParameters['LDAPPath'])
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand All @@ -239,7 +239,7 @@ function Set-AclConstructor5 {

} Catch {
Write-Error -Message ('Error while trying to Get a copy of the current DACL {0}' -f $object.DistinguishedName)
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand Down Expand Up @@ -302,7 +302,7 @@ function Set-AclConstructor5 {

} Catch {
Write-Error -Message ('Error when trying to re-apply the modified DACL to the {0}' -f $objectDN.DistinguishedName)
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand Down
6 changes: 3 additions & 3 deletions Private/Set-AclConstructor6.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function Set-AclConstructor6 {

} Catch {
Write-Error -Message ('Error while trying to access LDAP object {0}' -f $PSBoundParameters['LDAPPath'])
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand All @@ -256,7 +256,7 @@ function Set-AclConstructor6 {

} Catch {
Write-Error -Message ('Error while trying to Get a copy of the current DACL {0}' -f $object.DistinguishedName)
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand Down Expand Up @@ -322,7 +322,7 @@ function Set-AclConstructor6 {

} Catch {
Write-Error -Message ('Error when trying to re-apply the modified DACL to the {0}' -f $objectDN.DistinguishedName)
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch
} #end Process
Expand Down
6 changes: 3 additions & 3 deletions Private/Set-GPOConfigSection.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
[void]$txt.AppendLine('Item might not be added to the corresponding section. Please verify it!')
[void]$txt.AppendLine($Constants.NL)
Write-Warning -Message $txt
#Get-ErrorDetail -ErrorRecord $_
##Get-ErrorDetail -ErrorRecord $_
} #end Try-Catch

if ($resolvedAccount) {
Expand Down Expand Up @@ -233,7 +233,7 @@
[void]$txt.AppendLine('Item might not be added to the corresponding section. Please verify it!')
[void]$txt.AppendLine($Constants.NL)
Write-Warning -Message $txt
#Get-ErrorDetail -ErrorRecord $_
##Get-ErrorDetail -ErrorRecord $_
} #end If-Else

} #end If
Expand Down Expand Up @@ -283,7 +283,7 @@
{2}' -f
$CurrentKey, $CurrentSection, $_
)
#Get-ErrorDetail -ErrorRecord $_
##Get-ErrorDetail -ErrorRecord $_
} #end Try-Catch
} #end Process

Expand Down
2 changes: 1 addition & 1 deletion Private/Test-IsValidDN.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
} catch {
# Handle exceptions gracefully
Write-Error -Message 'Error when validating DistinguishedName'
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
} #end Try-Catch

} #end Process
Expand Down
2 changes: 1 addition & 1 deletion Private/Test-IsValidGUID.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
} catch {
# Handle exceptions gracefully
Write-Error -Message 'Error when validating GUID'
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
} #end Try-Catch

} #end Process
Expand Down
28 changes: 12 additions & 16 deletions Private/Test-IsValidSID.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,28 @@
Process {
# try RegEx
Try {
# Provide verbose output
if ($PSCmdlet.MyInvocation.BoundParameters['Verbose']) {

#if ($Variables.WellKnownSIDs -Contains $ObjectSID) {
If ($Variables.WellKnownSIDs.Keys.Contains($ObjectSID)) {

Write-Verbose -Message ('The SID {0} is a WellKnownSid.' -f $ObjectSID)
$isValid = $true
#if ($Variables.WellKnownSIDs -Contains $ObjectSID) {
If ($Variables.WellKnownSIDs.Keys.Contains($ObjectSID)) {

} elseIf ($ObjectSID -match $Constants.SidRegEx) {
Write-Verbose -Message ('The SID {0} is a WellKnownSid.' -f $ObjectSID)
$isValid = $true

Write-Verbose -Message ('The SID {0} is valid.' -f $ObjectSID)
$isValid = $true
} elseIf ($ObjectSID -match $Constants.SidRegEx) {

} else {
Write-Verbose -Message ('The SID {0} is valid.' -f $ObjectSID)
$isValid = $true

Write-Verbose -Message ('[WARNING] The SID {0} is NOT valid!.' -f $ObjectSID)
$isValid = $false
} else {

} #end If-Else
Write-Verbose -Message ('[WARNING] The SID {0} is NOT valid!.' -f $ObjectSID)
$isValid = $false

} #end If VERBOSE
} #end If-Else
} catch {
# Handle exceptions gracefully
Write-Error -Message ('An error occurred when validating the SID: {0}' -f $_)
Get-ErrorDetail -ErrorRecord $_
##Get-ErrorDetail -ErrorRecord $_
} #end Try-Catch

<#
Expand Down
4 changes: 2 additions & 2 deletions Private/Test-NameIsWellKnownSid.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
Error creating SecurityIdentifier object for {0}.' -f
$cleanName
)
#Get-ErrorDetail -ErrorRecord $_
##Get-ErrorDetail -ErrorRecord $_
$Identity = $null
}
} else {
Expand All @@ -100,7 +100,7 @@
} catch {
Write-Error -Message ('Error found when translating WellKnownSid for {0}.' -f $cleanedName)
$Identity = $null
#Get-ErrorDetail -ErrorRecord $_
##Get-ErrorDetail -ErrorRecord $_
} #end Try-Catch

} #end Process
Expand Down
4 changes: 2 additions & 2 deletions Private/Update-GpoVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function Update-GpoVersion {
} catch {

Write-Error -Message ('Error accessing GPO through DirectoryEntry' -f $Gpo.Name)
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_

} #end Try-Catch

Expand Down Expand Up @@ -152,7 +152,7 @@ function Update-GpoVersion {
} #end If
} #end If
} catch {
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw "The GPTs.ini file could not be modified: $_. Message is $($_.Exception.Message)"
} #end Try-Catch

Expand Down
18 changes: 9 additions & 9 deletions Public/AdTopology/Set-AdAclCreateDeleteSite.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
}
} Catch {
Write-Error -Message 'Error when delegating Create/Delete site'
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand Down Expand Up @@ -164,7 +164,7 @@
}
} Catch {
Write-Error -Message 'Error when delegating Create/Delete site'
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand Down Expand Up @@ -205,7 +205,7 @@
}
} Catch {
Write-Error -Message 'Error when delegating Create/Delete site'
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand Down Expand Up @@ -245,7 +245,7 @@
}
} Catch {
Write-Error -Message 'Error when delegating Create/Delete site'
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand Down Expand Up @@ -283,7 +283,7 @@
}
} Catch {
Write-Error -Message 'Error when delegating Create/Delete site'
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand Down Expand Up @@ -323,7 +323,7 @@
}
} Catch {
Write-Error -Message 'Error when delegating Create/Delete site'
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand Down Expand Up @@ -364,7 +364,7 @@
}
} Catch {
Write-Error -Message 'Error when delegating Create/Delete site'
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand Down Expand Up @@ -405,7 +405,7 @@
}
} Catch {
Write-Error -Message 'Error when delegating Create/Delete site'
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand Down Expand Up @@ -444,7 +444,7 @@
}
} Catch {
Write-Error -Message 'Error when delegating Create/Delete site'
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch

Expand Down
7 changes: 5 additions & 2 deletions Public/GPO/Set-GpoPrivilegeRight.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@
$Key,

[Parameter(Mandatory = $true)]
[AllowNull()]
[AllowEmptyString()]
[AllowEmptyCollection()]
[System.Collections.Generic.List[object]]
$Members
)
Expand Down Expand Up @@ -1185,7 +1188,7 @@

} Catch {
Write-Error -Message ('Something went wrong. {0}' -f $_)
#Get-ErrorDetail -ErrorRecord $_
##Get-ErrorDetail -ErrorRecord $_
} #end Try-Catch

} #end If
Expand All @@ -1199,7 +1202,7 @@

} Catch {
Write-Error -Message ('Something went wrong while trying to save the GptTmpl.inf file...')
#Get-ErrorDetail -ErrorRecord $_
##Get-ErrorDetail -ErrorRecord $_
Throw
}

Expand Down
2 changes: 1 addition & 1 deletion Public/Logging/Write-CustomLog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
Full details: {1}' -f
$_.Exception.Message, $_
)
Get-ErrorDetail -ErrorRecord $_
#Get-ErrorDetail -ErrorRecord $_
throw
} #end Try-Catch
} #end If
Expand Down
Loading

0 comments on commit 5af45c6

Please sign in to comment.