在使用 PowerShell 的 Restart-Computer 命令时,如果遇到失败的情况,可能的原因和解决方法包括: 权限问题: 确保你有足够的权限来重启目标计算机。如果是远程计算机,你可能需要使用管理员凭据。 示例代码: powershell Restart-Computer -ComputerName "RemoteComputer" -Credential (Get-Credential) 远程设置错误: 确保...
如需背景工作 Windows PowerShell 的詳細資訊,請參閱about_Jobs和about_Remote_Jobs。 Type:SwitchParameter Position:Named Default value:False Required:False Accept pipeline input:False Accept wildcard characters:False -ComputerName 指定一部計算機名稱或以逗號分隔的計算機名稱陣列。R...
Computer 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Restart-Computer 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Send-MailMessage 3.1.0.0 Microsoft.PowerShell.Utility Cmdlet Set-Service 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Set-WmiInstance 3.1.0.0 Microsoft.PowerShell.Management Cmdlet Show-...
sudo systemctl restart sshd.service 在macOS 计算机上安装 SSH 服务 安装最新版本的 PowerShell。 有关详细信息,请在macOS 上安装 PowerShell。 按照以下步骤确保启用了 SSH 远程处理: 打开System Settings。 单击General 单击Sharing。 检查Remote Login以设置Remote Login: On。
$RemoteScriptCommand = { param ( [Parameter(Mandatory=$True)] $ComputerName) # Write out the hostname of the hybrid connection server. hostname # Write out the hostname of the remote server. Invoke-Command -ComputerName $ComputerName -Credential $Using:Credential -ScriptBlock {hostname} ` ...
Restart-Computer -ComputerName "sz-test1119.test.local" -Credential $cred -Force 1. 2. 3. 命令执行结果如下: PS C:\Users> $cred = Get-Credential 位于命令管道位置 1 的 cmdlet Get-Credential 请为以下参数提供值: Credential PS C:\Users>Restart-Computer -ComputerName "sz-test1119.test.local...
组策略名称: Allow remote server management through WinRM 组策略路径: Computer configuration\Administrative Templates\Windows Components\Windows Remote Management (WinRM)\WinRM Service 注意:在防火墙端放行远程连接的端口 开启远程管理服务 Enable-PSRemoting ...
Invoke-Command -ComputerName cm-12r2 -FilePath .\task.ps1 1. 我在本地创建了脚本文件 task.ps1,task.ps1 中的脚本创建了一个 test.txt 文件,并把 PowerShell 的版本信息添加到这个文件中。运行上面的命令: 然后在远程机器上看有没有文件创建: ...
Invoke-Command -ComputerName cd-lsr-svr -ScriptBlock { Get-Service WinRM } -credential nickli 执行上面的命令,并输入用户的密码: 虽然命令被执行了,但缺陷也很明显:需要用户输入密码,因此无法被写到脚本中进行自动化操作。 使用下面的方法把密码写到命令中(这样就可以自动化了): ...
其中remote_server_name用于指定远程服务器。 限制:对于远程安装功能,必须使用/RemoteComputerCLI 选项中所使用的计算机名称。 要验证是否已配置 Windows PowerShell Remoting 功能,请输入以下 cmdlets: A. 在服务器 A 和服务器 B 上未启用凭证安全性支持提供程序 (CredSSP) 认证时,请输入以下 cmdlet: ...