I want to use a Powershell script to send me an customize email when different actions (events) occurs concerning my APC UPS device. When the script is run from Powershell is works as it should be. However, when the 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 Credential in windows, by using Credential Manager, is good because the script successfully send the email when run from PowerShell.
Can someone help me with this problem?
The script runs from an APC UPS connected to a Windows Server 2012 R2. All scripts are located on this server. The Powershell script is run from the UPS by using .bat file.
1) Create credentials. This WORKS
$username = "xxxxxx@yyyyyyyy"
$password = "zzzzzzzzzz"
$myPwd = ConvertTo-SecureString -string $password -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential -argumentlist $username, $myPwd
2) Create credentials. This does NOT work.
$cred=Get-StoredCredential -target XXXXXX
Thanks
Mario