I have both PowerShell 5.1 and PowerShell 7.0 on my computer. How can I enforce a mandatory version (a specific version, not a minimum or maximum version #) of PowerShell for a given script (in this case, PowerShell 7.0)?
another option is to use #Requires statement
#Requires -Version 7.0
here is the reference from Microsoft support
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_requires
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With