Need To Get Server Name In PowerShell

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
jjohnso7
Posts: 5
Joined: Wed Aug 24, 2016 3:02 pm

Need To Get Server Name In PowerShell

Post by jjohnso7 »

Host Monitor knows what the server name is. Is there any way I can get the ServerName into a PowerShell Script?
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

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
jjohnso7
Posts: 5
Joined: Wed Aug 24, 2016 3:02 pm

Need To Get Server Name In PowerShell

Post by jjohnso7 »

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.
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

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.
jjohnso7
Posts: 5
Joined: Wed Aug 24, 2016 3:02 pm

Post by jjohnso7 »

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>
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

You may set file path from "Params" field as Reply, then use %Reply% variable in "Attach file" field of Send e-mail (SMTP) action.
Post Reply