Hi Philippe-Andre,
this is exactly what we are doing: start the batch file to start powershell. Just for the sake of the next man looking at this, here is a sample Batch file:
@C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '.\nameOfPowershellScript.ps1'"
where the batch and script file are in the same folder.
Original Message:
Sent: 09-14-2021 10:13 AM
From: Philippe-Andre Trottier
Subject: Logmon - command with powershell
Looks like it works with a batch file. I've created a batch to execute the PS1 file and nimsoft accepts it. It works now.
thanks !
------------------------------
Philippe-Andre Trottier
[JobTitle]
[CompanyName]
Montreal,Quebec
Original Message:
Sent: 09-14-2021 09:12 AM
From: Garin Walsh
Subject: Logmon - command with powershell
Set the log level to 5 on logmon and run the profile - should log the errors there
Have you verified that the account running the probe can run powershell?
Have you tried creating a cmd/bat file that echos "OK" to verify that everything else works ok?
Original Message:
Sent: 09-14-2021 09:02 AM
From: Philippe-Andre Trottier
Subject: Logmon - command with powershell
Hey everyone. I am trying to run a powershell script with logmon (command mode) and get the output of that script with a watcher. Right now it doesn't look like a success (the script doesn't seem to run or the output is not catched by the watcher.
The script is pretty simple: I do a invoke-webrequest on a webpage and it return either an output OK or ERROR. I don't use URL response for various reasons...
So here's my configuration from IM: Does it seem ok?
Here is the script:
try
{
$Response = Invoke-WebRequest -Uri "www.google.ca"
# This will only execute if the Invoke-WebRequest is successful.
$StatusCode = $Response.StatusCode
}
catch
{
$StatusCode = $_.Exception.Response.StatusCode.value__
}
if ($StatusCode -like '404')
{
echo OK
}
Else
{
$StatusCode
echo ERROR
}
------------------------------
Philippe-Andre Trottier
[JobTitle]
[CompanyName]
Montreal,Quebec
------------------------------