Hi all
I need to be able to retrieve the version of the compiled .exe running my script, but I'm having trouble with figureing out how to do it. With regular .Net I would use Assembly.GetExecutingAssembly(), but I'm not quite sure on how to something similar with PowerShell.
Any hints on this one please?
Retrieve product version at runtime
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- Alexander Riedel
- Posts: 8478
- Last visit: Tue Mar 26, 2024 8:52 am
- Been upvoted: 37 times
Re: Retrieve product version at runtime
- if ($null -ne $hostinvocation)
- {
- $HostFile = $hostinvocation.MyCommand.path
- (Get-Command $HostFile).FileVersionInfo.FileVersion
- }
Product Field File Field Meaning Example ---------------------------------------------------------------------------------------- ProductVersion FileVersion String version 3.1.0.2 (alpha) ProductMajorPart FileMajorPart First number 3 ProductMinorPart FileMinorPart Second number 1 ProductBuildPart FileBuildPart Third number 0 ProductPrivatePart FilePrivatePart Fourth number 2
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.