Powershell : Ouvrir l'explorateur de fichier pour sélectionner un fichier
Résolu/Fermé
__Juulien__
Messages postés
21
Date d'inscription
vendredi 11 mai 2018
Statut
Membre
Dernière intervention
14 novembre 2020
-
Modifié le 16 avril 2020 à 08:24
yg_be Messages postés 21481 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 26 mai 2023 - 16 avril 2020 à 09:17
yg_be Messages postés 21481 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 26 mai 2023 - 16 avril 2020 à 09:17
A voir également:
- Methodinvocationnotsupportedinconstrainedlanguage
- Fichier rar - Guide
- Fichier host - Guide
- Ouvrir fichier .bin - Guide
- Ouvrir un fichier .dat - Guide
- Comment ouvrir un fichier apk ? - Guide
2 réponses
yg_be
Messages postés
21481
Date d'inscription
lundi 9 juin 2008
Statut
Contributeur
Dernière intervention
26 mai 2023
1 344
16 avril 2020 à 08:29
16 avril 2020 à 08:29
bonjour, " je n'arrive pas à le faire fonctionner": que se passe-t'il?
as-tu essayé en mettant la première ligne à la fin?
as-tu essayé en mettant la première ligne à la fin?
__Juulien__
Messages postés
21
Date d'inscription
vendredi 11 mai 2018
Statut
Membre
Dernière intervention
14 novembre 2020
16 avril 2020 à 08:35
16 avril 2020 à 08:35
Oui le problème est probablement la première ligne. Si je ne la met pas, aucune erreur et si je la met plutôt à la fin cela ne change à rien.
Voici mes erreurs quand j'exécute le toute :
Cannot invoke method. Method invocation is supported only on core types in this language mode.
At C:\Users\FroidevauxJ\Documents\test.ps1:5 char:2
+ [System.Reflection.Assembly]::LoadWithPartialName("System.Windows ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage
New-Object : Cannot create type. Only core types are supported in this language mode.
At C:\Users\FroidevauxJ\Documents\test.ps1:6 char:13
+ $objForm = New-Object System.Windows.Forms.OpenFileDialog
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (:) [New-Object], PSNotSupportedException
+ FullyQualifiedErrorId : CannotCreateTypeConstrainedLanguage,Microsoft.PowerShell.Commands.NewObjectCommand
The property 'InitialDirectory' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\FroidevauxJ\Documents\test.ps1:7 char:2
+ $objForm.InitialDirectory = $Directory
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'Filter' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\FroidevauxJ\Documents\test.ps1:8 char:2
+ $objForm.Filter = $Filter
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'Title' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\FroidevauxJ\Documents\test.ps1:9 char:2
+ $objForm.Title = $Title
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
You cannot call a method on a null-valued expression.
At C:\Users\FroidevauxJ\Documents\test.ps1:10 char:2
+ $Show = $objForm.ShowDialog()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Select-FileDialog : Operation cancelled by user.
At line:1 char:9
+ $file = Select-FileDialog -Title "Select a file"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Select-FileDialog</code>
Voici mes erreurs quand j'exécute le toute :
Cannot invoke method. Method invocation is supported only on core types in this language mode.
At C:\Users\FroidevauxJ\Documents\test.ps1:5 char:2
+ [System.Reflection.Assembly]::LoadWithPartialName("System.Windows ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage
New-Object : Cannot create type. Only core types are supported in this language mode.
At C:\Users\FroidevauxJ\Documents\test.ps1:6 char:13
+ $objForm = New-Object System.Windows.Forms.OpenFileDialog
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (:) [New-Object], PSNotSupportedException
+ FullyQualifiedErrorId : CannotCreateTypeConstrainedLanguage,Microsoft.PowerShell.Commands.NewObjectCommand
The property 'InitialDirectory' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\FroidevauxJ\Documents\test.ps1:7 char:2
+ $objForm.InitialDirectory = $Directory
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'Filter' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\FroidevauxJ\Documents\test.ps1:8 char:2
+ $objForm.Filter = $Filter
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'Title' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\FroidevauxJ\Documents\test.ps1:9 char:2
+ $objForm.Title = $Title
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
You cannot call a method on a null-valued expression.
At C:\Users\FroidevauxJ\Documents\test.ps1:10 char:2
+ $Show = $objForm.ShowDialog()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Select-FileDialog : Operation cancelled by user.
At line:1 char:9
+ $file = Select-FileDialog -Title "Select a file"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Select-FileDialog</code>
yg_be
Messages postés
21481
Date d'inscription
lundi 9 juin 2008
Statut
Contributeur
Dernière intervention
26 mai 2023
1 344
16 avril 2020 à 08:49
16 avril 2020 à 08:49
et en exécutant ton script ainsi, dans une boite de commande?
PowerShell.exe -f c:\yourscript.ps1
__Juulien__
Messages postés
21
Date d'inscription
vendredi 11 mai 2018
Statut
Membre
Dernière intervention
14 novembre 2020
>
yg_be
Messages postés
21481
Date d'inscription
lundi 9 juin 2008
Statut
Contributeur
Dernière intervention
26 mai 2023
16 avril 2020 à 08:59
16 avril 2020 à 08:59
Ok d'accord je viens de comprendre c'est une question de droit, si je fais votre commande cela me renvoies les mêmes erreurs. Il suffit simplement d'ouvrir powershell en tant qu'administrateur.
Merci pour votre aide
Merci pour votre aide
yg_be
Messages postés
21481
Date d'inscription
lundi 9 juin 2008
Statut
Contributeur
Dernière intervention
26 mai 2023
1 344
>
__Juulien__
Messages postés
21
Date d'inscription
vendredi 11 mai 2018
Statut
Membre
Dernière intervention
14 novembre 2020
16 avril 2020 à 09:17
16 avril 2020 à 09:17
parfait, peux-tu alors marquer le sujet comme résolu?