Search code examples
powershellversionfileinfo

How to SET fileinfo version to a PS1 file with Powershell


I have a PowerShell script named myscript.ps1 on a remote server.

I would like to know what is the version of this file. Unfortunately this command gives me nothing : (Get-Item "C:\myscript.ps1").VersionInfo.FileVersion

My question is : is there a way to add some information regarding the version of the script or else ? If yes, how please ?

My end goal is to check if the running script is the latest version otherwise download latest version on remote server and execute.

Thank you all.


Solution

  • I'm not sure you're going to find that information there unless it was set. I usually see that info in things like DLLs.

    If it were me, and I was looking to see if a file was different (a script or otherwise) I would use the Get-FileHash commandlet instead.