I think this is a problem with escaping certain characters.
I have this VBScript used to call a PowerShell command silently without a window (line 3) :
Dim objShell
Set objShell=CreateObject("WScript.Shell")
strExpression="get-printer | Where-Object {$_.DriverName -notlike "*microsoft*"} | export-csv C:\x\temp\printers.csv -encoding UTF8 -force"
strCMD="powershell -sta -noProfile -NonInteractive -executionpolicy Bypass -nologo -command " & Chr(34) &_
"&{" & strExpression &"}" & Chr(34)
objShell.Run strCMD,0
Which gives me this error:
Erreur : Type incompatible: '[string: "get-printer | Where-"]'
Code : 800A000D
If I remove the Where-Object and just do :
strExpression="get-printer | export-csv C:\x\temp\printers.csv -encoding UTF8 -force"
It works fine.
What seems to be the problem and what is the character used to "escape" in VBScript?