title: Checking for a powershell version
body: <p>Hi I currently have a very basic PowerShell script that runs when a computer is installed with Windows (any version). This script is below</p>
  <pre><code>Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted -Force
  [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
  
  Write-Output &quot;Installing OS Updater Modules Please Wait....&quot;
  Write-Output &quot; &quot;
  Install-PackageProvider -Name NuGet -Force
  Install-Module -Name PSWindowsUpdate -Force
  Write-Output &quot; &quot;
  Write-Output &quot;Installing Updates....&quot;
  Write-Output &quot; &quot;
  Install-WindowsUpdate -AcceptAll -Install -IgnoreReboot | Out-File &quot;c:\temp\WindowsUpdate.log&quot; -force
  </code></pre>
  <p>As I said very simple code this will install a few modules then update windows with any updates, however, it only works with PowerShell 5 and above is there a way I can check what version is installed then carry on with the script if it is PowerShell 4 and below stop executing the script.</p>
  <p>I know it's possible to install Windows Management Framework 5.1 into the install.wim/esd which will get around this but for people who don't have this, I would like the script to stop and not have any errors.</p>