I have a custom function not written by us and we are using this process to create a semi secure password string:
$pass = Get-Content "C:\Script\UserFolderCreation\file.txt" | ConvertTo-SecureString
Then when I run the function I pass -UserName “Admin” -Password $pass
This does not work but does when I actually put the password in instead of $pass.
The function code I’m running is:
Is there anyway to modify the parameter for -password to accept the $pass secure string?
Pertinent parts of the code:
<# .PARAMETER UseTokenAuthentication This switch parameter is used for username and password authentication to Secret Server in order to generate a token. That token will be used in subsequent API calls. This is a less secure approach, but usefull for a quick test .PARAMETER Password Only used if UseTokenAuthentication is called #> [parameter(Mandatory=$true,ParameterSetName="Password",Position=6)] [parameter(ParameterSetName="TokenAuthentication")] [String] $Password