encrypt and decrypt password in PS won't work as scheduled batch file, runs fine from commnad line
i have alerting program can run batch file if trigger condition met. use batch file run ps script. because there logins involved, saved password local text file. use get-content , convert text file secure string (convertto-securestring); this:
$pwd = get-content d:\bat\pwd.txt | convertto-securestring
$pwd2 = [runtime.interopservices.marshal]::ptrtostringauto([runtime.interopservices.marshal]::securestringtobstr($pwd))
later on call exe has parameter password (-password $pwd2).
when run batch file command prompt executes ps script correctly. hangs @ first line uses decrypted password when triggered through alerting program. can tell because of what's showing in task manager (i can kill exe process requires password , script continue). if remove ecrypted password process , use clear text string (what wanted avoid in first place), works.
any ideas why password encrypt/decrypt might not work through batch file? main thing needed change converting ps script batch friendly use full path names (the password file, exe, etc). need load type of runtime password decrypt?
Windows Server > Windows PowerShell
Comments
Post a Comment