2017-06-02 1 views
1

J'essaie d'exécuter une commande à distance sur un ordinateur doté d'un ". \".Powershell: Impossible de créer un fichier d'informations d'identification avec l'utilisateur point-slash

Lorsque j'essaie les informations d'identification en utilisant get-credentials et en les stockant dans un fichier, je ne suis pas autorisé à le faire. Lorsque je tente de le faire en utilisant

$Username = -join($env:COMPUTERNAME,'\<user_name>') 
$Password = '<password>' 
$pass = ConvertTo-SecureString -AsPlainText $Password -Force 
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass 
Invoke-Command -ComputerName <computer_name> -Authentication Kerberos -Credential $Cred {Get-WmiObject -Class Win32_LogicalDisk} 

Je reçois l'erreur suivante

Connecting to remote server failed with the following error message : WinRM cannot process the request. The following error occured while using Kerberos authenticati 
on: There are currently no logon servers available to service the logon request. 
Possible causes are: 
    -The user name or password specified are invalid. 
    -Kerberos is used when no authentication method and no user name are specified. 
    -Kerberos accepts domain user names, but not local user names. 
    -The Service Principal Name (SPN) for the remote computer name and port does not exist. 
    -The client and remote computers are in different domains and there is no trust between the two domains. 
After checking for the above issues, try the following: 
    -Check the Event Viewer for events related to authentication. 
    -Change the authentication method; add the destination computer to the WinRM TrustedHosts configuration setting or use HTTPS transport. 
Note that computers in the TrustedHosts list might not be authenticated. 
    -For more information about WinRM configuration, run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic. 
    + CategoryInfo   : OpenError: (:) [], PSRemotingTransportException 
    + FullyQualifiedErrorId : PSSessionStateBroken 

Mais quand je fais un mstsc et d'utiliser les mêmes informations d'identification ça marche.

S'il vous plaît laissez-moi savoir le chemin.

+1

Etes-vous sûr que vous avez besoin de auth avec kerberos? Vous utilisez le computername comme nom de domaine, cela me semble contre-intuitif. – restless1987

+0

Ce code est exécuté dans PS2, j'ai essayé de faire. \ mais le même résultat. J'ai utilisé Kerberos pour l'authentification, plutôt je l'ai trouvé pour être utilisé dans PowerShell 4. – prasunmax

+1

Le compte que vous utilisez est un compte local, et pas un compte de domaine, non? – restless1987

Répondre

0

$env:COMPUTERNAME est votre nom de l'ordinateur! Imaginez que j'utilise ComputerA et que je souhaite me connecter à ComputerB en tant qu'utilisateur local sur ComputerB.

Votre code, tel qu'il est actuellement, essaie de se connecter comme ComputerA\Username, ce qui n'existe pas sur ComputerB!

+0

Lorsque je fais un RDC (en utilisant mstsc) de computerA, je vois le même nom d'utilisateur. J'ai également essayé d'utiliser computerB/ de powershell mais il me donne la même erreur. – prasunmax

0

Pouvez-vous essayer de transmettre le nom d'utilisateur dans la syntaxe ci-dessous?

$Username = -join('Localhost','\<user_name>')