I want to use a Powershell script to send customized email from our APC Smart-UPS when different actions (events) occurs, lets say when there is an current outage. When the script is run from within Powershell, it works as it should be. However, when the same script is executed from the UPS, it does not work.
The problem has to do with Credentials. Unsafe credential script 1) works perfectly. But getting credential as with script 2) does not work when executed from UPS. The whole setup of Credentials in windows, is good because the script successfull send email when run from within PowerShell.
The scripts runs from APC Smart-UPS PowerChute Business Edition connected to a Windows Server 2012 R2. The scripts are located on the server itself. The Powershell script is run from the UPS by using a batch file.
The .bat scriptPowerShell.exe -ExecutionPolicy Unrestricted -noProfile -nonInteractive -file c:\xxxxx\PS\scripts\XXXXXSelfTestPast.ps1. Also when this batch file is run from the command prompt, everything works.
1) Create credentials. This WORKS$username = "aaaaa@bbbbbbbb"$password = "xxxxxxxxxx"$myPwd = ConvertTo-SecureString -string $password -AsPlainText -Force$cred = New-Object System.Management.Automation.PSCredential -argumentlist $username, $myPwd........ rest code
2) Create credentials. This does NOT work.$cred=Get-StoredCredential -target XXXXXX........ rest code
Please review this thread. https://forums.apc.com/spaces/7/ups-management-devices-powerchute-software/forums/general/98078/running-scripts-from-powerchute-syntax
Now I know why the script is not working.
Now I know what the problem is. See this link:
Sorry was for another Forum.
Choose a location