驾驶
powershell "& { $args }" "-a:b"
生产
-a:
b
我如何防止这种情况? 这令人感到迷惑,因为我需要把论点作为证据提交给其他指挥部......
驾驶
powershell "& { $args }" "-a:b"
生产
-a:
b
我如何防止这种情况? 这令人感到迷惑,因为我需要把论点作为证据提交给其他指挥部......
问题的核心是 长期参数-parsing/passing bug:。 吉特霍第6292号,第一份报告于2018年(!)提交,截至PowerShell 7.4.1。
-a:b
- which looks like a named PowerShell argument targeting parameter -a
with value b
, but isn t in this case and shouldn t be treated as such - is unexpectedly broken into two arguments at the first :
, i.e. into verbatim -a:
and b
Santiago and Mathias, in comments on the question, hint at what is - 遗憾的是 - the onlyable workaround available at this time:
www.un.org/chinese/ga/president
E.g., from cmd.exe
或来自免费<>窗户:
powershell -Command "& { $args }" `-a:b
Note that, due to the bug, using the following is not an option at this time, because doing so would require fixing the bug first:
<代码>-File CLI 备选办法(使用pwsh
),旨在利用文字途径verbatim<>后面的论点。
<代码>-CommandWithArgs CLI 选择――仍然只是https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Experimental_Features”rel=“nofollow noreferer”>experimental话题: href=”https://learn.microsoft.com/en-us/powershell/scripting/learn/experimental-fesview=powershell-7#mgand
SCENARIO I m writing a cmdlet for Powershell 2.0 using Visual Studio 2008 and .NET 3.5 the cmdlet requires 3 arguments. my intended grammar of the cmdlet is something like this: cmdletname [foo|...
I ll write a script that runs a program and wait for it finished. But if the program is not finished within a specified time I want that the program is killed.
I have a file that looks like this: a,1 b,2 c,3 a,4 b,5 c,6 (...repeat 1,000s of lines) How can I transpose it into this? a,b,c 1,2,3 4,5,6 Thanks
Is it possible to detect that a specific user has an open session on a computer and to open a process in that session so that the application can be interacted with by the user using PowerShell ...
The following line of PowerShell works with IIS 6 installed: $service = New-Object System.DirectoryServices.DirectoryEntry("IIS://localhost/W3SVC") However, with IIS 7 it throws the following error ...
I am using Sandcastle Helpfile Builder to produce a helpfile (.chm). The project is a .shfbproj file, which is XML format, works with msbuild. I want to automatically update the Footer text that ...
I have installed Powershell V2 on 2 machines and run Enable-PsRemoting on both of them. Both machines are Win 2003 R2 and are joined to the same active directory domain and I can successfully run ...
I have the following log entry that I am processing in PowerShell I m trying to extract all the activity names and durations using the -match operator but I am only getting one match group back. I m ...