参数不会与Invoke-Command远程一起使用,-computername返回null

时间:2017-10-06 14:00:02

标签: host invoke-command

我想知道如何使用Invoke-Command传递参数以在脚本中使用以远程运行。

hostinfo = gethostbyname (hostname);
saddr->sin_addr = *(struct in_addr *) hostinfo->h_addr;

我想知道这是否可行以及修复此脚本需要做些什么? 感谢

1 个答案:

答案 0 :(得分:0)

$cname = Read-Host "Computer Name?"
$event = Read-Host "What event?"
$eventfilter = Read-Host "What key word are you looking for?"
$amount = Read-Host "How many events do you want to see?"


Invoke-Command -cn $cname -ScriptBlock {Get-EventLog -cn $using:cname -LogName $using:event -Message "*$eventfilter*" -Newest $using:amount | FT -Wrap}