我喜欢标记和Mou编辑器,它具有动态预览渲染结果的强大功能.所以我想知道,有没有办法在Vim做同样的事情?
我以为我对此有了答案,但是我玩的越多,我就越认为它是Powershell的设计缺陷.
我想拖放(或使用Send-To机制)将多个文件和/或文件夹作为数组传递给Powershell脚本.
测试脚本
#Test.ps1
param ( [string[]] $Paths, [string] $ExampleParameter )
"Paths"
$Paths
"args"
$args
Run Code Online (Sandbox Code Playgroud)
尝试#1
我使用以下命令行创建了一个快捷方式,并将一些文件拖到它上面.这些文件作为单独的参数出现,这些参数首先匹配脚本参数的位置,其余部分放在$ args数组中.
尝试#1的快捷方式
powershell.exe -noprofile -noexit -file c:\Test.ps1
Run Code Online (Sandbox Code Playgroud)
包装脚本
我发现我可以用包装脚本做到这一点......
#TestWrapper.ps1
& .\Test.ps1 -Paths $args
Run Code Online (Sandbox Code Playgroud)
包装脚本的快捷方式
powershell.exe -noprofile -noexit -file c:\TestWrapper.ps1
Run Code Online (Sandbox Code Playgroud)
批处理文件包装器脚本
它通过批处理文件包装脚本工作...
REM TestWrapper.bat
SET args='%1'
:More
SHIFT
IF '%1' == '' GOTO Done
SET args=%args%,'%1'
GOTO More
:Done
Powershell.exe -noprofile -noexit -command "& {c:\test.ps1 %args%}"
Run Code Online (Sandbox Code Playgroud)
尝试回答
Keith Hill提出了使用以下快捷命令行的优秀建议,但它没有正确传递参数.当到达Test.ps1脚本时,带有空格的路径被拆分.
powershell.exe -noprofile -noexit -command "& {c:\test1.ps1 $args}"
Run Code Online (Sandbox Code Playgroud)
有没有人找到一种方法来做到这一点没有额外的脚本?
我尝试使用PowerShell移动文件夹
move-item c:\test c:\test2
Run Code Online (Sandbox Code Playgroud)
有效,但是
move-item c:\test \\192.168.1.50\c$\test2
Run Code Online (Sandbox Code Playgroud)
没告诉我
Move-Item:源和目标路径必须具有相同的根.移动不会跨卷运行.
我在键盘快捷键设置中注意到了这段代码.
{ "key": "ctrl+shift+c", "command":"workbench.action.terminal.openNativeConsole" },
我想知道,而不是打开cmd.exe,我可以将其更改为打开Powershell吗?
在Windows Server 2003 R2环境中,使用Powershell v2.0,如何复制Set-QADUser的功能以更新Active Directory中的用户属性,如电话号码和标题?
这里的诀窍是,我想这样做而不依赖于Set-QADUser,我还没有选择使用Server 2008的命令行开关.
谢谢.