1

I'm trying to run this powershell 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

in a batch file. This is what i got now :

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';}"

but it's telling me ">" is not a command

What i'm trying to do is get the list of all the software of a computer in the MySoftware.txt file.

Thanks for the help

3
  • backtick? Write-Output? btw, why batch but not a posh script? Commented May 10, 2016 at 19:27
  • 1
    You added a ; before the > that is not in the posh command that you show. Commented May 10, 2016 at 19:38
  • Also, this will only show you the 32 bit apps that are installed. Commented May 10, 2016 at 19:40

2 Answers 2

1

Remove the ";" before redirecting to a file through ">" and use "|" to pass the output of a command to the input of the next command instead of putting ";" in the end of each command.

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' }"
Sign up to request clarification or add additional context in comments.

Comments

0

can you try this line instead?

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}"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.