cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Question about script

anton_starchenk
Inactive

Hi guys!

I`ve made a simple script which writes notification message to file.

It works pretty well, except one. It is write only part of first string from notification message.

Maybe someone knows what is the trick and how write all notification message?

 

Thanks in advance.

1.bat

2.jpg

5 REPLIES 5

pawel_siwek1
Inactive

Hi Anton,


To get whole message it's recommended to use PowerShell scripts instead of .bat files. As prerequisite you will first need to enable PowerShell scripts execution on Windows CAS Server with 'set-executionpolicy remotesigned' command.

 

Than in your case edit ‘Test1’ script recipient in DC RUM console and fill in:

'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' as executable file path

-command C:\MyPowerShellScript\myscript.ps1 -message '{notificationMessage}' as parameters.

 

Source code for sample myscript.ps1 script that appends the message into my-log.log file is listed below:

param (
[string]$message = ""
)

$message | Add-Content my-log.log

 

Good luck,

Pawel Siwek

 

anton_starchenk
Inactive

Hi Pavel,

Thank you for your quick reply. 

 

I have installed Powershell & executed  'set-executionpolicy remotesigned' command.

To check possibility for  running scripts I executed Get-ExecutionPolicy in PS console.

Answer was RemoteSigned.

 

After that, I`ve edited script recipient

 

 

I`ve got some messages about running script in Log on CAS server

T SCRIP 15-05-29 11:23:15.625 C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command C:\Test\test.ps1 -message 'Начались проблемы с доступностью со следующими параметрами:
Доступность приложения Exchange Mail Service упала ниже установленного порога (<97%). Актуальное значение доступности: 94.201%. Число затронутых пользователей: 162. http://10.30.16.126/LSServlet?dmiAction=Generate&lsAction=LoadByName&lsEntryName=Tiers&FILTER_bgAppl...
' - terminate script.

 

But there is nothing in "my-log.log"

 

Maybe I should add something to the script or somewhere else?

 

Thank you!


pawel_siwek1
Inactive

Hi Anton, 

Try to adjust the PowerShell script to use absolute path

param (
[string]$message = ""
)

$message | Add-Content C:\Test\my-log.log



Best regards,

Pawel

anton_starchenk
Inactive

Hi Pavel,

It works! 

Thank you for help! 

 

See also comments on how to call (powershell) script here:

https://answers.dynatrace.com/questions/191051/scr...