How do I get the script version in code please?

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE 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.
User avatar
grathal
Posts: 98
Joined: Fri Dec 27, 2013 5:28 pm

How do I get the script version in code please?

Post by grathal » Tue Mar 11, 2014 9:12 am

Hello,

Is there a way please to get the version of my script in my code? I'm trying to put a small "v1.0" in the corner of a form.

Does PS 2012 also do auto-incrementing of the version?

I saw the %AppVersion% variable can be used in templates but I don't think that's the same.

Thx.

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Re: How do I get the script version in code please?

Post by davidc » Tue Mar 11, 2014 11:40 am

There are two way of doing this depending on what you do with the script:

1. If you package the script into an EXE you can use the following:

[System.Windows.Forms.Application]::ProductVersion

This will pull the version number from the running executable if you are using a GUI Form.

2. If you are not using a package exe, you can use a variable to store your version number (which you define in the script) and display it.

David
David
SAPIEN Technologies, Inc.