Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过远程PowerShell会话指定repadmin.exe的密码_Powershell_Active Directory_Credentials - Fatal编程技术网

如何通过远程PowerShell会话指定repadmin.exe的密码

如何通过远程PowerShell会话指定repadmin.exe的密码,powershell,active-directory,credentials,Powershell,Active Directory,Credentials,我对repadmin.exe实用程序有一些问题 我有以下设置: 安装了Windows Server 2012R2,并在VMWare VM内运行 Windows 8.1 Pro(VMware主机,我的家庭桌面)。我的主机不是域的一部分 我做了以下工作: 在我的Windows 8.1上打开PowerShell ISE并建立到我的DC的远程连接(PowerShell ISE->文件->新建远程PowerShell选项卡) 一旦我远程连接到DC,我运行以下命令 repadmin.exe/syncall

我对repadmin.exe实用程序有一些问题

我有以下设置:

  • 安装了Windows Server 2012R2,并在VMWare VM内运行
  • Windows 8.1 Pro(VMware主机,我的家庭桌面)。我的主机不是域的一部分
  • 我做了以下工作:

  • 在我的Windows 8.1上打开PowerShell ISE并建立到我的DC的远程连接(PowerShell ISE->文件->新建远程PowerShell选项卡)

  • 一旦我远程连接到DC,我运行以下命令

    repadmin.exe/syncall

  • 并获取以下错误:

    CALLBACK MESSAGE: Error contacting server ad864315-1f78-4266-a7c2-2d6f9cde2f15._msdcs.arvo.local (network error): 5 (0x5):
        Access is denied.
    
    CALLBACK MESSAGE: Error contacting server a5904e4b-dff2-4b75-b856-45593a48d84e._msdcs.arvo.local (network error): 5 (0x5):
        Access is denied.
    
    SyncAll exited with fatal Win32 error: 8440 (0x20f8):
        The naming context specified for this replication operation is invalid.
    
    repadmin : Password: Failed to query the console mode.
        + CategoryInfo          : NotSpecified: (Password: Faile...e console mode.:String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError
    
    我在这里发现,可以使用/u:和/pw:键为repadmin指定用户名和密码。此外,还可以使用两种方法传递密码-要么在命令行中显式指定密码,要么输入*(星号),系统将提示我输入密码。第二种选择更可取

    所以我可以这样做(在命令行中指定密码):

    或使用星号并在以下命令后输入密码:

    repadmin.exe /u:domain_name\user_name /pw:* /syncall
    
    星号在服务器上的PowerShell本地工作,但如果使用远程PowerShell会话运行它,则会出现以下错误:

    CALLBACK MESSAGE: Error contacting server ad864315-1f78-4266-a7c2-2d6f9cde2f15._msdcs.arvo.local (network error): 5 (0x5):
        Access is denied.
    
    CALLBACK MESSAGE: Error contacting server a5904e4b-dff2-4b75-b856-45593a48d84e._msdcs.arvo.local (network error): 5 (0x5):
        Access is denied.
    
    SyncAll exited with fatal Win32 error: 8440 (0x20f8):
        The naming context specified for this replication operation is invalid.
    
    repadmin : Password: Failed to query the console mode.
        + CategoryInfo          : NotSpecified: (Password: Faile...e console mode.:String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError
    
    有什么解决办法吗?我不会在命令行中明确指定密码,因为它不安全


    谢谢

    您可以在远程PowerShell会话中尝试以下操作:

    $MyCreds = Get-Credential
    Start-Process -FilePath repadmin.exe -ArgumentList "/syncall" -Credential $MyCreds
    
    这样,您就可以利用PowerShell凭据管理的安全性,只需在有权执行复制的帐户下运行该进程