2016-10-18 03:06:32 +02:00
|
|
|
# escape=`
|
|
|
|
FROM microsoft/windowsservercore
|
|
|
|
MAINTAINER brycem@microsoft.com
|
|
|
|
LABEL Readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md"
|
2016-11-08 23:41:58 +01:00
|
|
|
LABEL Description="This Dockerfile will install the latest release of PS."
|
2016-10-18 03:06:32 +02:00
|
|
|
|
2016-11-08 00:01:31 +01:00
|
|
|
ARG POWERSHELL_MSI=https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.12/PowerShell_6.0.0.12-alpha.12-win10-x64.msi
|
|
|
|
ARG POWERSHELL_SHA256=F3C3F3276462588E24BFE197DAA8795140E37557596861126D54462561C98671
|
2016-10-18 03:06:32 +02:00
|
|
|
|
2016-10-20 02:14:56 +02:00
|
|
|
# Setup PowerShell - Log-to > C:\Docker.log
|
2016-10-18 03:06:32 +02:00
|
|
|
SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"]
|
|
|
|
ADD $POWERSHELL_MSI /PowerShell-win10-x64.msi
|
|
|
|
ENV POWERSHELL_SHA256=$POWERSHELL_SHA256
|
|
|
|
|
|
|
|
# Install PowerShell package and clean up
|
2016-10-20 02:14:56 +02:00
|
|
|
RUN $ErrorActionPreference='Stop'; `
|
|
|
|
$ConfirmPreference='None'; `
|
|
|
|
$VerbosePreference='Continue'; `
|
|
|
|
Start-Transcript -path C:\Dockerfile.log -append -IncludeInvocationHeader ; `
|
|
|
|
$PSVersionTable | Write-Output ; `
|
|
|
|
$VerInfo = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' ; `
|
|
|
|
('FullBuildString: '+$VerInfo.BuildLabEx) | Write-Output ; `
|
|
|
|
('OperatingSystem: '+$VerInfo.ProductName+' '+$VerInfo.EditionId+' '+$VerInfo.InstallationType) | Write-Output ; `
|
|
|
|
[System.IO.FileInfo]$MsiFile = Get-Item -Path ./PowerShell-win10-x64.msi ; `
|
2016-10-18 03:06:32 +02:00
|
|
|
[String]$MsiHash=(Get-FileHash -Path $MSiFile -Algorithm SHA256 | select -ExpandProperty Hash) ; `
|
|
|
|
If ($MsiHash -notmatch $Env:POWERSHELL_SHA256) { `
|
|
|
|
Throw [String]$('['+$MsiHash+'] does not match ['+$Env:POWERSHELL_SHA256+']!') `
|
|
|
|
} ; `
|
|
|
|
Start-Process -FilePath msiexec.exe -ArgumentList '-qn','-i c:\PowerShell-win10-x64.msi', `
|
|
|
|
'-log c:\PowerShell-win10-x64.msi.log','-norestart' -wait ; `
|
|
|
|
$log=get-content -Path C:\PowerShell-win10-x64.msi.log -Last 10 ; `
|
|
|
|
if ($log -match 'Installation success or error status: 0') { `
|
2016-10-20 02:14:56 +02:00
|
|
|
Remove-Item -Path $MsiFile ; `
|
2016-10-18 03:06:32 +02:00
|
|
|
$psexe=Get-Item -Path $Env:ProgramFiles\PowerShell\*\powershell.exe ; `
|
|
|
|
New-Item -Type SymbolicLink -Path $Env:ProgramFiles\PowerShell\ -Name Core -Value $psexe.DirectoryName `
|
|
|
|
} else { throw 'Installation failed! See c:\PowerShell-win10-x64.msi.log' } ;
|
|
|
|
|
2016-10-20 02:14:56 +02:00
|
|
|
# Verify New Powershell.exe runs
|
|
|
|
SHELL ["C:\\Program Files\\PowerShell\\Core\\PowerShell.exe", "-command"]
|
|
|
|
RUN Start-Transcript -path C:\Dockerfile.log -append -IncludeInvocationHeader ; `
|
|
|
|
$ErrorActionPreference='Stop'; `
|
|
|
|
Write-Output $PSVersionTable ; `
|
|
|
|
If (-not($PSVersionTable.PSEdition -Match 'Core')) { `
|
|
|
|
Throw [String]$('['+$PSVersionTable.PSEdition+'] is not [Core]!') ; `
|
2016-10-18 03:06:32 +02:00
|
|
|
} ;
|
2016-10-20 02:14:56 +02:00
|
|
|
|
|
|
|
# Persist %PSCORE% ENV variable for user convenience
|
|
|
|
ENV PSCORE='"C:\Program Files\PowerShell\Core\PowerShell.exe"'
|