簡體   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