1 Answers
Best Answer
$func = {
function Say-Hello
{
param($Name)
Write-Host "$Name,您好!"
}
Say-Hello -Name 'PSTips.NET'
}
# 将函数定义转换成字符串
# Server List
#$serverList = Get-Content 'serverlist.txt'
$serverList=@('localhost')
foreach($server in $serverList )
{
Invoke-Command -ComputerName $server -ScriptBlock $func
}
