Now I know what the problem is. See this link:
Mario
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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.
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.
$username = "xxxxxx@yyyyyyyy"
$password = "zzzzzzzzzz"
$myPwd = ConvertTo-SecureString -string $password -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential -argumentlist $username, $myPwd
$cred=Get-StoredCredential -target XXXXXX
Thanks
Mario
Now I know what the problem is. See this link:
Mario
ups = uninterruptible power supply.
Via the UPS application PowerChute Business Edition you can execute a script when an event, lets say current outage, occurs. In this case, a .bat file is executed. The .bat file executes the Powershell script
The .bat script
PowerShell.exe -ExecutionPolicy Unrestricted -noProfile -nonInteractive -file c:\xxxxx\PS\scripts\upsMailSelfTestPast.ps1
The system does not give any error.
I think maybe it has to do with permissions. It works ok from within Powershell but not when it is executed from the UPS.
The Powershell script is run from the UPS by using .bat file.
What exactly does "from the UPS" mean?
Are you running Powershell.exe on the Windows server and referencing the UPS as a network drive? IE: you are reading the script "from the UPS" into the server's memory where powershell.exe is running?
Powershell.exe \\UPS\Share\SendMail.ps1
Create credentials. This does NOT work.
What error do you get? What account is being used to run the script? Is this being called by a Windows service or the task scheduler?