diff --git a/Modules/VMware.vSphere.SsoAdmin/VMware.vSphere.SsoAdmin.psm1 b/Modules/VMware.vSphere.SsoAdmin/VMware.vSphere.SsoAdmin.psm1 index fb86ba2..a25f5ef 100644 --- a/Modules/VMware.vSphere.SsoAdmin/VMware.vSphere.SsoAdmin.psm1 +++ b/Modules/VMware.vSphere.SsoAdmin/VMware.vSphere.SsoAdmin.psm1 @@ -112,7 +112,8 @@ function Connect-SsoAdminServer { ValueFromPipeline=$false, ValueFromPipelineByPropertyName=$false, HelpMessage='Password you want to use for authenticating with the server')] - [string] + [VMware.vSphere.SsoAdmin.Utils.StirngToSecureStringArgumentTransformationAttribute()] + [SecureString] $Password, [Parameter( @@ -132,14 +133,16 @@ function Connect-SsoAdminServer { -ArgumentList @( $Server, $User, - (ConvertTo-SecureString -String $Password -AsPlainText -Force), + $Password, $certificateValidator) - # Update $global:DefaultSsoAdminServers varaible - $global:DefaultSsoAdminServers.Add($ssoAdminServer) | Out-Null + if ($ssoAdminServer -ne $null) { + # Update $global:DefaultSsoAdminServers varaible + $global:DefaultSsoAdminServers.Add($ssoAdminServer) | Out-Null - # Function Output - Write-Output $ssoAdminServer + # Function Output + Write-Output $ssoAdminServer + } } } @@ -327,7 +330,7 @@ function Get-PersonUser { Github: https://github.com/dmilov =========================================================================== .DESCRIPTION - This function gets new person user account. + This function gets person user account. .PARAMETER Name Specifies Name to filter on when searching for person user accounts. @@ -570,12 +573,7 @@ function Remove-PersonUser { $myNewPersonUser = New-PersonUser -Server $ssoAdminConnection -User myAdmin -Password 'MyStrongPa$$w0rd' Remove-PersonUser -User $myNewPersonUser - Remove person user account with user name 'myAdmin' and password 'MyStrongPa$$w0rd' - - .EXAMPLE - New-PersonUser -User myAdmin -Password 'MyStrongPa$$w0rd' -EmailAddress 'myAdmin@mydomain.com' -FirstName 'My' -LastName 'Admin' - - Creates person user account with user name 'myAdmin', password 'MyStrongPa$$w0rd', and details against connections available in 'DefaultSsoAdminServers' + Remove person user account with user name 'myAdmin' #> [CmdletBinding(ConfirmImpact='High')] param( diff --git a/Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdmin.Utils.dll b/Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdmin.Utils.dll index 831ca20..c18d76e 100644 Binary files a/Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdmin.Utils.dll and b/Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdmin.Utils.dll differ diff --git a/Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdminClient.dll b/Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdminClient.dll index a578aab..2c5844d 100644 Binary files a/Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdminClient.dll and b/Modules/VMware.vSphere.SsoAdmin/net45/VMware.vSphere.SsoAdminClient.dll differ diff --git a/Modules/VMware.vSphere.SsoAdmin/netcoreapp2.0/VMware.vSphere.SsoAdmin.Utils.dll b/Modules/VMware.vSphere.SsoAdmin/netcoreapp2.0/VMware.vSphere.SsoAdmin.Utils.dll index 8309b2b..2a9fe1b 100644 Binary files a/Modules/VMware.vSphere.SsoAdmin/netcoreapp2.0/VMware.vSphere.SsoAdmin.Utils.dll and b/Modules/VMware.vSphere.SsoAdmin/netcoreapp2.0/VMware.vSphere.SsoAdmin.Utils.dll differ diff --git a/Modules/VMware.vSphere.SsoAdmin/netcoreapp2.0/VMware.vSphere.SsoAdminClient.dll b/Modules/VMware.vSphere.SsoAdmin/netcoreapp2.0/VMware.vSphere.SsoAdminClient.dll index eef1a7d..c91a1b2 100644 Binary files a/Modules/VMware.vSphere.SsoAdmin/netcoreapp2.0/VMware.vSphere.SsoAdminClient.dll and b/Modules/VMware.vSphere.SsoAdmin/netcoreapp2.0/VMware.vSphere.SsoAdminClient.dll differ diff --git a/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdmin.Utils/StirngToSecureStringArgumentTransformationAttribute.cs b/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdmin.Utils/StirngToSecureStringArgumentTransformationAttribute.cs new file mode 100644 index 0000000..740c5b5 --- /dev/null +++ b/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdmin.Utils/StirngToSecureStringArgumentTransformationAttribute.cs @@ -0,0 +1,38 @@ +// ************************************************************************** +// Copyright 2020 VMware, Inc. +// ************************************************************************** + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Management.Automation; +using System.Security; +using System.Text; +using System.Threading.Tasks; + +namespace VMware.vSphere.SsoAdmin.Utils +{ + public class StirngToSecureStringArgumentTransformationAttribute : ArgumentTransformationAttribute + { + private static class SecureStringConverter + { + public static SecureString ToSecureString(string value) { + var result = new SecureString(); + + foreach (var c in value.ToCharArray()) { + result.AppendChar(c); + } + + return result; + } + } + + public override object Transform(EngineIntrinsics engineIntrinsics, object inputData) { + object result = inputData; + if (inputData is string s) { + result = SecureStringConverter.ToSecureString(s); + } + return result; + } + } +} diff --git a/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdmin.Utils/VMware.vSphere.SsoAdmin.Utils.csproj b/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdmin.Utils/VMware.vSphere.SsoAdmin.Utils.csproj index 02974f9..631cd09 100644 --- a/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdmin.Utils/VMware.vSphere.SsoAdmin.Utils.csproj +++ b/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdmin.Utils/VMware.vSphere.SsoAdmin.Utils.csproj @@ -14,9 +14,11 @@ + + diff --git a/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient.Tests/IntegrationTests.cs b/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient.Tests/IntegrationTests.cs index 625bfa4..d51de00 100644 --- a/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient.Tests/IntegrationTests.cs +++ b/Modules/VMware.vSphere.SsoAdmin/src/VMware.vSphere.SsoAdmin.Client/VMware.vSphere.SsoAdminClient.Tests/IntegrationTests.cs @@ -13,7 +13,7 @@ namespace VMware.vSphere.SsoAdminClient.Tests { private string _vc = ""; private string _user = ""; - private string _rawPassword = "