Question impossible lancer script powershell via php
- Laurent Dardenne
- Hors Ligne
- Modérateur
-
Réduire
Plus d'informations
- Messages : 6311
- Remerciements reçus 68
il y a 10 ans 11 mois #19334
par Laurent Dardenne
Tutoriels PowerShell
Réponse de Laurent Dardenne sur le sujet Re:impossible lancer script powershell via php
Kevios écrit:
D'avoir un compte rendu avec Resolve-Error ce serait bien...Je n'ai jamais vraiment utilisé la gestion des erreurs
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- Kevin
- Auteur du sujet
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 14
- Remerciements reçus 0
il y a 10 ans 11 mois #19341
par Kevin
Réponse de Kevin sur le sujet Re:impossible lancer script powershell via php
Alors, j'ai réussi à récupérer ceci avec resolve-error
PSMessageDetails : Exception : System.InvalidOperationException: Impossible d'ex�cuter cette commande en raison de l'erreur�: Descripteur non valide. � System.Management.Automation.MshCommandRuntime.Thr owTerminatingError(ErrorRecord errorRecord) TargetObject : CategoryInfo : InvalidOperation: (
[Start-Process], InvalidOperation Exception FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands .StartProcessCommand ErrorDetails : InvocationInfo : System.Management.Automation.InvocationInfo PipelineIterationInfo : {0, 0} MyCommand : Start-Process BoundParameters : {[Credential, System.Management.Automation.PSCredential], [A rgumentList, System.String[]], [FilePath, powershell.exe]} UnboundArguments : {} ScriptLineNumber : 19 OffsetInLine : 14 HistoryId : -1 ScriptName : \\SERVEUR\script\Lancement_Powershell_Info_PC.ps1 Line : Start-Process powershell.exe -Credential $cred -ArgumentList \"Start-Process '\\SERVEUR\script\INFO_PC.exe' -Verb runAs \" PositionMessage : Au niveau de \\SERVEUR\script\Lancement_Powershell_Info_PC .ps1&#65533;: 19 Caract&#65533;re&#65533;: 14 + Start-Process <<<< powershell.exe -Credential $cred -Argu mentList \"Start-Process '\\SERVEUR\script\INFO_PC.exe' -Ve rb runAs\" InvocationName : Start-Process PipelineLength : 1 PipelinePosition : 1 ExpectingInput : False CommandOrigin : Internal 0000000000000000000000000000000000000000000000000000000000000000000000000000000 0 Message : Impossible d'ex&#65533;cuter cette commande en raison de l'erreur&#65533;: D escripteur non valide. Data : {} InnerException : TargetSite : Void ThrowTerminatingError(System.Management.Automation.ErrorR ecord) StackTrace : &#65533; System.Management.Automation.MshCommandRuntime.ThrowTermi natingError(ErrorRecord errorRecord) HelpLink : Source : System.Management.Automation
C'est bien ce type de résultat qu'on doit récupérer avec Resolve-Error?
PSMessageDetails : Exception : System.InvalidOperationException: Impossible d'ex&#65533;cuter cette commande en raison de l'erreur&#65533;: Descripteur non valide. &#65533; System.Management.Automation.MshCommandRuntime.Thr owTerminatingError(ErrorRecord errorRecord) TargetObject : CategoryInfo : InvalidOperation: (
C'est bien ce type de résultat qu'on doit récupérer avec Resolve-Error?
Connexion ou Créer un compte pour participer à la conversation.
- Laurent Dardenne
- Hors Ligne
- Modérateur
-
Réduire
Plus d'informations
- Messages : 6311
- Remerciements reçus 68
il y a 10 ans 11 mois #19343
par Laurent Dardenne
Tutoriels PowerShell
Réponse de Laurent Dardenne sur le sujet Re:impossible lancer script powershell via php
Kevios écrit:
Mais c'est illisible.
Quels droits le script PS, exécuté par PHP, a-t-il ? Admin/user ?
As-tu essayé avec un script simple qui t'afficherais si le contexte est admin ou pas. Voir le début de ce script .
Il faut s'assurer si c'est un pb de droits ou de construction de ligne d'appel de start-process.
Là c'est du pifomètre
Oui, par défaut il affiche la dernière erreur.C'est bien ce type de résultat qu'on doit récupérer avec Resolve-Error?
Mais c'est illisible.
Quels droits le script PS, exécuté par PHP, a-t-il ? Admin/user ?
As-tu essayé avec un script simple qui t'afficherais si le contexte est admin ou pas. Voir le début de ce script .
Il faut s'assurer si c'est un pb de droits ou de construction de ligne d'appel de start-process.
Là c'est du pifomètre
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- Kevin
- Auteur du sujet
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 14
- Remerciements reçus 0
il y a 10 ans 11 mois #19344
par Kevin
Réponse de Kevin sur le sujet Re:impossible lancer script powershell via php
le script powershell a les droits user quand lancé depuis le PHP. Une fois dans le script, l'application se lance avec les droits d'administrateur.
A ce moment-là je peux essayer de faire une élévation de privilège directement dans php.
Voici mon élévation de privilège dans mon script powershell:
[code:1]$username = $Variables.DOMAINE + \"\\" + $variables.USER2
$password = (ConvertTo-SecureString -String $variables.PWD2 -asplaintext -force)
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$password[/code:1]
Pour resolve-error, il me sort tout sur mon site PHP. Je vais essayer d'organiser mieux le résultat pour le retransmettre proprement ^^
A ce moment-là je peux essayer de faire une élévation de privilège directement dans php.
Voici mon élévation de privilège dans mon script powershell:
[code:1]$username = $Variables.DOMAINE + \"\\" + $variables.USER2
$password = (ConvertTo-SecureString -String $variables.PWD2 -asplaintext -force)
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$password[/code:1]
Pour resolve-error, il me sort tout sur mon site PHP. Je vais essayer d'organiser mieux le résultat pour le retransmettre proprement ^^
Connexion ou Créer un compte pour participer à la conversation.
- Laurent Dardenne
- Hors Ligne
- Modérateur
-
Réduire
Plus d'informations
- Messages : 6311
- Remerciements reçus 68
il y a 10 ans 11 mois #19345
par Laurent Dardenne
Tutoriels PowerShell
Réponse de Laurent Dardenne sur le sujet Re:impossible lancer script powershell via php
Kevios écrit:
Ainsi tu sauvegarderas la collection d'erreur, ce qui facilite le debug/support.
je comprends, dans ce tutoriel je propose un gestionnaire d'erreur global, tu peux l'implémenter si tu le souhaites.Pour resolve-error, il me sort tout sur mon site PHP. Je vais essayer d'organiser mieux le résultat pour le retransmettre proprement ^^
Ainsi tu sauvegarderas la collection d'erreur, ce qui facilite le debug/support.
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- Kevin
- Auteur du sujet
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 14
- Remerciements reçus 0
il y a 10 ans 11 mois #19346
par Kevin
Réponse de Kevin sur le sujet Re:impossible lancer script powershell via php
J'ai réussi à remettre au propre comme je le pouvais le message d'erreur:
PSMessageDetails :
Exception : System.InvalidOperationException: Impossible d'executer cette commande en raison de l'erreur : Descripteur non valide.
System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
TargetObject :
CategoryInfo :
InvalidOperation: ( : ) [Start-Process], InvalidOperation Exception
FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
PipelineIterationInfo : {0, 0}
MyCommand : Start-Process
BoundParameters : {[Credential, System.Management.Automation.PSCredential], [NoNewWindow, True], [ArgumentList, System.String[]], [FilePath, powershell.exe]}
UnboundArguments : {}
ScriptLineNumber : 20
OffsetInLine : 14
HistoryId : -1
ScriptName : \\SERVEUR\script\Lancement_Powershell_Info_PC.ps1
Line : Start-Process powershell.exe -Credential $cred -NoNewWindow: $true -ArgumentList \"Start-Process '\\SERVEUR\script\INFO_ PC.exe' -Verb runAs\"
PositionMessage : Au niveau de \\SERVEUR\script\Lancement_Powershell_Info_PC .ps1 l:20 Caractere:14 + Start-Process <<<< powershell.exe -Credential $cred -NoNe wWindow:$true -ArgumentList \"Start-Process '\\SERVEUR\script\INFO_PC.exe' -Verb runAs\"
InvocationName : Start-Process
PipelineLength : 1
PipelinePosition : 1
ExpectingInput : False
CommandOrigin : Internal
0000000000000000000000000000000000000000000000000000000000000000000000000000000 0
Message : Impossible d'executer cette commande en raison de l'erreur : Descripteur non valide.
Data : {}
InnerException :
TargetSite : Void
ThrowTerminatingError(System.Management.Automation.ErrorRecord)
StackTrace : System.Management.Automation.MshCommandRuntime.ThrowTermi natingError(ErrorRecord errorRecord)
HelpLink :
Source : System.Management.Automation
Est-ce plus lisible? ^^\"
PSMessageDetails :
Exception : System.InvalidOperationException: Impossible d'executer cette commande en raison de l'erreur : Descripteur non valide.
System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
TargetObject :
CategoryInfo :
InvalidOperation: ( : ) [Start-Process], InvalidOperation Exception
FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
PipelineIterationInfo : {0, 0}
MyCommand : Start-Process
BoundParameters : {[Credential, System.Management.Automation.PSCredential], [NoNewWindow, True], [ArgumentList, System.String[]], [FilePath, powershell.exe]}
UnboundArguments : {}
ScriptLineNumber : 20
OffsetInLine : 14
HistoryId : -1
ScriptName : \\SERVEUR\script\Lancement_Powershell_Info_PC.ps1
Line : Start-Process powershell.exe -Credential $cred -NoNewWindow: $true -ArgumentList \"Start-Process '\\SERVEUR\script\INFO_ PC.exe' -Verb runAs\"
PositionMessage : Au niveau de \\SERVEUR\script\Lancement_Powershell_Info_PC .ps1 l:20 Caractere:14 + Start-Process <<<< powershell.exe -Credential $cred -NoNe wWindow:$true -ArgumentList \"Start-Process '\\SERVEUR\script\INFO_PC.exe' -Verb runAs\"
InvocationName : Start-Process
PipelineLength : 1
PipelinePosition : 1
ExpectingInput : False
CommandOrigin : Internal
0000000000000000000000000000000000000000000000000000000000000000000000000000000 0
Message : Impossible d'executer cette commande en raison de l'erreur : Descripteur non valide.
Data : {}
InnerException :
TargetSite : Void
ThrowTerminatingError(System.Management.Automation.ErrorRecord)
StackTrace : System.Management.Automation.MshCommandRuntime.ThrowTermi natingError(ErrorRecord errorRecord)
HelpLink :
Source : System.Management.Automation
Est-ce plus lisible? ^^\"
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.058 secondes
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Entraide pour les initiés
- impossible lancer script powershell via php