From 7f25751667d9a089d988785f7a9cc5a5ccba6033 Mon Sep 17 00:00:00 2001 From: James Nord Date: Thu, 25 Jun 2020 11:41:02 +0100 Subject: [PATCH] the /EXPIRE (sic) flag on `net user` sets the account not to expire not the password of the account. this means that the image is DOA after the default password expiration duration. Add a call to wmic to set the password to never expire --- 11/nanoserver-1809/Dockerfile | 3 ++- 11/windowsservercore-1809/Dockerfile | 3 ++- 8/nanoserver-1809/Dockerfile | 3 ++- 8/windowsservercore-1809/Dockerfile | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/11/nanoserver-1809/Dockerfile b/11/nanoserver-1809/Dockerfile index 66441e3e..0a19af1a 100644 --- a/11/nanoserver-1809/Dockerfile +++ b/11/nanoserver-1809/Dockerfile @@ -33,7 +33,8 @@ RUN $output = net users ; ` if(-not ($output -match $env:user)) { ` Write-Host 'user does not exist?' ; ` net user $env:user /add /expire:never /passwordreq:no ; ` - net localgroup Administrators /add $env:user ` + net localgroup Administrators /add $env:user ; ` + wmic useraccount WHERE Name=$env:user set PasswordExpires=false; ` } COPY jenkins-agent.ps1 C:/ProgramData/Jenkins diff --git a/11/windowsservercore-1809/Dockerfile b/11/windowsservercore-1809/Dockerfile index 32e1926e..b18585fd 100644 --- a/11/windowsservercore-1809/Dockerfile +++ b/11/windowsservercore-1809/Dockerfile @@ -32,7 +32,8 @@ RUN $output = net users ; ` if(-not ($output -match $env:user)) { ` Write-Host 'user does not exist?' ; ` net user $env:user /add /expire:never /passwordreq:no ; ` - net localgroup Administrators /add $env:user ` + net localgroup Administrators /add $env:user ; ` + wmic useraccount WHERE Name=$env:user set PasswordExpires=false; ` } COPY jenkins-agent.ps1 C:/ProgramData/Jenkins diff --git a/8/nanoserver-1809/Dockerfile b/8/nanoserver-1809/Dockerfile index 854b3a9b..008d6bd3 100644 --- a/8/nanoserver-1809/Dockerfile +++ b/8/nanoserver-1809/Dockerfile @@ -32,7 +32,8 @@ RUN $output = net users ; ` if(-not ($output -match $env:user)) { ` Write-Host 'user does not exist?' ; ` net user $env:user /add /expire:never /passwordreq:no ; ` - net localgroup Administrators /add $env:user ` + net localgroup Administrators /add $env:user ; ` + wmic useraccount WHERE Name=$env:user set PasswordExpires=false; ` } COPY jenkins-agent.ps1 C:/ProgramData/Jenkins diff --git a/8/windowsservercore-1809/Dockerfile b/8/windowsservercore-1809/Dockerfile index e8af6379..7c38dabe 100644 --- a/8/windowsservercore-1809/Dockerfile +++ b/8/windowsservercore-1809/Dockerfile @@ -32,7 +32,8 @@ RUN $output = net users ; ` if(-not ($output -match $env:user)) { ` Write-Host 'user does not exist?' ; ` net user $env:user /add /expire:never /passwordreq:no ; ` - net localgroup Administrators /add $env:user ` + net localgroup Administrators /add $env:user ; ` + wmic useraccount WHERE Name=$env:user set PasswordExpires=false; ` } COPY jenkins-agent.ps1 C:/ProgramData/Jenkins