PowerShell-Toolbox icon indicating copy to clipboard operation
PowerShell-Toolbox copied to clipboard

Get info about MSI file - Write version in an environment variable

Open bovirus opened this issue 1 year ago • 3 comments

@bastienperez

Thanks for your scripts.

Could be possible to create a .ps1 script thet get version info by .msi file and save the version numebr info in a variable to use this info in a batch file?

Thanks.

bovirus avatar Dec 06 '24 08:12 bovirus

Hello,

You can use: $version = (Get-MSIFileInformation -FilePath "pathToYourMSI.msi").ProductVersion

Or did I misunderstand your request?

bastienperez avatar Dec 06 '24 09:12 bastienperez

@bastienperez

I'd like to run a dos bacyh like

powershell -c "powershellcommands"

and get the MSI version as DOS variable or as text file.

The scope is use in a bach file to analyze the msi file, get version, and set the file name using version.

bovirus avatar Dec 06 '24 09:12 bovirus

You can use powershell -Command "& { . path\To\Get-MSIFileInformation.ps1; (Get-MsiFileInformation -FilePath 'pathToYourMSI.msi').ProductVersion }"

This command will load and run the function within the brackets {}.

bastienperez avatar Dec 06 '24 10:12 bastienperez