Powershell : Ouvrir l'explorateur de fichier pour sélectionner un fichier
Résolu
__Juulien__
Messages postés
20
Date d'inscription
Statut
Membre
Dernière intervention
-
yg_be Messages postés 23541 Date d'inscription Statut Contributeur Dernière intervention -
yg_be Messages postés 23541 Date d'inscription Statut Contributeur Dernière intervention -
A voir également:
- Ouvrir powershell dans un dossier
- Comment ouvrir un fichier epub ? - Guide
- Comment ouvrir un fichier bin ? - Guide
- Dossier appdata - Guide
- Ouvrir un fichier .dat - Guide
- Comment ouvrir un fichier docx ? - Guide
2 réponses
yg_be
Messages postés
23541
Date d'inscription
Statut
Contributeur
Dernière intervention
Ambassadeur
1 583
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?
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>