支持PS 3.0及以后版本
如果你要通过Powershell远程访问电脑。这时你必须在对方电脑(你想要访问的电脑),用管理员权限执行下面代码:
PS> Enable-PSRemoting -SkipNetworkProfileCheck -Force
一旦你这样执行了代码,你只要拥有目标电脑的本地管理员权限就能从其它窗体访问这台电脑了。当两台电脑在同一个域内你就可以直接指定计算机名而不需要它的IP的地址。
启动交互方式:
PS> Enter-PSSession -ComputerName targetComputerName
要远程代入执行代码,请尝试:
PS> Invoke-Command -ScriptBlock { Get-Service } -ComputerName targetComputerName
原文地址:Enabling and Disabling PowerShell Remoting
本文链接: https://www.pstips.net/enabling-and-disabling-powershell-remoting.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
[array]$ipaddress = {“192.168.1.1″,”192.168.1.2”}foreach($ip in $ipaddress){$pwd= ConvertTo-SecureString “123” -AsPlainText -Force$cred= New-Object System.Management.Automation.PSCredential(“administrator”,$pwd)invoke-command -computer $ip -Credential $cred -ScriptBlock{ New-Item c:111.txt -Type file}}报错,如何破呢?Invoke-Command : Cannot evaluate parameter ‘ComputerName’ because its argument is specified as a script block and there is no input. A script block cannot be evaluated without input.