windows – 无法使用powershell重命名计算机

前端之家收集整理的这篇文章主要介绍了windows – 无法使用powershell重命名计算机前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
$script = { Rename-Computer -ComputerName "ADMINIS-ID1PS7V" -NewName "SERVER1" }
$computerName = "ADMINIS-ID1PS7V"
$username = "Administrator"
$pw = "123!@#qaZ"

# Create Credentials
$securepw = ConvertTo-SecureString $pw -asplaintext -force
$cred = new-object -typename System.Management.Automation.PSCredential -argument $username,$securepw

# Create and use session
$session = New-PSSession -credential $cred -ComputerName $computerName
Invoke-Command -Session $session -ScriptBlock $script
Remove-PSSession $session

>我在机器上禁用了防火墙.
>我运行了enable-PSRemoting -force
>我甚至通过允许远程服务器管理来设置GPO
WinRM启用*

我一直在:

Fail to rename computer 'ADMINIS-ID1PS7V' to 'SERVER1' due to the following exception: Access is denied.
    + CategoryInfo          : OperationStopped: (ADMINIS-ID1PS7V:String) [Rename-Computer],InvalidOperationException
    + FullyQualifiedErrorId : FailToRenameComputer,Microsoft.PowerShell.Commands.RenameComputerCommand
    + PSComputerName        : ADMINIS-ID1PS7V
为什么要远程(invoke-command)使用具有-computername参数的cmdlet?你试过直接运行命令吗?
原文链接:/windows/368075.html

猜你在找的Windows相关文章