I got task to check counter of network connections by SCOM agent on HP-Unix servers. Nothing difficult but I got troubles with auto connection, all servers want me to accept store key in cache and I must input "y or n" :(
So ... '-batch' in help
# .\plink.exe -v -batch -pw 'Password123' 'userlogin@10.44.6.10' 'netstat | grep scom | wc -l'
$arr = @('10.44.6.6', '10.44.6.5','10.44.6.4','10.44.6.3','10.44.6.2', '10.44.6.12'');
$keys = ' -batch -pw ';
$cmd = 'netstat | grep scom | wc -l';
function run-SSH([string] $linuxHostname)
{
$plink = "C:\plink.exe "
$myConStr = "$plink $keys `'$pass`' `'$linuxHostname`' `'$cmd`'";
return Invoke-Expression $myConStr
}
foreach($server in $hpux) {
$m = run-SSH "scom@$server"
write-host "$server -> $m";
}
No comments:
Post a Comment