2017-04-21 114 views
0

我可以从我的桌面运行以下命令离开我的HQ域,但我无法创建远程Powershell会话。 我搜索了很多帖子,无法确定如何解决这个问题。Powershell远程计算机会话

$TargetServer = 'RemoteComputer' 
Get-WmiObject -Namespace "root\cimv2" -Class Win32_Process -Impersonation 3 -Credential RemoteDomain\username -ComputerName $TargetServer 

需要这个工作,请注意,如果我登录到管理服务器在远程域命令的工作与我的默认NT权限:

$TargetServerSession = New-PSSession -Credential RemoteDomain\username -ComputerName $TargetServer 

回答

1

什么是你所得到的错误?也许这是一种凭据,我很想念get-credential的一部分。

YourUser需要远程​​机器上的本地管理权限,您需要为会话提供密码。

你做这个输入的PSSession:

# * Define name of remote machine 
$TargetServer = "RemoteComputer" 

# * Get a password prompt for the user 'YourUser' and store the creds 
$Cred = (Get-Credential YourDomain\YourUser) 

# * Create a PSSession for the Remote Computer using the Credentials you just provided 
$PSSession = new-pssession -Computer $TargetServer -Credential $Cred 

# * Enter the session 
Enter-PSSession $PSSession 

如果此代码不能正常工作,那么我们需要更多的相关信息。

相关问题