Powershell function throwing null exception

*爱你&永不变心* 提交于 2019-12-06 13:59:41
Arluin

You need to specify the -ArgumentList parameter with your Invoke-Command. For example:

Invoke-Command -Session $session -ScriptBlock { 
       param($Computer) 
       Get-WmiObject -ComputerName $Computer -Query "SELECT * FROM Win32_Group" 
  } -ArgumentList $Computer
Kirt Carson

The $IP is global and therefore known with the function. The -ArgumentList is needed or populate your $MyScriptBlock a line before acting on it with Invoke-Command.

Jimbo

The function does not know what $ip is.

You need to change the function to accept a parameter of $ip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!