我正在寻找一种从命令提示符运行几个PowerShell命令的方法 . 我不想为此创建脚本,因为它只需要运行几个命令,因为我真的不知道如何使用PowerShell编写脚本 .
这是我试图用来开始的命令:
Get-AppLockerFileInformation -Directory <folderpath> -Recurse -FileType <type>
我真的不想为此创建一个脚本,因为如果我可以从批处理文件中运行一个或两个命令以及剩下的东西会更容易 .
编辑:这是我到目前为止尝试过的 .
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....
2)
powershell -Command {Get-AppLockerFileInformation.....}
这种方式没有错误,但我没有得到任何回报 . 如果我使用 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....
4)
powershell -Command "& {Get-AppLockerFileInformation.....}"
Error: The term 'Get-AppLockerFileInformation is not recognized as the name of a cmdlet, function, script file, or operable program....
5)
powershell "& {Get-AppLockerFileInformation.....}"
Error: The term 'Get-AppLockerFileInformation is not recognized as the name of a cmdlet, function, script file, or operable program....
6)
powershell -ExecutionPolicy Bypass -NoLogo -NoProfile -Command {Get-AppLockerFileInformation....}
没有错误但没有任何反应 .
7)
powershell -ExecutionPolicy Bypass -NoLogo -NoProfile -Command "Get-AppLockerFileInformation...."
没有错误但没有任何反应 .
3 回答
这是 only answer 设法为我的问题工作,在this网页的帮助下弄清楚了(很好的参考) .
此外,这是一个执行多个命令的简洁方法:
例如,这就是我运行我的2个命令的方式:
也许
powershell -Command "Get-AppLockerFileInformation....."
看看
powershell /?
在单个命令行上运行它,如下所示: