Salut,

Dans une application Access je génère un script PS que je lance ensuite via la commande Shell(). Powershell se lance bien mais j'ai le message d'erreur suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Add-PSSnapin : Aucun composant logiciel enfichable n'a été inscrit pour Windows PowerShell version 3.
Au caractère C:\temp\Suppression.ps1:1 : 1
+ Add-PSSnapin Microsoft.Exchange.Management.Powershell.E2010
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument : (Microsoft.Excha...owershell.E2010:String) [Add-PSSnapin], PSArgumentE
   xception
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

Set-Mailbox : Le terme «Set-Mailbox» n'est pas reconnu comme nom d'applet de commande, fonction, fichier de script ou
programme exécutable. Vérifiez l'orthographe du nom, ou si un chemin d'accès existe, vérifiez que le chemin d'accès
est correct et réessayez.
Au caractère C:\temp\Suppression.ps1:2 : 1
+ Set-Mailbox -Identity CONSOLE@cerfrance.local -DeliverToMailboxAndForward $false ...
+ ~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Set-Mailbox:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Je lance mon appli Access sous Windows Server 2012 64 Bits. Je ne comprends pas, quand je lance Powershell via le raccourci (C:\Windows\system32\WindowsPowershell\v1.0\powershell.exe) je peux activer mon module Exchange sans problème...

Voici le script PS généré via VBA :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
Add-PSSnapin Microsoft.Exchange.Management.Powershell.E2010
Set-Mailbox -Identity console@domaine.local -DeliverToMailboxAndForward $false -ForwardingAddress $null
Je lance Powershell via la commande suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
Shell("C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -NoExit -File ""C:\temp\Suppression.ps1""", vbNormalFocus)
Je viens de me rendre compte que même si dans mon code je pointe le powershell présent dans system32 c'est celui de syswow64 qui est lancé...