Question Enable-PSRemoting depuis psexec

Plus d'informations
il y a 11 ans 8 mois #17854 par Howard
Salut,

Je bloque sur un point qui devient assez énervant. Je veux activer le PSRemoting sur mes postes distants en utilisant psexec (pas d'autres moyens de le faire ...). Quand je lance le script entier, j'ai mon invite PS qui affiche que je dois avoir des privilèges pour exécuter la commande alors que j'ai mis un compte d'admin du domaine dans la commande :

[code:1]
$ComputersRemote = Get-Content .\ComputersRemote.txt

foreach ($computer in $ComputersRemote)
{
Start-Process powershell.exe -verb RunAs
Domaine\AdminAccount -NoNewWindow -ArgumentList
\"C:\Script\psexec \\$computer -u
Domaine\AdminAccount -p P@ssw0rd Powershell
Enable-PSRemoting -Force\"
}
[/code:1]


Où est l'erreur please ?

Merci :-)

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 11 ans 8 mois #17856 par Gabriel
Réponse de Gabriel sur le sujet Re:Enable-PSRemoting depuis psexec
Salut

tu doit encapsuler ta commande enter \"{}\"

[code:1]
PS Travail:\> help about_PowerShell.exe -Detailed

TOPIC
about_PowerShell.exe

SHORT DESCRIPTION
Explains how to use the PowerShell.exe command-line tool. Displays
the syntax and describes the command-line switches.

PowerShell.exe starts a Windows PowerShell session. You can use it
in Cmd.exe and in Windows PowerShell.

LONG DESCRIPTION
SYNTAX
PowerShell[.exe]
[-EncodedCommand <Base64EncodedCommand>]
[-ExecutionPolicy <ExecutionPolicy>]
[-InputFormat {Text | XML}]
[-Mta]
[-NoExit]
[-NoLogo]
[-NonInteractive]
[-NoProfile]
[-OutputFormat {Text | XML}]
[-PSConsoleFile <FilePath> | -Version <Windows PowerShell version>]
[-Sta]
[-WindowStyle <style>]
[-File <FilePath> [<Args>]]
[-Command { - | <script-block> [-args <arg-array>]
| <string> [<CommandParameters>] } ]
PowerShell[.exe] -Help | -? | /?

................
EXAMPLES
PowerShell -PSConsoleFile sqlsnapin.psc1

PowerShell -Version 2.0 -NoLogo -InputFormat text -OutputFormat XML

PowerShell -Command {Get-EventLog -LogName security}

PowerShell -Command \"& {Get-EventLog -LogName security}\"

[/code:1]
ensuite je pense que ton psexec n'a pas le chemin par defaut il faut aussi envisager de mettre le chemin complet de powershell.exe, genre :

[code:1]
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command {Enable-PSRemoting -Force}
[/code:1]

cordialement.

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.038 secondes
Propulsé par Kunena