加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

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

发布时间:2020-12-14 00:06:58 所属栏目:Windows 来源:网络整理
导读:$script = { Rename-Computer -ComputerName "ADMINIS-ID1PS7V" -NewName "SERVER1" }$computerName = "ADMINIS-ID1PS7V"$username = "Administrator"$pw = "123!@#qaZ"# Create Credentials$securepw = ConvertTo-SecureString $pw -asplaintext -force$cre
$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?你试过直接运行命令吗?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读