Ask questions. Get answers. Find technical product solutions from passionate experts in the NXLog community.

Powershell set new field
Hi all, I would like to set the actual IP address of a computer when an event is raised and add the result in a new field. Is it possible to set a new field with powershell ? <Exec> if ($EventID == 11001) \ {\ exec_async("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-ExecutionPolicy", "ByPass", "-NonInteractive", "-Command", "(gwmi Win32_NetworkAdapterConfiguration | where {$_.IPEnabled}).IPAddress");\ } </Exec>

cmiscloni created
exec_async calling powershell and passing script parameters
I'm trying to trigger a powershell script to run with passed parameters on pattern matching the contents of $message. The method itself works, I just cannot work out how to pass parameters to the script I'm calling. <Input internal> Module im_internal Exec if ($message =~ /nxlog-ce-2.10.2150 started/) exec_async("C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe", "-ExecutionPolicy", "Bypass", "-command", "C:\Scripts\nxlog_exec_async_test.ps1"); </Input> My working test configuration is shown above. The script called nxlog_exec_async_test.ps1 is successfully called from an elevated shell, if there is no parameter passed in. exec_async("C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe", "-ExecutionPolicy", "Bypass", "-command", "C:\Scripts\nxlog_exec_async_test.ps1 test"); I've tried passing the parameter "test" in the following ways, but this doesn't work either i.e.: exec_async("C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe", "-ExecutionPolicy", "Bypass", "-command", "C:\Scripts\nxlog_exec_async_test.ps1", "test"); exec_async("C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe", "-ExecutionPolicy", "Bypass", "-command", "C:\Scripts\nxlog_exec_async_test.ps1 test"); The powershell script simply echos a line out to file, and the first line is: $testparm==$args[0] Which is assigning the first parameter to the variable $testparm Can anyone help? Cheers, Phil

pmeech created
Replies: 1
View post »
last updated