Unlike the XP command interpreter (cmd.exe), double quotes are not sufficient to prevent the wildcard character (*) from being expanded on the client when using PowerShell. You need to provide extra quotes to prevent PowerShell from evaluating away the double quotes.
The extra quoting can be supplied as single quotes surrounding the double quotes or by escaping the double quotes with grave-accent characters.
For example,
PS D:\workspaces\alamimo_ws> p4 files '"*"'
or
PS D:\workspaces\alamimo_ws> p4 files `"*`"
will pass the command line to p4 in the same way as the XP command interpreter.
You can use the following program to test your quoting and examine what would be passed to p4.
/* gcl.c, Get and print the command line. * This program can be used to deterime how cmd.exe and PowerShell parsing differ. * * To build: * cl gcl.c /link kernel32.lib */ #include "Windows.h" main() { printf("%s\n", GetCommandLine()); }view plain text source
XP command interpreter (cmd.exe)
The example below illustrates that the XP command interpreter passes the command line to the program without modification.
D:\projects\gcl>.\gcl * .\gcl * D:\projects\gcl>.\gcl "*" .\gcl "*"
PowerShell
Notice that in the first two examples below the wildcard character is passed to the program without double quotes. The last two examples show that the extra quoting produces the desired result.
PS D:\projects\gcl> .\gcl * "D:\projects\gcl\gcl.exe" * PS D:\projects\gcl> .\gcl "*" "D:\projects\gcl\gcl.exe" * PS D:\projects\gcl> .\gcl '"*"' "D:\projects\gcl\gcl.exe" "*" PS D:\projects\gcl> .\gcl `"*`" "D:\projects\gcl\gcl.exe" "*"
To learn more about quoting, enter the following at the PowerShell prompt
PS D:\workspaces\alamimo_ws> help about_quoting_rules