当我在Windows 7中安装较低版本的Powershell时,以下代码可以毫无问题地使用。获取服务的PowerShell错误
它检查文本文件中的每个服务器的某些服务并将结果转储为CSV。
现在我在Windows 10和使用PowerShell V5我收到此错误信息:
Get-Service : Cannot open Service Control Manager on computer 'tfsserver1'. This operation might require other privileges. At C:\Users\Razon\Desktop\Patching\ServerServices_Checker_v2.ps1:48 char:4 + (Get-Service -Name TFSJobAgent*,IIS*,World* -ComputerName $_) | Select Machine ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-Service], InvalidOperationException + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.GetServiceCommand
####System Varialbe to User's Deskotp
$filePath = [Environment]::GetFolderPath("Desktop")
下面是代码:
是否在远程服务器上启用PSRemoting?你有没有把它添加到你的TrustedHosts? –