2017-02-14 15 views
0

同じドメインに2台のサーバー(Windows server 2012 R2)があります。 私は、SERVER01上のコマンドを実行します。Invoke-commandに資格情報が必要ありません

Invoke-Command -ComputerName server02 -Credential Administrator -ScriptBlock {Get-Culture} 

私が(SERVER2の)私の管理者のパスワードを与え、それがうまく動作します。 しかし、ときに私が試してみてください。

Invoke-Command -ComputerName server02 -ScriptBlock {Get-Culture} 

また、動作しているようです。おそらく、2つのサーバーが同じドメインにあるためです。私はあなたが正しい資格情報を提供できるときにのみ動作するようにしています。誰かがそれで私を助けることができますか?

+1

あなたはおそらくすでにサーバにアクセスする権限を持っている、それは、このようなあなたの資格情報(PSを開いたユーザー)を使用して – 4c74356b41

答えて

1

これは、Domain Adminsグループまたはそれ以降のドメイン管理者のアカウントまたはアカウントによって実行されている可能性があります。

いずれの場合でも、アカウントにはそのコンピュータの特典があるため、この結果になります。

+0

ええ、それはリモートサーバー上だけでなく、ドメイン全体で管理者だったいくつかのアカウントでした。 – DenCowboy

1

server01でどのユーザーにスクリプトを実行しますか?そのユーザーはserver02にも権限を持っていますか?ユーザーがSERVER01とServer02の上の管理者権限を持っている場合、何の資格情報がneccessaryません...(私の知る限りでは)

提供された資格情報が有効であるかどうかを確認するには、ここを見て: https://gallery.technet.microsoft.com/scriptcenter/Test-Credential-dda902c6

か何かここで見つかった

$cred = Get-Credential #Read credentials 
$username = $cred.username 
$password = $cred.GetNetworkCredential().password 

# Get current domain using logged-on user's credentials 
$CurrentDomain = "LDAP://" + ([ADSI]"").distinguishedName 
$domain = New-Object System.DirectoryServices.DirectoryEntry($CurrentDomain,$UserName,$Password) 

if ($domain.name -eq $null) 
{ 
    write-host "Authentication failed - please verify your username and password." 
    exit #terminate the script. 
} 
else 
{ 
    write-host "Successfully authenticated with domain $domain.name" 
} 

(しかし、私はそれをテストしていません): https://serverfault.com/questions/276098/check-if-user-password-input-is-valid-in-powershell-script

関連する問題