繁体   English   中英

如何在批处理文件中执行此 powershell 命令?

[英]How to execute this powershell commands in a batch file?

我正在尝试运行此 powershell 命令:

Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize > C:\Users\Administrateur\Desktop\Mysoftware.txt

在批处理文件中。 这就是我现在得到的:

powershell.exe -noexit -command "& {Get-ItemProperty 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'; Select-Object DisplayName, DisplayVersion, Publisher, InstallDate; Format-Table -Autosize; > 'C:\Users\Administrateur\Desktop\Mysoftware.txt';}"

但它告诉我 ">" 不是命令

我想要做的是在 MySoftware.txt 文件中获取计算机的所有软件的列表。

谢谢您的帮助

去除那个 ”;” 在通过“>”重定向到文件并使用“|”之前将命令的输出传递到下一个命令的输入,而不是放置“;” 在每个命令的末尾。

powershell.exe -noexit -command "& {Get-ItemProperty 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table -Autosize > 'C:\Users\Administrateur\Desktop\Mysoftware.txt' }"

你可以试试这条线吗?

powershell.exe -noexit -command "& {Get-ItemProperty 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | export-csv 'C:\Users\Administrateur\Desktop\Mysoftware.csv' -nti}"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM