Posted: 2022-03-17 03:40 AM
I have been trying to get a command file to run my second script that then calls another powershell-script.
I have read a lot of different threads and FAQs but I can't seem to get this to work.
The file "default.cmd" can be run manually so everything works when running it manually.
I have also set the user administrator (local admin) on the server to run the service as said in FAQs and threads.
The server everything is running on is a windows server 2019 standard.
So here's how things are set:
default.cmd (calls)-> shutdown.bat (calls)-> shutdown-vms.ps1
Default.cmd looks like this for now:
C:"\Program Files (x86)\APC\PowerChute Business Edition\agent\cmdfiles\shutdown.bat"
I have tried with @start, with or without quoutes, different locations on the server etc.
When I press "test" in the shutdown settings on the website, nothing happens.
Shutdown.bat that calls a powershell file that halts all the running vms on a vmware server.
Powershell.exe -executionpolicy remotesigned -File "C:\Program Files (x86)\APC\PowerChute Business Edition\agent\cmdfiles\shutdown-vms.ps1"
Can someone please help me with this, it would be great to get this working as intended!
Posted: 2022-03-22 01:41 PM
When you enter C:"\Program Files (x86)\APC\PowerChute Business Edition\agent\cmdfiles\shutdown.bat" in a command prompt as an administrator does shutdown.bat run?
Have you looked in C:\Program Files (x86)\APC\PowerChute Business Edition\agent\log\pcbe.log file to see what error if any is entered?
Posted: 2022-03-23 04:40 AM
Hi @BillP and thank you for replying to my issue!
"When you enter C:"\Program Files (x86)\APC\PowerChute Business Edition\agent\cmdfiles\shutdown.bat" in a command prompt as an administrator does shutdown.bat run?"
Yes, it runs as intended, and i can even run the default.cmd in a command prompt and everything runs as it should.
"Have you looked in C:\Program Files (x86)\APC\PowerChute Business Edition\agent\log\pcbe.log file to see what error if any is entered?"
Yes, the log only said that login was successfull, nothing more unfortunately.
Posted: 2022-03-23 10:43 AM
I ran a test with PowerChute Agent 10.0.5. I created a .bat named Trigger. It triggers FindAgentRegKeys.psi
I added it to the Agent
Trigger.bat content is
cmd.exe /C Powershell.exe Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force; .\FindAgentRegKeys.ps1 >> c:\temp\AgentRegKey.txt
The PS file will search the registry for PowerChute entries and write them to a text file save in c:\temp
Next I stopped the Agent service and edited the user
I then restarted the service, log into the Agent and tested the scripts. Trigger.bat started the PS file and created the text file as expected.