Skip to content

Commit

Permalink
Merge pull request #24 from johnduprey/dev
Browse files Browse the repository at this point in the history
PSScriptAnalyzer Fixes
  • Loading branch information
JohnDuprey authored Apr 16, 2023
2 parents 3b243dd + 8550cd5 commit da7c5f8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ function Remove-DuoCustomBrandingDraftUser {
[string]$UserId
)

$DuoRequest = @{
Method = 'DELETE'
Path = '/admin/v1/branding/draft/users/{0}' -f $UserId
}
process {
$DuoRequest = @{
Method = 'DELETE'
Path = '/admin/v1/branding/draft/users/{0}' -f $UserId
}

if ($PSCmdlet.ShouldProcess($UserId)) {
$Request = Invoke-DuoRequest @DuoRequest
if ($Request.stat -ne 'OK') {
$Request
} else {
$Request.response
if ($PSCmdlet.ShouldProcess($UserId)) {
$Request = Invoke-DuoRequest @DuoRequest
if ($Request.stat -ne 'OK') {
$Request
} else {
$Request.response
}
}
}
}
31 changes: 16 additions & 15 deletions DuoSecurity/Public/Misc/Get-DuoAccountID.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,25 @@ function Get-DuoAccountID {
[Alias('api_hostname')]
[string]$ApiHost
)
$AccountHex = ''

if (!$ApiHost) {
if ($script:DuoApiHost) { $ApiHost = $script:DuoApiHost }
elseif ($script:DuoAccountsApiHost) { $ApiHost = $script:DuoAccountsApiHost }
}
process {
$AccountHex = ''

if (!$ApiHost) {
$ApiHost = Read-Host 'Please enter an API hostname (e.g. api-01ab23cd.duosecurity.com)'
}
if (!$ApiHost) {
if ($script:DuoApiHost) { $ApiHost = $script:DuoApiHost }
elseif ($script:DuoAccountsApiHost) { $ApiHost = $script:DuoAccountsApiHost }
}

if ($ApiHost -match 'api-(?<AccountHex>.+)\.duosecurity\.com') {
$AccountHex = '0x{0}' -f $Matches.AccountHex
$AccountHexUnsigned = [uint]$AccountHex
($AccountHexUnsigned.ToString().PadLeft(10, '0') -split '([0-9]{4})' -ne '') -join '-'
}
if (!$ApiHost) {
$ApiHost = Read-Host 'Please enter an API hostname (e.g. api-01ab23cd.duosecurity.com)'
}

else {
Write-Output 'Unable to determine account ID'
if ($ApiHost -match 'api-(?<AccountHex>.+)\.duosecurity\.com') {
$AccountHex = '0x{0}' -f $Matches.AccountHex
$AccountHexUnsigned = [uint]$AccountHex
($AccountHexUnsigned.ToString().PadLeft(10, '0') -split '([0-9]{4})' -ne '') -join '-'
} else {
throw 'Unable to determine account ID'
}
}
}

0 comments on commit da7c5f8

Please sign in to comment.