Skip to content

Commit

Permalink
Merge pull request #775 from ministryofjustice/onr/DSOS-2724/2012-jum…
Browse files Browse the repository at this point in the history
…pserver-prerequisites

add component to upgrade 2012 r2 base image to Powershell 5.1
  • Loading branch information
robertsweetman authored May 15, 2024
2 parents 03187a0 + a84032e commit ebb4337
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
5 changes: 5 additions & 0 deletions commonimages/base/windows_2012_r2/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ locals {
name = "git_windows"
version = "0.0.2"
parameters = []
},
{
name = "powershell_5_1"
version = "0.0.5"
parameters = []
}
]

Expand Down
2 changes: 1 addition & 1 deletion commonimages/base/windows_2012_r2/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

region = "eu-west-2"
ami_base_name = "windows_server_2012_r2"
configuration_version = "0.2.2"
configuration_version = "0.2.7"
release_or_patch = "release" # or "patch", see nomis AMI image building strategy doc
description = "Windows Server 2012 R2"

Expand Down
30 changes: 30 additions & 0 deletions commonimages/components/templates/powershell_5_1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: powershell_5_1
description: Component to install Windows Management Framework 5.1 on Windows Server 2012. This includes PowerShell 5.1 and will supercede Powershell 4.0 so we can use more modern commandlets.
schemaVersion: 1.0
parameters:
- Version:
type: string
default: 0.0.5
description: Component version (update this each time the file changes)
- Platform:
type: string
default: "Windows"
description: Platform.
phases:
- name: build
steps:
- name: InstallPowerShell_5_1
action: ExecutePowerShell
inputs:
commands:
- |
$PSMajorVersion = $PSVersionTable.PSVersion.Major
if ( $PSMajorVersion -le 4 ) {
Write-Host "Installing PowerShell 5.1"
choco install -y powershell
exit 3010
} else {
Write-Host "PowerShell $PSMajorVersion is installed"
exit 0
}

0 comments on commit ebb4337

Please sign in to comment.