View previous topic :: View next topic |
Author |
Message |
jjohnso7
Joined: 24 Aug 2016 Posts: 5
|
Posted: Fri Sep 09, 2016 3:59 pm Post subject: Need To Get Server Name In PowerShell |
|
|
Host Monitor knows what the server name is. Is there any way I can get the ServerName into a PowerShell Script? |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12792 Location: USA
|
Posted: Sat Sep 10, 2016 2:32 pm Post subject: |
|
|
What exactly "server" do you have in mind?
Server where HostMonitor is running?
Server where some Remote Monitoring Agent running?
Server checked by some test method?
some other server?
How exactly your script relates to HostMonitor?
Script started by "Execute external program" action assigned to some test item?
Regards
Alex |
|
Back to top |
|
|
jjohnso7
Joined: 24 Aug 2016 Posts: 5
|
Posted: Mon Sep 12, 2016 9:02 am Post subject: Need To Get Server Name In PowerShell |
|
|
HostMonitor periodically runs a test on a list of servers. The test calls PowerShell via Shell Script. Maybe Host Monitor could pass the Server Being Tested name via an input parameter.
Last edited by jjohnso7 on Mon Sep 12, 2016 9:08 am; edited 1 time in total |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Mon Sep 12, 2016 9:07 am Post subject: |
|
|
Sure, you may specify parameters (e.g. Server name) in "Params" field,
then you may use this value in the script.
E.g.
"Params" field:
22 MyServer1
Script:
$statusOk = "ScriptRes:Ok:"
$val = $args[1]
echo $statusOk$val
If parameter contains space symbol, just put it in single quote marks. |
|
Back to top |
|
|
jjohnso7
Joined: 24 Aug 2016 Posts: 5
|
Posted: Mon Sep 12, 2016 1:57 pm Post subject: |
|
|
If I pass a parameter to PowerShell containing a file path, it goes in a field <Params>. Can I use that variable name in <Params> to pass info to an alert that sends an email with an attachment of the same file name? Like this: Attach File <Params> |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Mon Sep 12, 2016 2:44 pm Post subject: |
|
|
You may set file path from "Params" field as Reply, then use %Reply% variable in "Attach file" field of Send e-mail (SMTP) action. |
|
Back to top |
|
|
|