相关疑难解决方法(0)

从命令提示符运行PowerShell命令(没有ps1脚本)

我正在寻找一种从命令提示符运行几个PowerShell命令的方法.我不想为此创建脚本,因为它只需要运行几个命令,因为我真的不知道如何使用PowerShell编写脚本.

这是我试图用来开始的命令:

Get-AppLockerFileInformation -Directory <folderpath> -Recurse -FileType <type>
Run Code Online (Sandbox Code Playgroud)

我真的不想为此创建一个脚本,因为如果我可以从批处理文件中运行一个或两个命令与其余的东西会更容易.

编辑:这是我到目前为止所尝试的.

1)

powershell -Command "Get-AppLockerFileInformation....."
Error: The term 'Get-AppLockerFileInformation is not recognized as the name of a cmdlet, function, script file, or operable program....
Run Code Online (Sandbox Code Playgroud)

2)

powershell -Command {Get-AppLockerFileInformation.....}
Run Code Online (Sandbox Code Playgroud)

这种方式没有错误,但我没有得到任何回报.如果我使用Set-AppLockerPolicy...没有任何反应.

3)

powershell -Command "{Get-AppLockerFileInformation.....}"
Error: The term 'Get-AppLockerFileInformation is not recognized as the name of a cmdlet, function, script file, or operable program....
Run Code Online (Sandbox Code Playgroud)

4)

powershell -Command "& {Get-AppLockerFileInformation.....}"
Error: The term 'Get-AppLockerFileInformation is not recognized as the name of a …
Run Code Online (Sandbox Code Playgroud)

powershell cmd batch-file

31
推荐指数
2
解决办法
11万
查看次数

标签 统计

batch-file ×1

cmd ×1

powershell ×1