At last - Now working....
Two problems eventually found.
1. The Powershell.exe -executionpolicy remotesigned -File "C:\Program Files\Nirsoft\failed.ps1" "%HostName%" "%IPAddress%" "%LastPingStatus%" "%LastFailedOn%"
Because of the space between Program and Files, needed to be enclosed in double quotes.
2. The script had managed to name itself 'failed.ps1.ps1' (see below). I had to run Notepad as Administrator to change it, after which it worked fine. Thanks for the help..
PS C:\Program Files\Nirsoft> dir
Directory: C:\Program Files\Nirsoft
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/07/2022 21:30 733 failed.ps1.ps1
-a---- 10/07/2022 12:58 72097 GUNAuto_Shot beretta m12 9 mm (ID 0437)_BSB.mp3
-a---- 12/07/2022 13:11 2189 PingInfoView.cfg
-a---- 06/01/2022 22:11 17765 PingInfoView.chm
-a---- 06/01/2022 22:11 60792 PingInfoView.exe
-a---- 12/07/2022 13:11 358 PingInfoView_hosts.txt
-a---- 06/01/2022 22:11 17023 readme.txt
Two problems eventually found.
1. The Powershell.exe -executionpolicy remotesigned -File "C:\Program Files\Nirsoft\failed.ps1" "%HostName%" "%IPAddress%" "%LastPingStatus%" "%LastFailedOn%"
Because of the space between Program and Files, needed to be enclosed in double quotes.
2. The script had managed to name itself 'failed.ps1.ps1' (see below). I had to run Notepad as Administrator to change it, after which it worked fine. Thanks for the help..
PS C:\Program Files\Nirsoft> dir
Directory: C:\Program Files\Nirsoft
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/07/2022 21:30 733 failed.ps1.ps1
-a---- 10/07/2022 12:58 72097 GUNAuto_Shot beretta m12 9 mm (ID 0437)_BSB.mp3
-a---- 12/07/2022 13:11 2189 PingInfoView.cfg
-a---- 06/01/2022 22:11 17765 PingInfoView.chm
-a---- 06/01/2022 22:11 60792 PingInfoView.exe
-a---- 12/07/2022 13:11 358 PingInfoView_hosts.txt
-a---- 06/01/2022 22:11 17023 readme.txt