diff --git a/DuoSecurity/Public/Admin API/Users/New-DuoUser.ps1 b/DuoSecurity/Public/Admin API/Users/New-DuoUser.ps1 index 6a3c989..0532d7c 100644 --- a/DuoSecurity/Public/Admin API/Users/New-DuoUser.ps1 +++ b/DuoSecurity/Public/Admin API/Users/New-DuoUser.ps1 @@ -10,7 +10,7 @@ function New-DuoUser { The name of the user to create. .PARAMETER Aliases - Username aliases for the user. Up to eight aliases may be specified with this parameter as a set of URL-encoded key-value pairs e.g. alias1=joe.smith&alias2=jsmith@example.com. Ignores alias position values not specified. Aliases must be unique amongst users. + Username aliases for the user. Up to eight aliases may be specified with this parameter. Aliases must be unique amongst users. .PARAMETER FullName The real name (or full name) of this user. @@ -72,13 +72,13 @@ function New-DuoUser { ) if ($Aliases) { - $AliasCollection = [System.Web.HttpUtility]::ParseQueryString([String]::Empty) - foreach ($Item in ($Aliases.GetEnumerator() | Sort-Object -CaseSensitive -Property Key)) { - $AliasCollection.Add($Item.Key, $Item.Value) + $x = 1 + $AliasList = $Aliases | ForEach-Object { + 'alias{0}={1}' -f $x, [System.Uri]::EscapeDataString($_) + $x++ } - $AliasString = [System.Web.HttpUtility]::UrlDecode($AliasCollection.ToString()) + $Params.aliases = $AliasList -join '&' } - $Params = @{ username = $Username } diff --git a/DuoSecurity/Public/Admin API/Users/Update-DuoUser.ps1 b/DuoSecurity/Public/Admin API/Users/Update-DuoUser.ps1 index 0a124e4..0768de6 100644 --- a/DuoSecurity/Public/Admin API/Users/Update-DuoUser.ps1 +++ b/DuoSecurity/Public/Admin API/Users/Update-DuoUser.ps1 @@ -13,7 +13,7 @@ function Update-DuoUser { The new username. .PARAMETER Aliases - Username aliases for the user. Up to eight aliases may be specified with this parameter as a set of URL-encoded key-value pairs e.g. alias1=joe.smith&alias2=jsmith@example.com. Ignores alias position values not specified. Remove the value for an existing alias by specifying a blank value e.g. alias1=. Aliases must be unique amongst users. + Username aliases for the user. Up to eight aliases may be specified with this parameter. Aliases must be unique amongst users. .PARAMETER FullName The new real name (or full name). @@ -76,12 +76,11 @@ function Update-DuoUser { $Params = @{} if ($Aliases) { $x = 1 - $AliasList = foreach ($Alias in $Aliases) { - if ($x -gt 8) { break } - @{ "alias$x" = $Alias } + $AliasList = $Aliases | ForEach-Object { + 'alias{0}={1}' -f $x, [System.Uri]::EscapeDataString($_) $x++ } - $Params.aliases = $AliasList + $Params.aliases = $AliasList -join '&' } if ($Username) { $Params.username = $Username }