I am trying to replace a batch file that runs an automated upload process with a PowerShell script that provides better security. Currently, the executable in the batch file is run with credentials that are displayed in clear text as part of a switch. I am new to PowerShell and am having difficulty understanding how to call these credentials and apply them to the executable file I am trying to run. There seem to be a lot of posts about applying saved credentials to cmdlets, but little about working with executables. Below is a copy of my current script.
$username = "firstname.lastname@example.org"
$password = "Get-Content D:\temp\axupload.txt | ConvertTo-SecureString"
$mycred = "New-Object System.Management.Automati
ntial -ArgumentList $username,$password"
$securepassword = "$mycred.GetNetworkCredent
$exe = "D:\Program Files (x86)\XtenderSolutions\Con
$appname = "HR_PERSONNEL_OPTION1"
$specname = "HR_PERSONNEL"
$filename = "\\xxxxxxx\aximport\HR\Wee
& $exe /U $username /W $securepassword /A $appname /S $specname /F $filename
Attached is the error message returned by the application. So it does not appear to be getting the needed credentials.
I am trying to understand the correct method to pass user credentials to an older exe application without having theses credentials in plain text. I already tried a version of the script using -credential, but it does not recognize that.