GithubHelp home page GithubHelp logo

rgl / packer-plugin-windows-update Goto Github PK

View Code? Open in Web Editor NEW
292.0 26.0 71.0 234 KB

Packer plugin for installing Windows updates

License: Mozilla Public License 2.0

Makefile 6.96% Go 38.88% PowerShell 46.48% Shell 1.57% HCL 6.11%
packer windows windows-updates

packer-plugin-windows-update's Introduction

Packer Windows Update Provisioner

Build status

This is a Packer plugin for installing Windows updates (akin to rgl/vagrant-windows-update).

NB This was only tested with Packer 1.10.0 and the images at rgl/windows-vagrant, so YMMV.

Usage

Configure your packer template to require a release version of the plugin, e.g.:

packer {
  required_plugins {
    windows-update = {
      version = "0.15.0"
      source = "github.com/rgl/windows-update"
    }
  }
}

Initialize your packer template (it will install the plugin):

packer init your-template.pkr.hcl

Use this provisioner plugin from your packer template file, e.g. like in rgl/windows-vagrant:

build {
  provisioner "windows-update" {
  }
}

Note, the plugin automatically restarts the machine after Windows Updates are applied. The reboots occur similar to the windows-restart provisioner built into packer where packer is aware that a shutdown is in progress.

Search Criteria, Filters and Update Limit

You can select which Windows Updates are installed by defining the search criteria, a set of filters, and how many updates are installed at a time.

Normally you would use one of the following settings:

Name search_criteria filters
Important AutoSelectOnWebSites=1 and IsInstalled=0 $true
Recommended BrowseOnly=0 and IsInstalled=0 $true
All IsInstalled=0 $true
Optional Only AutoSelectOnWebSites=0 and IsInstalled=0 $_.BrowseOnly

NB Recommended is the default setting.

But you can customize them, e.g.:

build {
  provisioner "windows-update" {
    search_criteria = "IsInstalled=0"
    filters = [
      "exclude:$_.Title -like '*Preview*'",
      "include:$true",
    ]
    update_limit = 25
  }
}

NB For more information about the search criteria see the IUpdateSearcher::Search method documentation and the xWindowsUpdateAgent DSC resource source.

NB If the update_limit attribute is not declared, it defaults to 1000.

The general filter syntax is:

ACTION:EXPRESSION

ACTION is a string that can have one of the following values:

action description
include includes the update when the expression evaluates to $true
exclude excludes the update when the expression evaluates to $true

NB If no ACTION evaluates to $true the update will NOT be installed.

EXPRESSION is a PowerShell expression. When it returns $true, the ACTION is executed and no further filters are evaluated.

Inside an expression, the Windows Update IUpdate interface can be referenced by the $_ variable.

Development

Build:

make

Install the plugin into $HOME/.packer.d/plugins with:

make install

And comment the required_plugin block in your packer template file.

If you are having problems running packer set the PACKER_LOG=1 environment variable to see more information.

Test (QEMU)

You can test the plugin with a previously installed rgl/windows-vagrant image with:

make test

packer-plugin-windows-update's People

Contributors

aaronk1 avatar agowa avatar bengardiner avatar bishopbm1 avatar feiyushi avatar george-richardson avatar jetersen avatar jpereira avatar matt-richardson avatar mdonoughe avatar pfurtschellerp avatar pvandervelde avatar rgl avatar romlecat avatar stuartp44 avatar swampdragons avatar tvories avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

packer-plugin-windows-update's Issues

provisioner type not found: windows-update

Hi,

When I run packer I have error as below

packer build -only=windows-2016-amd64-virtualbox windows-2016.json
Failed to initialize build 'windows-2016-amd64-virtualbox': provisioner type not found: windows-update
windows-2016-amd64-virtualbox output will be in this color.

System Windows 10 Enterprise, 1607
Packages installed using choco. I even check with packer 1.2.2, still it doesn't work

Plugin Fails with Error: `unexpected EOF`.

We have an automated process which runs our packer templates multiple times per week. We have consistently received the following error only in the Australia East region:

unexpected EOF
Full logs: 2019-05-03T11:56:42.8365945Z ##[debug]**************************************/ 2019-05-03T11:56:42.8366311Z ##[debug]Match start index: -1 2019-05-03T11:56:42.8366671Z ##[debug]Match start index: -1 2019-05-03T11:56:42.8379167Z ==> mo-prod-australia east-1556883083-win2019: Uploading the Windows update elevated script... 2019-05-03T11:56:42.8379460Z 2019-05-03T11:56:42.8379871Z ##[debug]Parsing log line to extract output... 2019-05-03T11:56:42.8380407Z ##[debug]/************************************* 2019-05-03T11:56:42.8380927Z ##[debug]==> mo-prod-australia east-1556883083-win2019: Uploading the Windows update elevated script...

2019-05-03T11:56:42.8381369Z ##[debug]**************************************/
2019-05-03T11:56:42.8381724Z ##[debug]Match start index: -1
2019-05-03T11:56:42.8382193Z ##[debug]Match start index: -1
2019-05-03T11:56:48.0633961Z ==> mo-prod-australia east-1556883083-win2019: Uploading the Windows update check for reboot required elevated script...
2019-05-03T11:56:48.0634634Z
2019-05-03T11:56:48.0635512Z ##[debug]Parsing log line to extract output...
2019-05-03T11:56:48.0636042Z ##[debug]/*************************************
2019-05-03T11:56:48.0636560Z ##[debug]==> mo-prod-australia east-1556883083-win2019: Uploading the Windows update check for reboot required elevated script...

2019-05-03T11:56:48.0637050Z ##[debug]**************************************/
2019-05-03T11:56:48.0637448Z ##[debug]Match start index: -1
2019-05-03T11:56:48.0637814Z ##[debug]Match start index: -1
2019-05-03T11:56:53.1754529Z ==> mo-prod-australia east-1556883083-win2019: Uploading the Windows update script...
2019-05-03T11:56:53.1754853Z
2019-05-03T11:56:53.1755398Z ##[debug]Parsing log line to extract output...
2019-05-03T11:56:53.1755834Z ##[debug]/*************************************
2019-05-03T11:56:53.1756291Z ##[debug]==> mo-prod-australia east-1556883083-win2019: Uploading the Windows update script...

2019-05-03T11:56:53.1756871Z ##[debug]**************************************/
2019-05-03T11:56:53.1757286Z ##[debug]Match start index: -1
2019-05-03T11:56:53.1757707Z ##[debug]Match start index: -1
2019-05-03T11:56:58.8793518Z ==> mo-prod-australia east-1556883083-win2019: Running Windows update...
2019-05-03T11:56:58.8793829Z
2019-05-03T11:56:58.8794450Z ##[debug]Parsing log line to extract output...
2019-05-03T11:56:58.8794886Z ##[debug]/*************************************
2019-05-03T11:56:58.8795330Z ##[debug]==> mo-prod-australia east-1556883083-win2019: Running Windows update...

2019-05-03T11:56:58.8795783Z ##[debug]**************************************/
2019-05-03T11:56:58.8796160Z ##[debug]Match start index: -1
2019-05-03T11:56:58.8796525Z ##[debug]Match start index: -1
2019-05-03T11:57:01.9346862Z mo-prod-australia east-1556883083-win2019: Searching for Windows updates...
2019-05-03T11:57:01.9347227Z
2019-05-03T11:57:01.9347777Z ##[debug]Parsing log line to extract output...
2019-05-03T11:57:01.9348180Z ##[debug]/*************************************
2019-05-03T11:57:01.9348778Z ##[debug] mo-prod-australia east-1556883083-win2019: Searching for Windows updates...

2019-05-03T11:57:01.9349227Z ##[debug]**************************************/
2019-05-03T11:57:01.9349740Z ##[debug]Match start index: -1
2019-05-03T11:57:01.9350190Z ##[debug]Match start index: -1
2019-05-03T11:57:05.9334108Z mo-prod-australia east-1556883083-win2019: Found Windows update (2018-10-15; 20.72 MB): Update for Adobe Flash Player for Windows Server 2019 (1809) for x64-based Systems (KB4462930)
2019-05-03T11:57:05.9334600Z
2019-05-03T11:57:05.9335212Z ##[debug]Parsing log line to extract output...
2019-05-03T11:57:05.9335627Z ##[debug]/*************************************
2019-05-03T11:57:05.9336207Z ##[debug] mo-prod-australia east-1556883083-win2019: Found Windows update (2018-10-15; 20.72 MB): Update for Adobe Flash Player for Windows Server 2019 (1809) for x64-based Systems (KB4462930)

2019-05-03T11:57:05.9337116Z ##[debug]**************************************/
2019-05-03T11:57:05.9337539Z ##[debug]Match start index: -1
2019-05-03T11:57:05.9337903Z ##[debug]Match start index: -1
2019-05-03T11:57:05.9338437Z mo-prod-australia east-1556883083-win2019: Found Windows update (2019-03-01; 64.24 MB): 2019-02 Cumulative Update for .NET Framework 3.5 and 4.7.2 for Windows Server 2019 for x64 (KB4486553)
2019-05-03T11:57:05.9338830Z
2019-05-03T11:57:05.9339203Z ##[debug]Parsing log line to extract output...
2019-05-03T11:57:05.9339615Z ##[debug]/*************************************
2019-05-03T11:57:05.9340170Z ##[debug] mo-prod-australia east-1556883083-win2019: Found Windows update (2019-03-01; 64.24 MB): 2019-02 Cumulative Update for .NET Framework 3.5 and 4.7.2 for Windows Server 2019 for x64 (KB4486553)

2019-05-03T11:57:05.9340735Z ##[debug]**************************************/
2019-05-03T11:57:05.9341135Z ##[debug]Match start index: -1
2019-05-03T11:57:05.9341928Z ##[debug]Match start index: -1
2019-05-03T11:57:05.9342371Z mo-prod-australia east-1556883083-win2019: Found Windows update (2019-04-09; 42.38 MB): Windows Malicious Software Removal Tool x64 - April 2019 (KB890830)
2019-05-03T11:57:05.9342648Z
2019-05-03T11:57:05.9342994Z ##[debug]Parsing log line to extract output...
2019-05-03T11:57:05.9343798Z ##[debug]/*************************************
2019-05-03T11:57:05.9344331Z ##[debug] mo-prod-australia east-1556883083-win2019: Found Windows update (2019-04-09; 42.38 MB): Windows Malicious Software Removal Tool x64 - April 2019 (KB890830)

2019-05-03T11:57:05.9344860Z ##[debug]**************************************/
2019-05-03T11:57:05.9345232Z ##[debug]Match start index: -1
2019-05-03T11:57:05.9345593Z ##[debug]Match start index: -1
2019-05-03T11:57:05.9348502Z mo-prod-australia east-1556883083-win2019: Found Windows update (2019-04-09; 20.73 MB): 2019-04 Security Update for Adobe Flash Player for Windows Server 2019 for x64-based Systems (KB4493478)
2019-05-03T11:57:05.9348884Z
2019-05-03T11:57:05.9349400Z ##[debug]Parsing log line to extract output...
2019-05-03T11:57:05.9349942Z ##[debug]/*************************************
2019-05-03T11:57:05.9350483Z ##[debug] mo-prod-australia east-1556883083-win2019: Found Windows update (2019-04-09; 20.73 MB): 2019-04 Security Update for Adobe Flash Player for Windows Server 2019 for x64-based Systems (KB4493478)

2019-05-03T11:57:05.9351032Z ##[debug]**************************************/
2019-05-03T11:57:05.9351394Z ##[debug]Match start index: -1
2019-05-03T11:57:05.9351742Z ##[debug]Match start index: -1
2019-05-03T11:57:05.9352204Z mo-prod-australia east-1556883083-win2019: Found Windows update (2019-05-03; 185.16 MB): Definition Update for Windows Defender Antivirus - KB2267602 (Definition 1.293.758.0)
2019-05-03T11:57:05.9352572Z
2019-05-03T11:57:05.9352943Z ##[debug]Parsing log line to extract output...
2019-05-03T11:57:05.9354048Z ##[debug]/*************************************
2019-05-03T11:57:05.9354626Z ##[debug] mo-prod-australia east-1556883083-win2019: Found Windows update (2019-05-03; 185.16 MB): Definition Update for Windows Defender Antivirus - KB2267602 (Definition 1.293.758.0)

2019-05-03T11:57:05.9355194Z ##[debug]**************************************/
2019-05-03T11:57:05.9355568Z ##[debug]Match start index: -1
2019-05-03T11:57:05.9355927Z ##[debug]Match start index: -1
2019-05-03T11:57:05.9360282Z mo-prod-australia east-1556883083-win2019: Found Windows update (2019-04-09; 14486.29 MB): 2019-04 Cumulative Update for Windows Server 2019 (1809) for x64-based Systems (KB4493509)
2019-05-03T11:57:05.9360627Z
2019-05-03T11:57:05.9361049Z ##[debug]Parsing log line to extract output...
2019-05-03T11:57:05.9361467Z ##[debug]/*************************************
2019-05-03T11:57:05.9362336Z ##[debug] mo-prod-australia east-1556883083-win2019: Found Windows update (2019-04-09; 14486.29 MB): 2019-04 Cumulative Update for Windows Server 2019 (1809) for x64-based Systems (KB4493509)

2019-05-03T11:57:05.9363212Z ##[debug]**************************************/
2019-05-03T11:57:05.9363969Z ##[debug]Match start index: -1
2019-05-03T11:57:05.9364333Z ##[debug]Match start index: -1
2019-05-03T11:57:05.9364724Z mo-prod-australia east-1556883083-win2019: Downloading Windows updates (3 updates; 14735.69 MB)...
2019-05-03T11:57:05.9364950Z
2019-05-03T11:57:05.9365297Z ##[debug]Parsing log line to extract output...
2019-05-03T11:57:05.9365708Z ##[debug]/*************************************
2019-05-03T11:57:05.9366174Z ##[debug] mo-prod-australia east-1556883083-win2019: Downloading Windows updates (3 updates; 14735.69 MB)...

2019-05-03T11:57:05.9366767Z ##[debug]**************************************/
2019-05-03T11:57:05.9367364Z ##[debug]Match start index: -1
2019-05-03T11:57:05.9368526Z ##[debug]Match start index: -1
2019-05-03T11:57:19.7353351Z mo-prod-australia east-1556883083-win2019: Installing Windows updates...
2019-05-03T11:57:19.7353942Z
2019-05-03T11:57:19.7354484Z ##[debug]Parsing log line to extract output...
2019-05-03T11:57:19.7354914Z ##[debug]/*************************************
2019-05-03T11:57:19.7355359Z ##[debug] mo-prod-australia east-1556883083-win2019: Installing Windows updates...

2019-05-03T11:57:19.7355799Z ##[debug]**************************************/
2019-05-03T11:57:19.7356186Z ##[debug]Match start index: -1
2019-05-03T11:57:19.7356673Z ##[debug]Match start index: -1
2019-05-03T12:01:14.7118082Z mo-prod-australia east-1556883083-win2019: Waiting for the Windows Modules Installer to exit...
2019-05-03T12:01:14.7118654Z
2019-05-03T12:01:14.7119582Z ##[debug]Parsing log line to extract output...
2019-05-03T12:01:14.7120131Z ##[debug]/*************************************
2019-05-03T12:01:14.7120702Z ##[debug] mo-prod-australia east-1556883083-win2019: Waiting for the Windows Modules Installer to exit...

2019-05-03T12:01:14.7121250Z ##[debug]**************************************/
2019-05-03T12:01:14.7121763Z ##[debug]Match start index: -1
2019-05-03T12:01:14.7122219Z ##[debug]Match start index: -1
2019-05-03T12:03:20.3245693Z ==> mo-prod-australia east-1556883083-win2019: Waiting for machine to restart...
2019-05-03T12:03:20.3246093Z
2019-05-03T12:03:20.3247052Z ##[debug]Parsing log line to extract output...
2019-05-03T12:03:20.3247556Z ##[debug]/*************************************
2019-05-03T12:03:20.3248293Z ##[debug]==> mo-prod-australia east-1556883083-win2019: Waiting for machine to restart...

2019-05-03T12:03:20.3248848Z ##[debug]**************************************/
2019-05-03T12:03:20.3249426Z ##[debug]Match start index: -1
2019-05-03T12:03:20.3249807Z ##[debug]Match start index: -1
2019-05-03T12:03:25.6095111Z Build 'mo-prod-australia east-1556883083-win2019' errored: unexpected EOF
2019-05-03T12:03:25.6097880Z
2019-05-03T12:03:25.6098564Z ##[debug]Parsing log line to extract output...
2019-05-03T12:03:25.6100019Z ##[debug]/*************************************
2019-05-03T12:03:25.6100678Z ##[debug]Build 'mo-prod-australia east-1556883083-win2019' errored: unexpected EOF

2019-05-03T12:03:25.6101284Z ##[debug]**************************************/
2019-05-03T12:03:25.6101773Z ##[debug]Match start index: -1
2019-05-03T12:03:25.6102201Z ##[debug]Match start index: -1
2019-05-03T12:03:25.6102362Z
2019-05-03T12:03:25.6102505Z
2019-05-03T12:03:25.6102854Z ##[debug]Parsing log line to extract output...
2019-05-03T12:03:25.6103262Z ##[debug]/*************************************
2019-05-03T12:03:25.6103673Z ##[debug]

2019-05-03T12:03:25.6104096Z ##[debug]**************************************/
2019-05-03T12:03:25.6104483Z ##[debug]Match start index: -1
2019-05-03T12:03:25.6104840Z ##[debug]Match start index: -1
2019-05-03T12:03:25.6105139Z ==> Some builds didn't complete successfully and had errors:
2019-05-03T12:03:25.6105307Z
2019-05-03T12:03:25.6105665Z ##[debug]Parsing log line to extract output...
2019-05-03T12:03:25.6106219Z ##[debug]/*************************************
2019-05-03T12:03:25.6107187Z ##[debug]==> Some builds didn't complete successfully and had errors:

2019-05-03T12:03:25.6107735Z ##[debug]**************************************/
2019-05-03T12:03:25.6108144Z ##[debug]Match start index: -1
2019-05-03T12:03:25.6108523Z ##[debug]Match start index: -1
2019-05-03T12:03:25.6108811Z --> mo-prod-australia east-1556883083-win2019: unexpected EOF
2019-05-03T12:03:25.6108996Z
2019-05-03T12:03:25.6109299Z ==> Builds finished but no artifacts were created.
2019-05-03T12:03:25.6109504Z
2019-05-03T12:03:25.6109868Z ##[debug]Parsing log line to extract output...
2019-05-03T12:03:25.6110495Z ##[debug]/*************************************
2019-05-03T12:03:25.6111020Z ##[debug]--> mo-prod-australia east-1556883083-win2019: unexpected EOF

==> Builds finished but no artifacts were created.

2019-05-03T12:03:25.6111558Z ##[debug]**************************************/
2019-05-03T12:03:25.6112245Z ##[debug]Match start index: -1
2019-05-03T12:03:25.6112608Z ##[debug]Match start index: -1
2019-05-03T12:03:25.6978796Z panic: runtime error: invalid memory address or nil pointer dereference
2019-05-03T12:03:25.6979360Z 2019/05/03 12:03:25 packer.exe: [signal 0xc0000005 code=0x0 addr=0x10 pc=0x6718bd]
2019-05-03T12:03:25.6979681Z 2019/05/03 12:03:25 packer.exe:
2019-05-03T12:03:25.6979961Z 2019/05/03 12:03:25 packer.exe: goroutine 2437 [running]:
2019-05-03T12:03:25.6980327Z 2019/05/03 12:03:25 packer.exe: net/http.redirectBehavior(0x262156d, 0x4, 0x0, 0xc000180800, 0x0, 0x0, 0x0)
2019-05-03T12:03:25.6980743Z 2019/05/03 12:03:25 packer.exe: /usr/local/Cellar/go/1.11.1/libexec/src/net/http/client.go:422 +0x2d
2019-05-03T12:03:25.6981123Z 2019/05/03 12:03:25 packer.exe: net/http.(Client).do(0xc000171cb0, 0xc000180800, 0x0, 0x0, 0x0)
2019-05-03T12:03:25.6981544Z 2019/05/03 12:03:25 packer.exe: /usr/local/Cellar/go/1.11.1/libexec/src/net/http/client.go:655 +0x327
2019-05-03T12:03:25.6981959Z 2019/05/03 12:03:25 packer.exe: net/http.(Client).Do(0xc000171cb0, 0xc000180800, 0x6, 0xc0002fab60, 0x20)
2019-05-03T12:03:25.6982375Z 2019/05/03 12:03:25 packer.exe: /usr/local/Cellar/go/1.11.1/libexec/src/net/http/client.go:509 +0x3c
2019-05-03T12:03:25.6982856Z 2019/05/03 12:03:25 packer.exe: github.com/hashicorp/packer/vendor/github.com/masterzen/winrm.clientRequest.Post(0x28efee0, 0xc0002d0650, 0xc0004ac800, 0xc0002bf600, 0x0, 0x0, 0x0, 0x0)
2019-05-03T12:03:25.6983356Z 2019/05/03 12:03:25 packer.exe: /Users/azr/go/src/github.com/hashicorp/packer/vendor/github.com/masterzen/winrm/http.go:82 +0x2c9
2019-05-03T12:03:25.6983886Z 2019/05/03 12:03:25 packer.exe: github.com/hashicorp/packer/vendor/github.com/masterzen/winrm.ClientNTLM.Post(0x28efee0, 0xc0002d0650, 0xc0004ac800, 0xc0002bf600, 0xc0002bf600, 0xc0004cf320, 0x263000b, 0xd)
2019-05-03T12:03:25.6984416Z 2019/05/03 12:03:25 packer.exe: /Users/azr/go/src/github.com/hashicorp/packer/vendor/github.com/masterzen/winrm/ntlm.go:22 +0x50
2019-05-03T12:03:25.6984927Z 2019/05/03 12:03:25 packer.exe: github.com/hashicorp/packer/vendor/github.com/masterzen/winrm.(Client).sendRequest(0xc0004ac800, 0xc0002bf600, 0xc0002bf600, 0xc0002bf600, 0x978ed9, 0x56413e0)
2019-05-03T12:03:25.6985452Z 2019/05/03 12:03:25 packer.exe: /Users/azr/go/src/github.com/hashicorp/packer/vendor/github.com/masterzen/winrm/client.go:102 +0x4a
2019-05-03T12:03:25.6986080Z 2019/05/03 12:03:25 packer.exe: github.com/hashicorp/packer/vendor/github.com/masterzen/winrm.(Client).CreateShell(0xc0004ac800, 0x0, 0x0, 0x0)
2019-05-03T12:03:25.6986538Z 2019/05/03 12:03:25 packer.exe: /Users/azr/go/src/github.com/hashicorp/packer/vendor/github.com/masterzen/winrm/client.go:81 +0xa0
2019-05-03T12:03:25.6987109Z 2019/05/03 12:03:25 packer.exe: github.com/hashicorp/packer/communicator/winrm.(Communicator).Start(0xc00046b500, 0xc00016eae0, 0xc0004899a0, 0x28f0420)
2019-05-03T12:03:25.6987574Z 2019/05/03 12:03:25 packer.exe: /Users/azr/go/src/github.com/hashicorp/packer/communicator/winrm/communicator.go:78 +0x3a
2019-05-03T12:03:25.6988034Z 2019/05/03 12:03:25 packer.exe: github.com/hashicorp/packer/packer/rpc.(CommunicatorServer).Start(0xc0002beea0, 0xc00017de00, 0xc0002d00d0, 0x0, 0x0)
2019-05-03T12:03:25.6988666Z 2019/05/03 12:03:25 packer.exe: /Users/azr/go/src/github.com/hashicorp/packer/packer/rpc/communicator.go:263 +0x1f9
2019-05-03T12:03:25.6989139Z 2019/05/03 12:03:25 packer.exe: reflect.Value.call(0xc000728ea0, 0xc000482498, 0x13, 0x26213d5, 0x4, 0xc000439f18, 0x3, 0x3, 0xc0006bb080, 0x200010001, ...)
2019-05-03T12:03:25.6989571Z 2019/05/03 12:03:25 packer.exe: /usr/local/Cellar/go/1.11.1/libexec/src/reflect/value.go:447 +0x450
2019-05-03T12:03:25.6990112Z 2019/05/03 12:03:25 packer.exe: reflect.Value.Call(0xc000728ea0, 0xc000482498, 0x13, 0xc000439f18, 0x3, 0x3, 0x2, 0x0, 0x0)
2019-05-03T12:03:25.6990514Z 2019/05/03 12:03:25 packer.exe: /usr/local/Cellar/go/1.11.1/libexec/src/reflect/value.go:308 +0xab
2019-05-03T12:03:25.6990961Z 2019/05/03 12:03:25 packer.exe: net/rpc.(service).call(0xc00073f000, 0xc0006f1b30, 0xc0001682d0, 0xc000168300, 0xc000178d00, 0xc00017d8a0, 0x1e57de0, 0xc00017de00, 0x16, 0x1ebc660, ...)
2019-05-03T12:03:25.6992162Z 2019/05/03 12:03:25 packer.exe: /usr/local/Cellar/go/1.11.1/libexec/src/net/rpc/server.go:384 +0x155
2019-05-03T12:03:25.6992518Z 2019/05/03 12:03:25 packer.exe: created by net/rpc.(Server).ServeCodec
2019-05-03T12:03:25.6992889Z 2019/05/03 12:03:25 packer.exe: /usr/local/Cellar/go/1.11.1/libexec/src/net/rpc/server.go:481 +0x485
2019-05-03T12:03:25.6993244Z 2019/05/03 12:03:25 [INFO] 0 bytes written for 'stdout'
2019-05-03T12:03:25.6993535Z 2019/05/03 12:03:25 [INFO] 0 bytes written for 'stderr'
2019-05-03T12:03:25.6993848Z 2019/05/03 12:03:25 [ERR] Error decoding response stream 63: EOF
2019-05-03T12:03:25.6994149Z 2019/05/03 12:03:25 [INFO] (telemetry) ending azure-arm
2019-05-03T12:03:25.6994498Z 2019/05/03 12:03:25 ui error: Build 'mo-prod-australia east-1556883083-win2019' errored: unexpected EOF
2019-05-03T12:03:25.6994859Z 2019/05/03 12:03:25 Builds completed. Waiting on interrupt barrier...
2019-05-03T12:03:25.6995316Z 2019/05/03 12:03:25 [ERR] Error decoding response stream 84: EOF
2019-05-03T12:03:25.6995629Z 2019/05/03 12:03:25 machine readable: error-count []string{"1"}
2019-05-03T12:03:25.6996066Z 2019/05/03 12:03:25 ui error:
2019-05-03T12:03:25.6996362Z ==> Some builds didn't complete successfully and had errors:
2019-05-03T12:03:25.6996718Z 2019/05/03 12:03:25 machine readable: mo-prod-australia east-1556883083-win2019,error []string{"unexpected EOF"}
2019-05-03T12:03:25.6997113Z 2019/05/03 12:03:25 ui error: --> mo-prod-australia east-1556883083-win2019: unexpected EOF
2019-05-03T12:03:25.6997418Z 2019/05/03 12:03:25 ui:
2019-05-03T12:03:25.6997679Z ==> Builds finished but no artifacts were created.
2019-05-03T12:03:25.6997975Z 2019/05/03 12:03:25 [INFO] (telemetry) Finalizing.
2019-05-03T12:03:25.6998320Z 2019/05/03 12:03:25 packer-provisioner-windows-update.exe: 2019/05/03 12:03:25 [INFO] 0 bytes written for 'stdout'
2019-05-03T12:03:25.6998748Z 2019/05/03 12:03:25 packer-provisioner-windows-update.exe: 2019/05/03 12:03:25 [INFO] 0 bytes written for 'stderr'
2019-05-03T12:03:25.6999175Z 2019/05/03 12:03:25 packer-provisioner-windows-update.exe: 2019/05/03 12:03:25 Waiting for machine to reboot with timeout: 4h0m0s
2019-05-03T12:03:25.6999618Z 2019/05/03 12:03:25 packer-provisioner-windows-update.exe: 2019/05/03 12:03:25 Waiting for machine to become available...
2019-05-03T12:03:25.7000167Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7000604Z 2019/05/03 12:03:25 waiting for all plugin processes to complete...
2019-05-03T12:03:25.7001056Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7001535Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7002074Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7003256Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7003646Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7004029Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7004613Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7005001Z 2019/05/03 12:03:25 [INFO] (telemetry) ending windows-update
2019-05-03T12:03:25.7005356Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7005728Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7006114Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7006592Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7006990Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7007377Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7007868Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7008236Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7008591Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7009083Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7009468Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7009856Z 2019/05/03 12:03:25 f:\agent1_work\r294\a\packer-provisioner-windows-update.exe: plugin process exited
2019-05-03T12:03:25.7010257Z 2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019-05-03T12:03:25.7010469Z
2019-05-03T12:03:25.7010762Z
2019-05-03T12:03:25.7011377Z ##[debug]Parsing log line to extract output...
2019-05-03T12:03:25.7011795Z ##[debug]/
*****************************
2019-05-03T12:03:25.7020979Z ##[debug]panic: runtime error: invalid memory address or nil pointer dereference
2019/05/03 12:03:25 packer.exe: [signal 0xc0000005 code=0x0 addr=0x10 pc=0x6718bd]
2019/05/03 12:03:25 packer.exe:
2019/05/03 12:03:25 packer.exe: goroutine 2437 [running]:
2019/05/03 12:03:25 packer.exe: net/http.redirectBehavior(0x262156d, 0x4, 0x0, 0xc000180800, 0x0, 0x0, 0x0)
2019/05/03 12:03:25 packer.exe: /usr/local/Cellar/go/1.11.1/libexec/src/net/http/client.go:422 +0x2d
2019/05/03 12:03:25 packer.exe: net/http.(*Client).do(0xc000171cb0, 0xc000180800, 0x0, 0x0, 0x0)
2019/05/03 12:03:25 packer.exe: /usr/local/Cellar/go/1.11.1/libexec/src/net/http/client.go:655 +0x327
2019/05/03 12:03:25 packer.exe: net/http.(*Client).Do(0xc000171cb0, 0xc000180800, 0x6, 0xc0002fab60, 0x20)
2019/05/03 12:03:25 packer.exe: /usr/local/Cellar/go/1.11.1/libexec/src/net/http/client.go:509 +0x3c
2019/05/03 12:03:25 packer.exe: github.com/hashicorp/packer/vendor/github.com/masterzen/winrm.clientRequest.Post(0x28efee0, 0xc0002d0650, 0xc0004ac800, 0xc0002bf600, 0x0, 0x0, 0x0, 0x0)
2019/05/03 12:03:25 packer.exe: /Users/azr/go/src/github.com/hashicorp/packer/vendor/github.com/masterzen/winrm/http.go:82 +0x2c9
2019/05/03 12:03:25 packer.exe: github.com/hashicorp/packer/vendor/github.com/masterzen/winrm.ClientNTLM.Post(0x28efee0, 0xc0002d0650, 0xc0004ac800, 0xc0002bf600, 0xc0002bf600, 0xc0004cf320, 0x263000b, 0xd)
2019/05/03 12:03:25 packer.exe: /Users/azr/go/src/github.com/hashicorp/packer/vendor/github.com/masterzen/winrm/ntlm.go:22 +0x50
2019/05/03 12:03:25 packer.exe: github.com/hashicorp/packer/vendor/github.com/masterzen/winrm.(*Client).sendRequest(0xc0004ac800, 0xc0002bf600, 0xc0002bf600, 0xc0002bf600, 0x978ed9, 0x56413e0)
2019/05/03 12:03:25 packer.exe: /Users/azr/go/src/github.com/hashicorp/packer/vendor/github.com/masterzen/winrm/client.go:102 +0x4a
2019/05/03 12:03:25 packer.exe: github.com/hashicorp/packer/vendor/github.com/masterzen/winrm.(*Client).CreateShell(0xc0004ac800, 0x0, 0x0, 0x0)
2019/05/03 12:03:25 packer.exe: /Users/azr/go/src/github.com/hashicorp/packer/vendor/github.com/masterzen/winrm/client.go:81 +0xa0
2019/05/03 12:03:25 packer.exe: github.com/hashicorp/packer/communicator/winrm.(*Communicator).Start(0xc00046b500, 0xc00016eae0, 0xc0004899a0, 0x28f0420)
2019/05/03 12:03:25 packer.exe: /Users/azr/go/src/github.com/hashicorp/packer/communicator/winrm/communicator.go:78 +0x3a
2019/05/03 12:03:25 packer.exe: github.com/hashicorp/packer/packer/rpc.(*CommunicatorServer).Start(0xc0002beea0, 0xc00017de00, 0xc0002d00d0, 0x0, 0x0)
2019/05/03 12:03:25 packer.exe: /Users/azr/go/src/github.com/hashicorp/packer/packer/rpc/communicator.go:263 +0x1f9
2019/05/03 12:03:25 packer.exe: reflect.Value.call(0xc000728ea0, 0xc000482498, 0x13, 0x26213d5, 0x4, 0xc000439f18, 0x3, 0x3, 0xc0006bb080, 0x200010001, ...)
2019/05/03 12:03:25 packer.exe: /usr/local/Cellar/go/1.11.1/libexec/src/reflect/value.go:447 +0x450
2019/05/03 12:03:25 packer.exe: reflect.Value.Call(0xc000728ea0, 0xc000482498, 0x13, 0xc000439f18, 0x3, 0x3, 0x2, 0x0, 0x0)
2019/05/03 12:03:25 packer.exe: /usr/local/Cellar/go/1.11.1/libexec/src/reflect/value.go:308 +0xab
2019/05/03 12:03:25 packer.exe: net/rpc.(*service).call(0xc00073f000, 0xc0006f1b30, 0xc0001682d0, 0xc000168300, 0xc000178d00, 0xc00017d8a0, 0x1e57de0, 0xc00017de00, 0x16, 0x1ebc660, ...)
2019/05/03 12:03:25 packer.exe: /usr/local/Cellar/go/1.11.1/libexec/src/net/rpc/server.go:384 +0x155
2019/05/03 12:03:25 packer.exe: created by net/rpc.(*Server).ServeCodec
2019/05/03 12:03:25 packer.exe: /usr/local/Cellar/go/1.11.1/libexec/src/net/rpc/server.go:481 +0x485
2019/05/03 12:03:25 [INFO] 0 bytes written for 'stdout'
2019/05/03 12:03:25 [INFO] 0 bytes written for 'stderr'
2019/05/03 12:03:25 [ERR] Error decoding response stream 63: EOF
2019/05/03 12:03:25 [INFO] (telemetry) ending azure-arm
2019/05/03 12:03:25 ui error: Build 'mo-prod-australia east-1556883083-win2019' errored: unexpected EOF
2019/05/03 12:03:25 Builds completed. Waiting on interrupt barrier...
2019/05/03 12:03:25 [ERR] Error decoding response stream 84: EOF
2019/05/03 12:03:25 machine readable: error-count []string{"1"}
2019/05/03 12:03:25 ui error:
==> Some builds didn't complete successfully and had errors:
2019/05/03 12:03:25 machine readable: mo-prod-australia east-1556883083-win2019,error []string{"unexpected EOF"}
2019/05/03 12:03:25 ui error: --> mo-prod-australia east-1556883083-win2019: unexpected EOF
2019/05/03 12:03:25 ui:
==> Builds finished but no artifacts were created.
2019/05/03 12:03:25 [INFO] (telemetry) Finalizing.
2019/05/03 12:03:25 packer-provisioner-windows-update.exe: 2019/05/03 12:03:25 [INFO] 0 bytes written for 'stdout'
2019/05/03 12:03:25 packer-provisioner-windows-update.exe: 2019/05/03 12:03:25 [INFO] 0 bytes written for 'stderr'
2019/05/03 12:03:25 packer-provisioner-windows-update.exe: 2019/05/03 12:03:25 Waiting for machine to reboot with timeout: 4h0m0s
2019/05/03 12:03:25 packer-provisioner-windows-update.exe: 2019/05/03 12:03:25 Waiting for machine to become available...
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 waiting for all plugin processes to complete...
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 [INFO] (telemetry) ending windows-update
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work\r294\a\packer-provisioner-windows-update.exe: plugin process exited
2019/05/03 12:03:25 f:\agent1_work_temp\1556883079054\packer\packer.exe: plugin process exited

2019-05-03T12:03:25.7030899Z ##[debug]**************************************/
2019-05-03T12:03:25.7031344Z ##[debug]Match start index: -1
2019-05-03T12:03:25.7031744Z ##[debug]Match start index: -1
2019-05-03T12:03:25.7620325Z
2019-05-03T12:03:25.7620767Z
2019-05-03T12:03:25.7621168Z !!!!!!!!!!!!!!!!!!!!!!!!!!! PACKER CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
2019-05-03T12:03:25.7621374Z
2019-05-03T12:03:25.7621631Z Packer crashed! This is always indicative of a bug within Packer.
2019-05-03T12:03:25.7622009Z A crash log has been placed at "crash.log" relative to your current
2019-05-03T12:03:25.7622366Z working directory. It would be immensely helpful if you could please
2019-05-03T12:03:25.7622715Z report the crash with Packer1 so that we can fix this.
2019-05-03T12:03:25.7622893Z
2019-05-03T12:03:25.7623141Z 1: https://github.com/hashicorp/packer/issues
2019-05-03T12:03:25.7623296Z
2019-05-03T12:03:25.7623562Z !!!!!!!!!!!!!!!!!!!!!!!!!!! PACKER CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
2019-05-03T12:03:25.7623748Z
2019-05-03T12:03:25.7624254Z ##[debug]Parsing log line to extract output...
2019-05-03T12:03:25.7624661Z ##[debug]/*************************************
2019-05-03T12:03:25.7625524Z ##[debug]

!!!!!!!!!!!!!!!!!!!!!!!!!!! PACKER CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Packer crashed! This is always indicative of a bug within Packer.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Packer1 so that we can fix this.

!!!!!!!!!!!!!!!!!!!!!!!!!!! PACKER CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

This same exact template works in the other 3 regions we run this in Azure (East US, North Europe, West US). This failure has happened every single time over the past 2 weeks.

Note that we did not use the windows-update plug in before that. We recently upgraded our images from Windows 2016 to Windows 2019 and need the plug in because the Azure Marketplace Windows 2019 images do not have all the critical updates installed. I am reporting this issue to the plug in because the template also worked on Windows Server 2019 in Azure Australia East region before the addition of the windows-update plug in.

I have upgraded to the latest version of this plugin (v0.7.0) but it has the same error. Additionally, I have upgraded our Packer version from 1.3.2 to 1.4.0 and have a different error with Packer that I reported:

hashicorp/packer#7608

But, I have upgraded Packer to version 1.3.5 and it has the same EOF error.

Packer crash log:
crash.log

Doesn't work with environment_vars

We need to access a proxy server to get out for windows updates. Normally we use environment_vars to get powershell and windows_shell provisioners to work with our proxies.

Could we add something to this that allowed the use of environment_vars to work with proxies?

Windows update script exited with non-zero exit status: 2147943515

Packer 1.3.1 (docker image hashicorp/packer:light)
packer-provisioner-windows-update-linux 0.5.1
Building a Windows Server 2016 VM

==> vmware-iso: Uploading the Windows update elevated script...
==> vmware-iso: Uploading the Windows update script...
==> vmware-iso: Running Windows update...
==> vmware-iso: Stopping virtual machine...
==> vmware-iso: Unregistering virtual machine...
==> vmware-iso: Deleting output directory...
Build 'vmware-iso' errored: Windows update script exited with non-zero exit status: 2147943515

Same result with or without filters.

Azurerm Windows 2016 datacenter - Search for Windows updates failed with 'Exception from HRESULT: 0x8024402F

Packer 1.4.3
Base image MS - Windows2016 Datacenter image in azure
Builder azurerm


==> Azure-UK-South: Running Windows update...
Azure-UK-South: Searching for Windows updates...
Azure-UK-South: Waiting for operation to complete (system performance: 2 % cpu; 26 % memory)...
Azure-UK-South: Waiting for operation to complete (system performance: 16 % cpu; 96 % memory)...
Azure-UK-South: Waiting for operation to complete (system performance: 3 % cpu; 95 % memory)...


same scripts working ok on none azure infrastructure
based on other notes i've checked if its using a proxy - none is shown
I've also tried disabling windows agent on the vm but still get the same error

Problems running under Windows 2008 R2 (0.6.0)

I had an issue almost immediately, with the latest version of the provisioner on Windows 2008R2 (where I still have a need to generate test images and templates, due to a rather large number of servers in our environment that have not been upgraded...)

In the windows-update.ps1 file - I was getting an error where you were setting the updateDownloader priority to 4. It appears that even though the Microsoft documentation implies that there is a dpExtraHigh settings, that it was not implemented in all their OS.

I was able to get past it by wrapping the statement in a try-catch.

    try {
        $updateDownloader.Priority = 4 # 1 (dpLow), 2 (dpNormal), 3 (dpHigh), 4 (dpExtraHigh).
    } catch {}

Additionally, in both of the Powershell files in update folder, the use of ScriptStackTrace, within your trap blocks, causes issues on servers where Powershell 2.0 is still installed. I was able to generate a meaningful error by utilizing properties of $error.InvocationInfo to capture the pertinent areas there were issues.

    $err = $_
    Write-Output "ERROR: $($err)"
    if ($PSVersionTable.PSVersion.Major -gt 2) {
        Write-Output (($err.ScriptStackTrace -split '\r?\n') -replace '^(.*)$','ERROR: $1')
    } else {
        Write-Output "ERROR IN     : $($err.InvocationInfo.ScriptName)"
        Write-Output "LINE NUMBER  : $($err.InvocationInfo.ScriptLineNumber)"
        Write-Output "OFFSET       : $($err.InvocationInfo.OffsetInLine)"
        Write-Output "COMMAND      : $($err.InvocationInfo.MyCommand)"
        Write-Output "LINE         : $($err.InvocationInfo.Line)"
    }
    Write-Output (($err.Exception.ToString() -split '\r?\n') -replace '^(.*)$','ERROR EXCEPTION: $1')

Finally, the last issue I encountered was more cosmetic. On these servers, I was running into an issue where Powershell was breaking up output longer than 79 characters into separate lines of output. Such as:

virtualbox-iso: ERROR: Exception setting "Priority": "The parameter is incorrect. (Exception fr
virtualbox-iso: om HRESULT: 0x80070057 (E_INVALIDARG))"

Instead of

virtualbox-iso: ERROR: Exception setting "Priority": "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"

I was able to remedy that by adding the following at the 'top' of the .ps1 files.

$Host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size (500, 25)

By and large, my testing with 0.6.0 has been very positive - hacking I had to do on the provisioner.go file to achieve stability on older OS versions is no longer needed.

The only other piece of info that I would offer up, is that I do have a stable, and working version of
elevated-template.ps1 that configures the scheduled task directly, rather than importing a pre-baked .XML file. This was developed based on some strangeness (the root of which I can't seem to remember...) where the .XML import would fail, when everything seemed to be working as it should.

I am extremely excited to use your provisioner to build images/templates. It is a definite improvement on the sort of blind process of having the windows update logic built into the Autounattend.xml file.

If any or all of these are of interest, I can certainly cobble together a pull request.

Keep up the great work.
Cheers.

Error on Install, No File

Having used on windows 2012 R2 with no issues, I am finding that on windows 2016 core I am getting an no file error when the provisioner attempts to install the updates and then fails with error.

==> amazon-ebs: Running Windows update...
    amazon-ebs: #< CLIXML
    amazon-ebs: Searching for Windows updates...
    amazon-ebs: Skipped (filter) Windows update (2018-05-17; 1273.25 MB): 2018-05 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4103720)
    amazon-ebs: Found Windows update (2018-05-17; 11.43 MB): 2018-05 Update for Windows Server 2016 for x64-based Systems (KB4132216)
    amazon-ebs: Found Windows update (2018-05-30; 5.78 MB): Update for Windows Defender antimalware platform - KB4052623 (Version 4.16.17656.18052)
    amazon-ebs: Downloading Windows updates...
    amazon-ebs: Installing Windows updates...
    amazon-ebs: ERROR: Exception from HRESULT: 0x80240016
    amazon-ebs: ERROR: at <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: line 185
    amazon-ebs: ERROR: at <ScriptBlock>, <No file>: line 1
    amazon-ebs: ERROR EXCEPTION: System.Runtime.InteropServices.COMException (0x80240016): Exception from HRESULT: 0x80240016
    amazon-ebs: ERROR EXCEPTION:    at System.Management.Automation.ComInterop.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo& excepInfo, ComMethodDesc method, Object[] args, UInt32 argErr)
    amazon-ebs: ERROR EXCEPTION:    at CallSite.Target(Closure , CallSite , ComObject )
    amazon-ebs: ERROR EXCEPTION:    at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
    amazon-ebs: ERROR EXCEPTION:    at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
    amazon-ebs: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.DynamicInstruction`2.Run(InterpretedFrame frame)
    amazon-ebs: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
    amazon-ebs: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">2</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>
==> amazon-ebs: Terminating the source AWS instance...
==> amazon-ebs: Cleaning up any extra volumes...
==> amazon-ebs: No volumes to clean up, skipping
==> amazon-ebs: Deleting temporary security group...
==> amazon-ebs: Deleting temporary keypair...
Build 'amazon-ebs' errored: Windows update script exited with non-zero exit status: 1

==> Some builds didn't complete successfully and had errors:
--> amazon-ebs: Windows update script exited with non-zero exit status: 1

development build fails

I've made a change and would like to do a development build, but this fails.
Can you help me out?

make -d output fails here:

...
github.com/hashicorp/packer/helper/ssh
github.com/hashicorp/packer/helper/useragent
github.com/hashicorp/packer/vendor/github.com/masterzen/azure-sdk-for-go/core/http
github.com/hashicorp/packer/vendor/github.com/mitchellh/go-fs
github.com/hashicorp/packer/vendor/github.com/mitchellh/go-fs/fat
github.com/hashicorp/packer/vendor/github.com/masterzen/winrm
github.com/hashicorp/packer/vendor/github.com/packer-community/winrmcp/winrmcp
Reaping losing child 0x558270e61720 PID 940
Makefile:4: recipe for target 'packer-provisioner-windows-update' failed
make: *** [packer-provisioner-windows-update] Error 2
Removing child 0x558270e61720 PID 940 from chain.

Doesn't work with Server 2019

Hello Rui Lopes :)

Your module doesn't work with Server 2019 :/

Config :

{
    "variables": {
      "os_name": "Win_Srv_STD_CORE_2019_English",
      "iso_url": ".\\iso\\en_windows_server_2019_x64_dvd_3c2cf1202.iso",
      "iso_checksum_type": "sha256",
      "iso_checksum": "7B463563206DCE275F2D3FF77AC36C430052FAE161CD4F8B31F3DC7AF1C3F418",
      "switch_name": "Lab",
      "vlan_id": ""
    },
    "builders": [
      {
        "type": "hyperv-iso",
        "vm_name": "{{ user `os_name` }}",
        "iso_url": "{{ user `iso_url` }}",
        "iso_checksum_type": "{{user `iso_checksum_type`}}",
        "iso_checksum": "{{user `iso_checksum`}}",
        "temp_path": "./Tmp",
        "disk_size": "40000",
        "communicator": "winrm",
        "winrm_username": "Administrator",
        "winrm_password": "password",
        "winrm_timeout": "8h",
        "shutdown_command": "C:/windows/system32/sysprep/sysprep.exe /generalize /oobe /unattend:C:/Windows/system32/unattended.xml /quiet /shutdown /mode:vm",
        "shutdown_timeout": "30m",
        "ram_size": 2048,
        "enable_dynamic_memory": "true",
        "cpu": 4,
        "generation": 2,
        "switch_name": "{{user `switch_name`}}",
        "vlan_id": "{{user `vlan_id`}}",
        "boot_wait": "0s",
        "boot_command": [
          "aaaaa<wait>a<wait>a<wait>"
        ],
        "output_directory": "./Tmp/Output/{{ user `os_name` }}/",
        "guest_additions_mode":"disable",
        "enable_secure_boot":true,
        "secondary_iso_images": [
          "./Tmp/BootDisk/win2019stdcore.iso"
        ]
      }
    ],
    "provisioners": [
        {
            "type": "windows-update",
            "filters": [
                "exclude:$_.Title -like '*Preview*'",
                "include:$_.Title -like '*Cumulative Update for Windows*'",
                "include:$_.AutoSelectOnWebSites"
            ]
        }
    ],
    "post-processors": [
      {
        "type": "vagrant",
        "compression_level": 9,
        "keep_input_artifact": false,
        "output": "./Output/{{ user `os_name` }}_{{.Provider}}.box",
        "vagrantfile_template": "./Templates/win2019stdcore/vagrantfile.template"
      }
    ]
  }

Result Logs :

==> hyperv-iso: Creating build directory...
==> hyperv-iso: Retrieving ISO
    hyperv-iso: Using file in-place: file:///G:/v2/PackerTemplates/PackerTemplates/Iso/en_windows_server_2019_x64_dvd_3c2cf1202.iso
==> hyperv-iso: Creating switch 'Lab' if required...
==> hyperv-iso:     switch 'Lab' already exists. Will not delete on cleanup...
==> hyperv-iso: Creating virtual machine...
==> hyperv-iso: Enabling Integration Service...
==> hyperv-iso: Setting boot drive to os dvd drive G:/v2/PackerTemplates/PackerTemplates/Iso/en_windows_server_2019_x64_dvd_3c2cf1202.iso ...
==> hyperv-iso: Mounting os dvd drive G:/v2/PackerTemplates/PackerTemplates/Iso/en_windows_server_2019_x64_dvd_3c2cf1202.iso ...
==> hyperv-iso: Skipping mounting Integration Services Setup Disk...
==> hyperv-iso: Mounting secondary DVD images...
==> hyperv-iso: Mounting secondary dvd drive ./Tmp/BootDisk/win2019stdcore.iso ...
==> hyperv-iso: Configuring vlan...
==> hyperv-iso: Starting the virtual machine...
==> hyperv-iso: Attempting to connect with vmconnect...
==> hyperv-iso: Host IP for the HyperV machine: 172.16.10.69
==> hyperv-iso: Typing the boot command...
==> hyperv-iso: Waiting for WinRM to become available...
    hyperv-iso: WinRM connected.
    hyperv-iso: #< CLIXML
    hyperv-iso: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>
==> hyperv-iso: Connected to WinRM!
==> hyperv-iso: Uploading the Windows update elevated script...
==> hyperv-iso: Uploading the Windows update script...
==> hyperv-iso: Running Windows update...
    hyperv-iso: #< CLIXML
    hyperv-iso: Searching for Windows updates...
    hyperv-iso: ERROR: Exception from HRESULT: 0x8024402C
    hyperv-iso: ERROR: at <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: line 141
    hyperv-iso: ERROR: at <ScriptBlock>, <No file>: line 1
    hyperv-iso: ERROR EXCEPTION: System.Runtime.InteropServices.COMException (0x8024402C): Exception from HRESULT: 0x8024402C
    hyperv-iso: ERROR EXCEPTION:    at System.Management.Automation.ComInterop.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo& excepInfo, ComMethodDesc method, Object[] args, UInt32 argErr)
    hyperv-iso: ERROR EXCEPTION:    at CallSite.Target(Closure , CallSite , ComObject , String )
    hyperv-iso: ERROR EXCEPTION:    at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
    hyperv-iso: ERROR EXCEPTION:    at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
    hyperv-iso: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
    hyperv-iso: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
    hyperv-iso: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">2</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>
==> hyperv-iso: Disconnecting from vmconnect...
==> hyperv-iso: Clean up secondary dvd drives...
==> hyperv-iso: Clean up os dvd drive...
==> hyperv-iso: Unregistering and deleting virtual machine...
==> hyperv-iso: Deleting output directory...
==> hyperv-iso: Deleting build directory...
Build 'hyperv-iso' errored: Windows update script exited with non-zero exit status: 1

==> Some builds didn't complete successfully and had errors:
--> hyperv-iso: Windows update script exited with non-zero exit status: 1

==> Builds finished but no artifacts were created.

Thx
Thomas

Not all updates are installed

Hey there,

I've encountered not all updates are installed in my config:

  • packer v1.4.3
  • packer-builder-vsphere v2.3
  • Windows Server 2016

There should be many more updates to find/install and should take much longer (a few hours maybe instead of only minutes). The build itself finished nonetheless (output/code below).

Perhaps someone has a suggestion on this...

Packer-Output:

==> vsphere-iso: Creating VM...
==> vsphere-iso: Customizing hardware...
==> vsphere-iso: Mount ISO images...
==> vsphere-iso: Creating floppy disk...
    vsphere-iso: Copying files flatly from floppy_files
    vsphere-iso: Done copying files from floppy_files
    vsphere-iso: Collecting paths from floppy_dirs
    vsphere-iso: Resulting paths from floppy_dirs : [/opt/git/packer-config/windows/server_2016/floppy_files/autounattend.xml /opt/git/packer-config/windows/server_2016/floppy_files/openssh.ps1]
    vsphere-iso: Recursively copying : /opt/git/packer-config/windows/server_2016/floppy_files/autounattend.xml
    vsphere-iso: Recursively copying : /opt/git/packer-config/windows/server_2016/floppy_files/openssh.ps1
    vsphere-iso: Done copying paths from floppy_dirs
==> vsphere-iso: Uploading created floppy image
==> vsphere-iso: Adding generated Floppy...
==> vsphere-iso: Set boot order temporary...
==> vsphere-iso: Power on VM...
==> vsphere-iso: Waiting for IP...
==> vsphere-iso: IP address: 10.123.4.242
==> vsphere-iso: Using ssh communicator to connect: 10.123.4.242
==> vsphere-iso: Waiting for SSH to become available...
==> vsphere-iso: Connected to SSH!
==> vsphere-iso: Provisioning with windows-shell...
==> vsphere-iso: Provisioning with shell script: /opt/git/packer-config/windows/server_2016/powershell_scripts/post_install_config.ps1
    vsphere-iso: The operation completed successfully.
    vsphere-iso: The operation completed successfully.
    vsphere-iso: The operation completed successfully.
    vsphere-iso: The operation completed successfully.
    vsphere-iso: The operation completed successfully.
    vsphere-iso: The operation completed successfully.
    vsphere-iso: The operation completed successfully.
    vsphere-iso: The operation completed successfully.
    vsphere-iso: The operation completed successfully.
==> vsphere-iso: Restarting Machine
==> vsphere-iso: Waiting for machine to restart...
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: #< CLIXML
    vsphere-iso: BCTEMPLATEWS16 restarted.
==> vsphere-iso: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>
==> vsphere-iso: Machine successfully restarted, moving on
==> vsphere-iso: Uploading the Windows update elevated script...
==> vsphere-iso: Uploading the Windows update check for reboot required elevated script...
==> vsphere-iso: Uploading the Windows update script...
==> vsphere-iso: Running Windows update...
    vsphere-iso: Searching for Windows updates...
    vsphere-iso: Waiting for operation to complete (system performance: 1 % cpu; 22 % memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 1 % cpu; 23 % memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 24 % cpu; 34 % memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 5 % cpu; 36 % memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 5 % cpu; 39 % memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 14 % cpu; 36 % memory)...
    vsphere-iso: Found Windows update (2018-07-05; 1271.31 MB): 2018-05 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4103723)
    vsphere-iso: Found Windows update (2019-08-14; 44.17 MB): Windows Malicious Software Removal Tool x64 - August 2019 (KB890830)
    vsphere-iso: Found Windows update (2019-09-11; 11.52 MB): 2019-09 Servicing Stack Update for Windows Server 2016 for x64-based Systems (KB4512574)
    vsphere-iso: Downloading Windows updates (3 updates; 1327.01 MB)...
    vsphere-iso: Waiting for operation to complete (system performance: 24 % cpu; 42 % memory)...
    vsphere-iso: Installing Windows updates...
    vsphere-iso: Waiting for operation to complete (system performance: 10 % cpu; 33 % memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 5 % cpu; 31 % memory)...
==> vsphere-iso: Restarting Machine
==> vsphere-iso: Waiting for machine to restart...
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: A system shutdown is in progress.(1115)
==> vsphere-iso: #< CLIXML
    vsphere-iso: BCTEMPLATEWS16 restarted.
==> vsphere-iso: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>
==> vsphere-iso: Machine successfully restarted, moving on
==> vsphere-iso: Provisioning with windows-shell...
==> vsphere-iso: Provisioning with shell script: /tmp/windows-shell-provisioner825708904
    vsphere-iso:
    vsphere-iso: C:\Users\cloud>cmd.exe /c powershell Start-Process msiexec.exe -Wait -ArgumentList "/i","F:\CloudbaseInitSetup_0_9_11_x64.msi"
==> vsphere-iso: Provisioning with windows-shell...
==> vsphere-iso: Provisioning with shell script: /opt/git/packer-config/windows/server_2016/powershell_scripts/post_install_cleanup.ps1
==> vsphere-iso: Shut down VM...
==> vsphere-iso: Deleting Floppy drives...
==> vsphere-iso: Deleting Floppy image...
==> vsphere-iso: Eject CD-ROM drives...
==> vsphere-iso: Convert VM into template...
==> vsphere-iso: Clear boot order...
Build 'vsphere-iso' finished.

Packer.json:

  "provisioners": [
  {
    "type": "windows-shell",
    "script": "{{user `post_install_config_script`}}",
    "remote_path": "{{user `post_install_config_path`}}",
    "execute_command": "cmd.exe /c powershell Invoke-Expression -Command \"C:\\Users\\Cloud\\post_install_config.ps1\""
  },
  {
    "type": "windows-restart",
    "check_registry": "true"
  },
  {
    "type": "windows-update"
  },
  {
    "type": "windows-restart",
    "check_registry": "true"
  },
  {

    "type": "windows-shell",
    "inline": ["cmd.exe /c powershell Start-Process msiexec.exe -Wait -ArgumentList \"/i\",\"F:\\CloudbaseInitSetup_0_9_11_x64.msi\""]
  },
  {
    "type": "windows-shell",
    "script": "{{user `post_install_cleanup_script`}}",
    "remote_path": "{{user `post_install_cleanup_path`}}",
    "execute_command": "cmd.exe /c powershell Invoke-Expression -Command \"C:\\Users\\Cloud\\post_install_cleanup.ps1\""
  }]

Known drivers that have no user input is labeled as CanRequestUserInput are skipped

Using IsInstalled=0 it is somewhat unexpected that CanRequestUserInput is skipped. Especially when I know these two updates actually do not request any User Input as these are drivers and never seen any prompts.

   {
      "type": "windows-update",
      "search_criteria": "IsInstalled=0"
    },
vsphere-clone: Skipped (CanRequestUserInput) Windows update (2019-06-06; 0.05 MB): VMware, Inc. - SCSIAdapter - 4/6/2018 12:00:00 AM - 1.3.10.0
vsphere-clone: Skipped (CanRequestUserInput) Windows update (2019-04-24; 0.08 MB): VMware, Inc. - Net - 10/17/2018 12:00:00 AM - 1.8.10.0

Unable to build

The build package is unusable.
Can you please provide the exact steps that are required to build this package?

I cloned this repo into a subfolder of ~/Git.
Than I run the commands from the Readme:

go get -u github.com/hashicorp/packer/packer/plugin
go get -u github.com/jteeuwen/go-bindata/...
make

It builds and looks like it was successful, but the resulting package cannot be run by packer. "Exit before we could connect"

Issues with Build Immutable Packer Image in Azure Devops

Having issues building a VHD image as part of a build pipeline in Azure Devops.

The task starts but then just sits on searching for updates or similar until the hosted agent times out after 6 hours.

I have had one build which succeeded but then running two further builds failed, without any config changes.

I am installing the provisioner using choco install task prior to the build image task.

{
  "builders": [
    {
      "capture_container_name": "vsts-buildimagetask",
      "capture_name_prefix": "{{user `capture_name_prefix`}}",
      "client_id": "{{user `client_id`}}",
      "client_secret": "{{user `client_secret`}}",
      "communicator": "winrm",
      "image_offer": "{{user `image_offer`}}",
      "image_publisher": "{{user `image_publisher`}}",
      "image_sku": "{{user `image_sku`}}",
      "location": "{{user `location`}}",
      "object_id": "{{user `object_id`}}",
      "os_type": "Windows",
      "resource_group_name": "{{user `environment`}}-RG",
      "storage_account": "{{user `environment` | lower}}",
      "subscription_id": "{{user `subscription_id`}}",
      "tenant_id": "{{user `tenant_id`}}",
      "type": "azure-arm",
      "vm_size": "Standard_D3_v2",
      "winrm_insecure": "true",
      "winrm_timeout": "15m",
      "winrm_use_ssl": "true",
      "winrm_username": "packer"
    }
  ],
  "post-processors": [],
  "provisioners": [
    {
      "type": "windows-shell",
      "inline": [
        "cmd /c \"if exist c:\\\\fileTemp rd /s /q c:\\\\fileTemp\"",
        "cmd /c \"mkdir c:\\\\fileTemp\""
      ]
    },
    {
      "type": "windows-update"
    },
    {
      "type": "file",
      "source": "{{user `package_path`}}",
      "destination": "c:\\fileTemp\\{{user `package_name`}}"
    },
    {
      "type": "powershell",
      "inline": [
        "cd \"C:\\fileTemp\"",
        "C:\\fileTemp\\{{user `package_name`}}\\{{user `scriptPath`}}"
      ]
    },
    {
      "type": "powershell",
      "inline": [
        "if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}",
        "& $Env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quit /quiet"
      ]
    }
  ],
  "variables": {
    "capture_name_prefix": "",
    "client_id": "",
    "client_secret": "",
    "image_offer": "",
    "image_publisher": "",
    "image_sku": "",
    "location": "",
    "object_id": "",
    "package_name": "",
    "package_path": "",
    "scriptPath": "",
    "subscription_id": "",
    "tenant_id": "",
    "environment": ""
  }
}

The build gets stuck when downloading or installing windows updates at various stages. This sits for 6 hours until the hosted agent times out.

example Log

2018-12-19T16:15:16.0820077Z ==> azure-arm: Uploading the Windows update elevated script...
2018-12-19T16:15:16.0820175Z 
2018-12-19T16:15:22.3871926Z ==> azure-arm: Uploading the Windows update check for reboot required elevated script...
2018-12-19T16:15:22.3872676Z 
2018-12-19T16:15:29.4799809Z ==> azure-arm: Uploading the Windows update script...
2018-12-19T16:15:29.4799954Z 
2018-12-19T16:15:36.9359463Z ==> azure-arm: Running Windows update...
2018-12-19T16:15:36.9360077Z 
2018-12-19T16:15:48.1680114Z     azure-arm: Searching for Windows updates...

Restart aborted before given a chance to complete, stuck in infinite loop

Using the VSphereISO builder to create a Windows Server 2019 (1809) LTSC image, I'm seeing the following sequence of events, 100% reproducible in my environment. The windows-update provisioner is getting stuck waiting in an infinite loop for a reboot that will never happen.

The relevant sequence of events (note timestamps):

2020/03/12 17:08:12 packer.exe plugin: [INFO] starting remote command: shutdown.exe -f -r -t 0 -c "packer restart"
2020/03/12 17:08:12 packer.exe plugin: [INFO] starting remote command: shutdown.exe -f -r -t 60 -c "packer restart test"
2020/03/12 17:08:13 packer.exe plugin: [INFO] starting remote command: shutdown.exe -a

It seems that the packer restart test and subsequent shutdown -a occur so quickly that the real, non-test, reboot is cancelled.

Full log:

    vsphere-iso: Waiting for operation to complete (system performance: 0% cpu; 23% memory)...
2020/03/12 17:08:12 packer.exe plugin: [INFO] command 'PowerShell -ExecutionPolicy Bypass -OutputFormat Text -File C:/Windows/Temp/packer-windows-update-elevated.ps1' exited with code: 101
2020/03/12 17:08:12 packer.exe plugin: [INFO] RPC endpoint: Communicator ended with: 101
==> vsphere-iso: Restarting the machine...
2020/03/12 17:08:12 [INFO] 1325 bytes written for 'stdout'
2020/03/12 17:08:12 [INFO] 0 bytes written for 'stderr'
2020/03/12 17:08:12 [INFO] RPC client: Communicator ended with: 101
2020/03/12 17:08:12 [INFO] RPC endpoint: Communicator ended with: 101
2020/03/12 17:08:12 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:12 [INFO] 0 bytes written for 'stderr'
2020/03/12 17:08:12 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:12 [INFO] 1325 bytes written for 'stdout'
2020/03/12 17:08:12 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:12 [INFO] RPC client: Communicator ended with: 101
2020/03/12 17:08:12 packer.exe plugin: [INFO] starting remote command: shutdown.exe -f -r -t 0 -c "packer restart"
2020/03/12 17:08:12 packer.exe plugin: [INFO] command 'shutdown.exe -f -r -t 0 -c "packer restart"' exited with code: 0
2020/03/12 17:08:12 packer.exe plugin: [INFO] RPC endpoint: Communicator ended with: 0
2020/03/12 17:08:12 [INFO] 0 bytes written for 'stdout'
==> vsphere-iso: Waiting for machine to become available...
2020/03/12 17:08:12 [INFO] 0 bytes written for 'stderr'
2020/03/12 17:08:12 [INFO] RPC client: Communicator ended with: 0
2020/03/12 17:08:12 [INFO] RPC endpoint: Communicator ended with: 0
2020/03/12 17:08:12 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:12 [INFO] 0 bytes written for 'stdout'
2020/03/12 17:08:12 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:12 [INFO] 0 bytes written for 'stderr'
2020/03/12 17:08:12 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:12 [INFO] RPC client: Communicator ended with: 0
2020/03/12 17:08:12 packer.exe plugin: [INFO] starting remote command: shutdown.exe -f -r -t 60 -c "packer restart test"
2020/03/12 17:08:12 packer.exe plugin: [INFO] command 'shutdown.exe -f -r -t 60 -c "packer restart test"' exited with code: 0
2020/03/12 17:08:12 packer.exe plugin: [INFO] RPC endpoint: Communicator ended with: 0
2020/03/12 17:08:12 [INFO] 0 bytes written for 'stdout'
2020/03/12 17:08:12 [INFO] 0 bytes written for 'stderr'
2020/03/12 17:08:12 [INFO] RPC client: Communicator ended with: 0
2020/03/12 17:08:12 [INFO] RPC endpoint: Communicator ended with: 0
2020/03/12 17:08:12 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:12 [INFO] 0 bytes written for 'stderr'
2020/03/12 17:08:12 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:12 [INFO] 0 bytes written for 'stdout'
2020/03/12 17:08:12 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:12 [INFO] RPC client: Communicator ended with: 0
2020/03/12 17:08:13 packer.exe plugin: [INFO] starting remote command: shutdown.exe -a
2020/03/12 17:08:13 packer.exe plugin: [INFO] command 'shutdown.exe -a' exited with code: 0
2020/03/12 17:08:13 packer.exe plugin: [INFO] RPC endpoint: Communicator ended with: 0
2020/03/12 17:08:13 [INFO] 0 bytes written for 'stdout'
2020/03/12 17:08:13 [INFO] 0 bytes written for 'stderr'
2020/03/12 17:08:13 [INFO] RPC client: Communicator ended with: 0
2020/03/12 17:08:13 [INFO] RPC endpoint: Communicator ended with: 0
2020/03/12 17:08:13 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:13 [INFO] 0 bytes written for 'stderr'
2020/03/12 17:08:13 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:13 [INFO] 0 bytes written for 'stdout'
2020/03/12 17:08:13 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:13 [INFO] RPC client: Communicator ended with: 0
2020/03/12 17:08:13 packer.exe plugin: [INFO] starting remote command: PowerShell -ExecutionPolicy Bypass -OutputFormat Text -File C:/Windows/Temp/packer-windows-update-pending-reboot-elevated.ps1
    vsphere-iso: Waiting for the Windows Modules Installer to exit...
2020/03/12 17:08:39 packer.exe plugin: [INFO] command 'PowerShell -ExecutionPolicy Bypass -OutputFormat Text -File C:/Windows/Temp/packer-windows-update-pending-reboot-elevated.ps1' exited with code: 101
2020/03/12 17:08:39 packer.exe plugin: [INFO] RPC endpoint: Communicator ended with: 101
2020/03/12 17:08:39 [INFO] 0 bytes written for 'stderr'
2020/03/12 17:08:39 [INFO] 54 bytes written for 'stdout'
2020/03/12 17:08:39 [INFO] RPC client: Communicator ended with: 101
2020/03/12 17:08:39 [INFO] RPC endpoint: Communicator ended with: 101
2020/03/12 17:08:39 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:39 [INFO] 0 bytes written for 'stderr'
2020/03/12 17:08:39 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:39 [INFO] 54 bytes written for 'stdout'
2020/03/12 17:08:39 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:39 [INFO] RPC client: Communicator ended with: 101
2020/03/12 17:08:39 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:39 Retryable error: Machine not yet available (exit status 101)
2020/03/12 17:08:44 packer.exe plugin: [INFO] starting remote command: shutdown.exe -f -r -t 60 -c "packer restart test"
2020/03/12 17:08:44 packer.exe plugin: [INFO] command 'shutdown.exe -f -r -t 60 -c "packer restart test"' exited with code: 0
2020/03/12 17:08:44 packer.exe plugin: [INFO] RPC endpoint: Communicator ended with: 0
2020/03/12 17:08:44 [INFO] 0 bytes written for 'stderr'
2020/03/12 17:08:44 [INFO] 0 bytes written for 'stdout'
2020/03/12 17:08:44 [INFO] RPC client: Communicator ended with: 0
2020/03/12 17:08:44 [INFO] RPC endpoint: Communicator ended with: 0
2020/03/12 17:08:44 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:44 [INFO] 0 bytes written for 'stderr'
2020/03/12 17:08:44 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:44 [INFO] 0 bytes written for 'stdout'
2020/03/12 17:08:44 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:44 [INFO] RPC client: Communicator ended with: 0
2020/03/12 17:08:44 packer.exe plugin: [INFO] starting remote command: shutdown.exe -a
2020/03/12 17:08:44 packer.exe plugin: [INFO] command 'shutdown.exe -a' exited with code: 0
2020/03/12 17:08:44 packer.exe plugin: [INFO] RPC endpoint: Communicator ended with: 0
2020/03/12 17:08:44 [INFO] 0 bytes written for 'stderr'
2020/03/12 17:08:44 [INFO] 0 bytes written for 'stdout'
2020/03/12 17:08:44 [INFO] RPC client: Communicator ended with: 0
2020/03/12 17:08:44 [INFO] RPC endpoint: Communicator ended with: 0
2020/03/12 17:08:44 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:44 [INFO] 0 bytes written for 'stderr'
2020/03/12 17:08:44 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:44 [INFO] 0 bytes written for 'stdout'
2020/03/12 17:08:44 packer-provisioner-windows-update.exe plugin: 2020/03/12 17:08:44 [INFO] RPC client: Communicator ended with: 0
2020/03/12 17:08:44 packer.exe plugin: [INFO] starting remote command: PowerShell -ExecutionPolicy Bypass -OutputFormat Text -File C:/Windows/Temp/packer-windows-update-pending-reboot-elevated.ps1
    vsphere-iso: Waiting for the Windows Modules Installer to exit...

// And on and on forever...

Update Download Size Wrong

The update download size is not showing correctly:

Searching for Windows updates...
Found Windows update (2020-02-11; 30.02 MB): Windows Malicious Software Removal Tool x64 - February 2020 (KB890830)
Found Windows update (2020-02-11; 68.19 MB): 2020-02 Cumulative Update for .NET Framework 3.5 and 4.8 for Windows 10 Version 1909 for x64 (KB4534132)
Found Windows update (2020-02-11; 20.75 MB): 2020-02 Security Update for Adobe Flash Player for Windows 10 Version 1909 for x64-based Systems (KB4537759)
Found Windows update (2020-02-12; 95.73 MB): Security Intelligence Update for Windows Defender Antivirus - KB2267602 (Version 1.309.810.0)
Found Windows update (2020-02-11; 86512.19 MB): 2020-02 Cumulative Update for Windows 10 Version 1909 for x64-based Systems (KB4532693)
Downloading Windows updates (5 updates; 86726.87 MB)...

I am not exactly sure why the cumulative update is showing as 86 GB...

Updates hanging waiting on TiWorker.exe exit on Windows 10 RS3 (1709)

This looks to be the same issue as #5, and possibly #41.

On Windows 10 RS3 (1709), TiWorker.exe can remain active even after updates are complete and a reboot is pending. Looking at other scripts and tools to install Windows Updates, I can't find any other references to waiting for TiWorker.exe to complete before restarting.

It seems like the wait should be removed, or at worst timed out and continuing with a reboot.

I'm happy to make the PR, but I wanted to discuss the issue first before proposing a code change.

If you have any questions, please let me know. Thanks!

Windows Updates hang with Cumulative Updates

When using packer to create Windows images with this update plugin, it always hangs when downloading the update.
If I log onto the system, I can see in the log files of this plugin, that the update is afterwards also installed, but the reboot is never executed. A manual reboot is not registered within packer (similar to the installation itself). This only seems to happen with the big cumulative updates.

My plugin call is simply:
"provisioners": [
{ "type": "windows-update" },
]

==> alicloud-ecs: Connected to WinRM!
==> alicloud-ecs: Uploading the Windows update elevated script...
==> alicloud-ecs: Uploading the Windows update check for reboot required elevated script...
==> alicloud-ecs: Uploading the Windows update script...
==> alicloud-ecs: Running Windows update...
alicloud-ecs: Searching for Windows updates...
alicloud-ecs: Found Windows update (2019-01-08; 1388.13 MB): 2019-01 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4480961)
alicloud-ecs: Downloading Windows updates (1 updates; 1388.13 MB)...

Updates silently failing

I'm using the latest version (0.7.1) along with Packer 1.4.0. I'm using the vanilla provisioner:

{
"type": "windows-update"
}

The log output, below, shows it executed the PowerShell command and got an exit code 0, but no updates happened and the provisioning process moved on. In comparing with other outputs posted here, I notice the "searching for updates" is missing.

After the image completed, I created a VM from it and it took quite a while for the new VM to identify updates, including the massive May 2019 rollup--it did not get applied as part of the Packer build (I hoped it would do the update).

Is there a flag or something I should be passing to tell it to wait for the download and install of the updates? I'm hoping I'm just missing something simple...

==> vsphere-iso: Running Windows update...
2019/05/15 00:01:40 packer-builder-vsphere-iso.linux: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>2019/05/15 00:01:40 [INFO] starting remote command: PowerShell -ExecutionPolicy Bypass -OutputFormat Text -File C:/Windows/Temp/packer-windows-update-elevated.ps1
    vsphere-iso: Waiting for the Windows Modules Installer to exit...
2019/05/15 00:02:16 packer-builder-vsphere-iso.linux: 2019/05/15 00:02:16 [INFO] command 'PowerShell -ExecutionPolicy Bypass -OutputFormat Text -File C:/Windows/Temp/packer-windows-update-elevated.ps1' exited with code: 0
2019/05/15 00:02:16 [INFO] 54 bytes written for 'stdout'
2019/05/15 00:02:16 [INFO] 0 bytes written for 'stderr'
2019/05/15 00:02:16 [INFO] RPC client: Communicator ended with: 0
2019/05/15 00:02:16 [INFO] RPC endpoint: Communicator ended with: 0
2019/05/15 00:02:16 packer-builder-vsphere-iso.linux: 2019/05/15 00:02:16 [INFO] RPC endpoint: Communicator ended with: 0
2019/05/15 00:02:16 packer-provisioner-windows-update: 2019/05/15 00:02:16 [INFO] 54 bytes written for 'stdout'
2019/05/15 00:02:16 packer-provisioner-windows-update: 2019/05/15 00:02:16 [INFO] 0 bytes written for 'stderr'
2019/05/15 00:02:16 packer-provisioner-windows-update: 2019/05/15 00:02:16 [INFO] RPC client: Communicator ended with: 0
2019/05/15 00:02:16 [INFO] (telemetry) ending windows-update

Can't Build from Dev

Hi
Build fails. Thrift entry in Go.sum is invalid. Could you please fix that.

Thanks

Problem on 2008 r2

Gokd morning,

Ive been having difficulties getting this workin lg on 2008 r2.

Here is the error

vsphere-iso: Rollup for Windows Server 2008 R2 for x64-based Systems (KB4343900)
vsphere-iso: Downloading Windows updates...
vsphere-iso: ERROR: Exception has been thrown by the target of an invocation.
vsphere-iso: #< CLIXML
vsphere-iso: Property 'ScriptStackTrace' cannot be found on this object. Make
vsphere-iso: sure that it e_x000D__x000A_
xists.x000D__x000AAt C:\Windows\Temp\packer-windows-update.ps1:34 char:23_x000D__x000A_+ Write-Output (($. <<<< ScriptStackTrace -split '\r
vsphere-iso: ?\n') -replace '^(.*)$x000D__x000A
','ERROR: $1')x000D__x000
vsphere-iso: A
+ CategoryInfo : InvalidOperation: (.:OperatorT
vsphere-iso: oken) [], RuntimeE x000D__x000A
xception_x000D__x000A

vsphere-iso: + FullyQualifiedErrorId : PropertyNotFoundStrict_x000D__x000A_
vsphere-iso:
x000D__x000A
==> vsphere-iso: Power off VM...
==> vsphere-iso: Destroying VM...
Build 'vsphere-iso' errored: Windows update script exited with non-zero exit status: 1

==> Some builds didn't complete successfully and had errors:
--> vsphere-iso: Windows update script exited with non-zero exit status: 1

==> Builds finished but no artifacts were created.
Build step 'Windows PowerShell' marked build as failure
NOTICE:

It seems like windows is maybe starting the download of the patches prior to the proviso net being able to do it and fails? I am downloading against a WSUS server.

Thoughts?

Download / Install all.

I've found that I need to include the windows-update provisioner more than once in my packer script to try and ensure that all Updates have been downloaded and installed. Is there a way of ensuring the windows-update provisioner continues to download/install until none are left? (Eg, behaviour when checking for windows updates manually in the gui is that often you need to run/install more than once to ensure there are none remaining).

Incompatible w/ packer v1.5.0

When running plugin v0.8.0 with packer v1.5.0, receive the following:

[packer]$ packer build packer-ami.json 
Failed to initialize build 'amazon-ebs': error initializing provisioner 'windows-update': Incompatible API version with plugin. Plugin version: 4, Ours: 5

==> Builds finished but no artifacts were created.
[packer]$ 

packer backward compatibility for v0.9.0

@rgl first of all, thank you for the contribution for this packer plugin. It is awesome!

Question, is there a way to make v0.9.0 backward compatible with packer 1.4.5 and below?

Fails with exit code 1

==> vsphere-iso: Running Windows update...
    vsphere-iso: #< CLIXML
    vsphere-iso: Searching for Windows updates...
    vsphere-iso: Skipped (filter) Windows update (2017-06-13; 12.55 MB): Microsoft Silverlight (KB4023307)
    vsphere-iso: Found Windows update (2018-05-17; 1273.25 MB): 2018-05 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4103720)
    vsphere-iso: Found Windows update (2018-05-17; 11.43 MB): 2018-05 Update for Windows Server 2016 for x64-based Systems (KB4132216)
    vsphere-iso: Found Windows update (2018-09-11; 45.88 MB): Windows Malicious Software Removal Tool x64 - September 2018 (KB890830)
    vsphere-iso: Found Windows update (2018-09-29; 148.29 MB): Definition Update for Windows Defender Antivirus - KB2267602 (Definition 1.277.305.0)
    vsphere-iso: Downloading Windows updates...
    vsphere-iso: Installing Windows updates...
    vsphere-iso: Pending Reboot detected. Waiting for the Windows Modules Installer to exit...
    vsphere-iso: Rebooting...
    vsphere-iso: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">2</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>
==> vsphere-iso: Power off VM...
==> vsphere-iso: Destroying VM...
Build 'vsphere-iso' errored: Windows update script exited with non-zero exit status: 1

Maybe it's the progress part at the end. If so, adding $ProgressPreference='SilentlyContinue' internally to your powershell calls could help.
Or it's because I'm connecting with ssh instead of winrm into it.

Option to limit number of updates per cycle

This is more of a feature request. It would be nice to limit the number of updates applied per cycle. Server 2008 R2 has so many updates that it would be nice to handle the update rounds a bit more "safely".

I was looking at your windowsupdate.ps1 and there might be an easy way to add a count to updates and then breaking when it hits that count.

Excellent work here, by the way! Super helpful!

Windows update fails with blank error

Looking to use this to script our Windows update as part of our golden image builds for Amazon EC2.

This is the error I get when I include the windows-update provisioner:

2017/07/11 13:55:13 packer.exe: 2017/07/11 13:55:13 Connected to machine
2017/07/11 13:55:13 ui: ==> tasks: Machine successfully restarted, moving on
2017/07/11 13:55:13 ui: ==> tasks: Uploading the Windows update elevated script...
2017/07/11 13:55:13 packer-provisioner-windows-update.exe: 2017/07/11 13:55:13 [INFO] 2859 bytes written for 'uploadData'
2017/07/11 13:55:13 [INFO] 2859 bytes written for 'uploadData'
2017/07/11 13:55:13 packer.exe: 2017/07/11 13:55:13 Uploading file to 'C:/Windows/Temp/packer-windows-update-elevated.ps1'
2017/07/11 13:55:14 packer.exe: #< CLIXML
2017/07/11 13:55:14 ui: ==> tasks: Uploading the Windows update script...
2017/07/11 13:55:14 packer-provisioner-windows-update.exe: 2017/07/11 13:55:14 [INFO] 5559 bytes written for 'uploadData'
2017/07/11 13:55:14 [INFO] 5559 bytes written for 'uploadData'
2017/07/11 13:55:14 packer.exe: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 2017/07/11 13:55:14 Uploading file to 'C:/Windows/Temp/packer-windows-update.ps1'
2017/07/11 13:55:15 packer.exe: #< CLIXML
2017/07/11 13:55:15 ui: ==> tasks: Running Windows update...
2017/07/11 13:55:16 packer.exe: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 2017/07/11 13:55:16 [INFO] starting remote command: PowerShell -ExecutionPolicy Bypass -OutputFormat Text -File C:/Windows/Temp/packer-windows-update-elevated.ps1
2017/07/11 13:55:16 packer.exe: 2017/07/11 13:55:16 [INFO] command 'PowerShell -ExecutionPolicy Bypass -OutputFormat Text -File C:/Windows/Temp/packer-windows-update-elevated.ps1' exited with code: 1
2017/07/11 13:55:16 packer.exe: 2017/07/11 13:55:16 [INFO] RPC endpoint: Communicator ended with: 1
2017/07/11 13:55:16 [INFO] 1144 bytes written for 'stdout'
2017/07/11 13:55:16 [INFO] RPC client: Communicator ended with: 1
2017/07/11 13:55:16 [INFO] 0 bytes written for 'stderr'
2017/07/11 13:55:16 [INFO] RPC endpoint: Communicator ended with: 1
2017/07/11 13:55:16 packer-provisioner-windows-update.exe: 2017/07/11 13:55:16 [INFO] 1144 bytes written for 'stdout'
2017/07/11 13:55:16 packer-provisioner-windows-update.exe: 2017/07/11 13:55:16 [INFO] 0 bytes written for 'stderr'
2017/07/11 13:55:16 ui: tasks: ERROR: (12,8):UserId:
2017/07/11 13:55:16 ui: tasks: ERROR: at , C:\Windows\Temp\packer-windows-update-elevated.ps1: line 55
2017/07/11 13:55:16 ui: tasks: ERROR EXCEPTION: System.Runtime.InteropServices.COMException (0x80070534): (12,8):UserId:
2017/07/11 13:55:16 ui: tasks: ERROR EXCEPTION: at System.Management.Automation.ComInterop.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo& excepInfo, ComMethodDesc method, Object[] args, UInt32 argErr)
2017/07/11 13:55:16 packer-provisioner-windows-update.exe: 2017/07/11 13:55:16 [INFO] RPC client: Communicator ended with: 1
2017/07/11 13:55:16 ui: tasks: ERROR EXCEPTION: at CallSite.Target(Closure , CallSite , ComObject , Object , Object , Int32 , String , String , Int32 , Object )
2017/07/11 13:55:16 ui: tasks: ERROR EXCEPTION: at System.Dynamic.UpdateDelegates.UpdateAndExecute8[T0,T1,T2,T3,T4,T5,T6,T7,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
2017/07/11 13:55:16 ui: tasks: ERROR EXCEPTION: at System.Dynamic.UpdateDelegates.UpdateAndExecute8[T0,T1,T2,T3,T4,T5,T6,T7,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
2017/07/11 13:55:16 ui: tasks: ERROR EXCEPTION: at System.Management.Automation.Interpreter.DynamicInstruction`9.Run(InterpretedFrame frame)
2017/07/11 13:55:16 ui: tasks: ERROR EXCEPTION: at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2017/07/11 13:55:16 ui: ==> tasks: Terminating the source AWS instance...

This is our packer config:

{
"builders": [
{
"name": "tasks",
"type": "amazon-ebs",
"communicator": "winrm",
"user_data_file": "./ec2-userdata.ps1",
"ami_name": "base-tasks",
"tags": {
"Name": "base-tasks-{{isotime "2006-01-02"}}"
},
"region": "eu-west-1",
"instance_type": "m4.large",
"iam_instance_profile": "dev-build-role",
"vpc_id": "vpc-4afbea2e",
"subnet_id": "subnet-43213827",
"ami_users": "150445443113",
"force_deregister": true,
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "Windows_Server-2016-English-Full-Base-*",
"root-device-type": "ebs"
},
"owners": [ "801119661308" ],
"most_recent": true
},
"run_tags": {
"Name": "builder-tasks-{{isotime "2006-01-02"}}"
},
"security_group_id": "sg-b2498acb",
"winrm_username": "Administrator",
"winrm_use_ssl": true,
"winrm_insecure": true,
"disable_stop_instance": true
}
],
"provisioners": [
{
"type": "powershell",
"inline": [ "c:\bootstrap\bootstrap.ps1" ]
},
{
"type": "windows-restart"
},
{
"type": "windows-update"
},
{
"type": "windows-restart"
},
{
"type": "powershell",
"inline": [ "c:\bootstrap\ngen.ps1" ]
},
{
"type": "windows-restart"
},
{
"type": "powershell",
"inline": [ "c:\bootstrap\sysprep.ps1" ]
}
]
}

Windows update script exited with non-zero exit status: 259

First time using this provider but keep hitting a problem during everybuild.
Any suggestions please? Can see it also disscussed here but I've tried adding a reboot before and after the windows update provisioner. #3

Snipet from my build json file

Everything before this works fine.
{
"type": "windows-restart"
},
{
"type": "windows-update",
"filters": [
"exclude:$.Title -like 'Preview'",
"include:$
.Title -like 'Cumulative Update for Windows'",
"include:$.Title -like 'Recommended'",
"include:$
.AutoSelectOnWebSites"
]
},
{
"type": "windows-restart"
},
{
"type": "powershell",
"inline": [
"C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeDisks.ps1 -Schedule",
"C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1 -Schedule",
"C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\SysprepInstance.ps1 -noshutdown"
]
}
]

20:35:11 ==> amazon-ebs: Uploading the Windows update elevated script...
20:35:14 ==> amazon-ebs: Uploading the Windows update script...
20:35:16 ==> amazon-ebs: Running Windows update...
20:35:18 amazon-ebs: #< CLIXML
20:35:18 amazon-ebs: Pending Reboot detected. Waiting for the Windows Modules Installer to exit...
20:35:33 amazon-ebs: Rebooting...
20:35:33 amazon-ebs: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 2Preparing modules for first use.0-1-1Completed-1
20:35:33 ==> amazon-ebs: Waiting for machine to restart...
20:35:33 amazon-ebs: A system shutdown is in progress.(1115)
20:36:30 amazon-ebs: EC2AMAZ-8TNC0L4 restarted.
20:36:30 amazon-ebs: #< CLIXML
20:36:30 amazon-ebs: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1
20:36:30 ==> amazon-ebs: Machine successfully restarted, moving on
20:36:30 ==> amazon-ebs: Running Windows update...
20:36:33 amazon-ebs: #< CLIXML
20:36:34 amazon-ebs: Searching for Windows updates...
20:37:04 amazon-ebs: Found Windows update (2018-09-20; 1348.38 MB): 2018-09 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4457127)
20:37:04 amazon-ebs: Found Windows update (2018-10-05; 74.93 MB): Definition Update for Windows Defender Antivirus - KB2267602 (Definition 1.277.663.0)
20:37:04 amazon-ebs: Downloading Windows updates...
20:37:49 amazon-ebs: Installing Windows updates...
21:19:34 amazon-ebs: Pending Reboot detected. Waiting for the Windows Modules Installer to exit...
21:21:45 amazon-ebs: Rebooting...
21:21:45 amazon-ebs: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 2Preparing modules for first use.0-1-1Completed-1
21:21:45 ==> amazon-ebs: Waiting for machine to restart...
21:21:45 amazon-ebs: A system shutdown is in progress.(1115)
21:23:23 amazon-ebs: EC2AMAZ-8TNC0L4 restarted.
21:23:23 amazon-ebs: #< CLIXML
21:23:23 amazon-ebs: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1
21:23:23 ==> amazon-ebs: Machine successfully restarted, moving on
21:23:23 ==> amazon-ebs: Running Windows update...
21:23:26 amazon-ebs: #< CLIXML
21:23:29 amazon-ebs: Searching for Windows updates...
21:28:23 ==> amazon-ebs: Terminating the source AWS instance...
21:30:10 ==> amazon-ebs: Cleaning up any extra volumes...
21:30:10 ==> amazon-ebs: No volumes to clean up, skipping
21:30:10 ==> amazon-ebs: Deleting temporary security group...
21:30:11 ==> amazon-ebs: Deleting temporary keypair...
21:30:11 Build 'amazon-ebs' errored: Windows update script exited with non-zero exit status: 259
21:30:11
21:30:11 ==> Some builds didn't complete successfully and had errors:
21:30:11 --> amazon-ebs: Windows update script exited with non-zero exit status: 259
21:30:11
21:30:11 ==> Builds finished but no artifacts were created.

Is it possible to supply a timeout for the entire update process?

Hello! Many provisioners in Packer support a timeout property that fails the provisioner if the process takes to long.

windows-update appears to have a restart_timeout property for waiting for restarts, but if the update process itself takes too long or hangs, there doesn't seem to be a way to detect this inside Packer.

Is there a way to timeout the overall update process, inclusive of multiple rounds of updates?

Search for Windows updates failed with 'Exception from HRESULT: 0x80072EE2'

I'm trying to use the "packer-provisioner-windows-update"-provisioner in a corporate environment:

  • User authenticated proxy server for internet access (an exception for authentcation would be possible if the packer vm ip address would be static)
  • Microsoft System Center Configuration Manager incl. WSUS
  • VMware vSphere 6.7 U2 as hypervisor

Any idea how I can get the provisioner working behind an enviroment like this? Is there anyway to grab the updates from an on-premise WSUS server?

Packer fails whilst searching for updates with exit code 16001

1536205203,,ui,say,==> amazon-ebs: Machine successfully restarted%!(PACKER_COMMA) moving on
1536205203,,ui,say,==> amazon-ebs: Uploading the Windows update elevated script...
1536205217,,ui,say,==> amazon-ebs: Uploading the Windows update script...
1536205230,,ui,say,==> amazon-ebs: Running Windows update...
1536205235,,ui,message, amazon-ebs: #< CLIXML
1536205236,,ui,message, amazon-ebs: Searching for Windows updates...
1536205296,,ui,say,==> amazon-ebs: Terminating the source AWS instance...
1536205328,,ui,say,==> amazon-ebs: Cleaning up any extra volumes...
1536205328,,ui,say,==> amazon-ebs: No volumes to clean up%!(PACKER_COMMA) skipping
1536205328,,ui,say,==> amazon-ebs: Deleting temporary security group...
1536205328,,ui,say,==> amazon-ebs: Deleting temporary keypair...
1536205328,,ui,error,Build 'amazon-ebs' errored: Windows update script exited with non-zero exit
status: 16001
1536205328,,error-count,1
1536205328,,ui,error,\n==> Some builds didn't complete successfully and had errors:
1536205328,amazon-ebs,error,Windows update script exited with non-zero exit status: 16001
1536205328,,ui,error,--> amazon-ebs: Windows update script exited with non-zero exit status: 1600
1
1536205328,,ui,say,\n==> Builds finished but no artifacts were created.

Feature request: build MacOS binary

Are there any plans to make a MacOS binary available? It would be great to be able to use this plugin to build Windows VMs in Fusion and not have to maintain update scripts or Chef recipes.

windows-update provisioner taking over 1 hour - ebs Creation failure

Tieout creating ebs
Times are packer start to windows-update - 6 mins
windows-update search/download/install (2 updates, 1400MB) 42 mins..
windows-update reboot/ install completion/check for more updates 8 mis.
sysprep 4 mins.
Stopping the source instance fails with "amazon-ebs: Error stopping instance: RequestExpired: Request has expired.
Co-incidentally just over 1 hour has expired when the build gets to the final stage.
I assume this is some form of AWS temp credential expiry.
I have tried upping the image ebs as far as a m4.x16large to see if higher network or cpu would help the speed to no avail.
Full log attached.
Is there anyway to increase a timeout

packerlog.txt

Windows update fails with exit code 259 (some of the time)

I'm not sure if you will be able to help much with this but I'm running three builds in parallel and usually one of the builds fails with the below error:

Windows update script exited with non-zero exit status: 259

In the log below the builder named "web" failed this time. Other times "files" and "tasks" builders might fail:

2017/07/14 10:56:12 ui: web: EC2AMAZ-17MJEE2 restarted.
2017/07/14 10:56:12 packer-provisioner-windows-update.exe: 2017/07/14 10:56:12 [INFO] 28 bytes written for 'stdout'
2017/07/14 10:56:12 packer-provisioner-windows-update.exe: 2017/07/14 10:56:12 [INFO] 392 bytes written for 'stderr'
2017/07/14 10:56:12 packer-provisioner-windows-update.exe: 2017/07/14 10:56:12 [INFO] RPC client: Communicator ended with: 0
2017/07/14 10:56:12 ui: web: #< CLIXML
2017/07/14 10:56:12 ui: web: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1
2017/07/14 10:56:12 packer-provisioner-windows-update.exe: 2017/07/14 10:56:12 Connected to machine
2017/07/14 10:56:12 ui: ==> web: Machine successfully restarted, moving on
2017/07/14 10:56:12 ui: ==> web: Running Windows update...
2017/07/14 10:56:12 packer.exe: 2017/07/14 10:56:12 [INFO] starting remote command: PowerShell -ExecutionPolicy Bypass -OutputFormat Text -File C:/Windows/Temp/packer-windows-update-elevated.ps1
2017/07/14 10:56:15 ui: web: Searching for Windows updates...
2017/07/14 10:59:23 packer.exe: 2017/07/14 10:59:23 [INFO] command 'PowerShell -ExecutionPolicy Bypass -OutputFormat Text -File C:/Windows/Temp/packer-windows-update-elevated.ps1' exited with code: 259
2017/07/14 10:59:23 packer.exe: 2017/07/14 10:59:23 [INFO] RPC endpoint: Communicator ended with: 259
2017/07/14 10:59:23 [INFO] 34 bytes written for 'stdout'
2017/07/14 10:59:23 [INFO] RPC client: Communicator ended with: 259
2017/07/14 10:59:23 [INFO] 0 bytes written for 'stderr'
2017/07/14 10:59:23 [INFO] RPC endpoint: Communicator ended with: 259
2017/07/14 10:59:23 packer-provisioner-windows-update.exe: 2017/07/14 10:59:23 [INFO] 34 bytes written for 'stdout'
2017/07/14 10:59:23 packer-provisioner-windows-update.exe: 2017/07/14 10:59:23 [INFO] 0 bytes written for 'stderr'
2017/07/14 10:59:23 packer-provisioner-windows-update.exe: 2017/07/14 10:59:23 [INFO] RPC client: Communicator ended with: 259
2017/07/14 10:59:23 ui: ==> web: Terminating the source AWS instance...
2017/07/14 10:59:23 packer.exe: 2017/07/14 10:59:23 Waiting for state to become: terminated
2017/07/14 10:59:23 packer.exe: 2017/07/14 10:59:23 Using 2s as polling delay (change with AWS_POLL_DELAY_SECONDS)
2017/07/14 10:59:23 packer.exe: 2017/07/14 10:59:23 Allowing 300s to complete (change with AWS_TIMEOUT_SECONDS)
2017/07/14 10:59:28 ui: tasks: Installing Windows updates...
2017/07/14 11:01:41 ui: files: Pending Reboot detected. Waiting for the Windows Modules Installer to exit...
2017/07/14 11:01:45 ui: ==> web: Cleaning up any extra volumes...
2017/07/14 11:01:45 ui: ==> web: No volumes to clean up, skipping
2017/07/14 11:01:45 ui: ==> web: Deleting temporary keypair...

I've had problems in general with Packer with WinRM failing at times. It seems to randomly fail sometimes doing it. Not sure if that is related or not.

I know this is a very wooly bug report but it was mostly down to if you knew any reason why I would get a exit code of 259.

build hangs on downloading updates

Hi,

My builds are failing, they are stuck on the downloading updates stage during a 2nd windows-update run.

Packer 1.3.2
packer-builder-vsphere-clone (or vsphere-iso) 2.1
packer-provisioner-windows-update 0.6.0
Windows Server 2016

Packer build file:

{
  "provisioners": [
    {
      "type": "windows-shell",
      "scripts":[
        "./windows/scripts/2016/activate_windows.bat"
      ]
    },
    {
      "type": "windows-update"
    }
  ],

  "variables": {
    "vsphere_user": "{{env `vsphere_user`}}",
    "vsphere_pwd": "{{env `vsphere_pwd`}}"
  },

  "builders": [
    {
      "type": "vsphere-clone",
      "vcenter_server": "{{user `vsphere_host`}}",
      "username": "{{user `vsphere_user`}}",
      "password": "{{user `vsphere_pwd`}}",
      "insecure_connection": "true",

      "template": "windows-2016-base-template",
      "datacenter": "{{ user `datacenter`}}",

      "vm_name": "windows-2016-std_template_{{isotime \"20060102\"}}",
      "cluster": "{{ user `cluster`}}",
      "datastore": "{{ user `datastore`}}",

      "communicator": "winrm",
      "winrm_username": "Administrator",
      "winrm_password": "",
      "shutdown_command": "c:\\Windows\\System32\\Sysprep\\sysprep.exe /generalize /oobe /mode:vm /shutdown /unattend:c:\\unattend.xml",

     "folder": "Templates",
     "convert_to_template": "true"
    }
  ]
}

Relevant part of the build output:

==> vsphere-clone: Uploading the Windows update elevated script...
==> vsphere-clone: Uploading the Windows update check for reboot required elevated script...
==> vsphere-clone: Uploading the Windows update script...
==> vsphere-clone: Running Windows update...
    vsphere-clone: Searching for Windows updates...
    vsphere-clone: Found Windows update (2018-05-17; 1273,25 MB): 2018-05 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4103720)
    vsphere-clone: Found Windows update (2018-05-17; 11,43 MB): 2018-05 Update for Windows Server 2016 for x64-based Systems (KB4132216)
    vsphere-clone: Found Windows update (2018-11-13; 46,5 MB): Windows Malicious Software Removal Tool x64 - November 2018 (KB890830)
    vsphere-clone: Found Windows update (2018-11-26; 162,45 MB): Definition Update for Windows Defender Antivirus - KB2267602 (Definition 1.281.855.0)
    vsphere-clone: Downloading Windows updates (4 updates; 1493,64 MB)...
    vsphere-clone: Installing Windows updates...
    vsphere-clone: Waiting for the Windows Modules Installer to exit...
==> vsphere-clone: Waiting for machine to restart...
    vsphere-clone: A system shutdown is in progress.(1115)
    vsphere-clone: A system shutdown is in progress.(1115)
    vsphere-clone: A system shutdown is in progress.(1115)
    vsphere-clone: A system shutdown is in progress.(1115)
    vsphere-clone: A system shutdown is in progress.(1115)
    vsphere-clone: Waiting for the Windows Modules Installer to exit...
    vsphere-clone: xxx-44J057R restarted.
==> vsphere-clone: Machine successfully restarted, moving on
==> vsphere-clone: Running Windows update...
    vsphere-clone: Searching for Windows updates...
    vsphere-clone: Found Windows update (2018-09-13; 1,06 MB): 2018-09 Update for Windows Server 2016 for x64-based Systems (KB4091664)
    vsphere-clone: Found Windows update (2018-10-22; 5,64 MB): Update for Windows Defender Antivirus antimalware platform - KB4052623 (Version 4.18.1810.5)
    vsphere-clone: Found Windows update (2018-11-13; 1377,07 MB): 2018-11 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4467691)
    vsphere-clone: Found Windows update (2018-11-13; 11,43 MB): 2018-11 Update for Windows Server 2016 for x64-based Systems (KB4465659)
    vsphere-clone: Downloading Windows updates (4 updates; 1395,21 MB)...
ERROR: Job failed: execution took longer than 6h0m0s seconds

Unable to apply "Feature update to Windows 10, version 1909"

I was using the below code for applying updates to Windows 10. It was able to apply all the security updates, except the "Feature update to Windows 10, version 1909". Is there an option to include the feature updates as well ?

{
"provisioners": [
{
"type": "windows-update",
"search_criteria": "IsInstalled=0",
"filters": [
"exclude:$_.Title -like 'Preview'",
"include:$true"
],
"update_limit": 25
}
]
}

Packer template validation fails with: Incompatible API version

Using a Packer template with Azure provisioners, validation of the plugin fails with the following error:

Failed to initialize build 'azure-arm': error initializing provisioner 'windows-update': Incompatible API version with plugin. Plugin version: 4, Ours: 5

Have installed the plugin via Chocolatey and using the following in the template:

        {
            "type": "windows-update",
            "search_criteria": "IsInstalled=0",
            "filters": [
                "exclude:$_.Title -like '*Silverlight*'",
                "include:$true"
            ],
            "update_limit": 25
        }

Waiting for the Windows Modules Installer to exit

Hey there,

I'm encountering an odd behaviour with packer stuck after the update-process...

Code:

{
    "type": "windows-update",
    "search_criteria": "IsInstalled=0"
  },

Log:

==> vsphere-iso: Uploading the Windows update elevated script...
==> vsphere-iso: Uploading the Windows update check for reboot required elevated script...
==> vsphere-iso: Uploading the Windows update script...
==> vsphere-iso: Running Windows update...
    vsphere-iso: Searching for Windows updates...
    vsphere-iso: Waiting for operation to complete (system performance: 14% cpu; 34% memory)...
    vsphere-iso: Found Windows update (2018-11-29; 9.24 MB): Security Update for Microsoft Visual C++ 2008 Service Pack 1 Redistributable Package (KB2538243)
    vsphere-iso: Found Windows update (2019-05-27; 20.72 MB): Update for Adobe Flash Player for Windows Server 2019 (1809) for x64-based Systems (KB4462930)
    vsphere-iso: Found Windows update (2019-06-12; 20.74 MB): 2019-06 Security Update for Adobe Flash Player for Windows Server 2019 for x64-based Systems (KB4503308)
    vsphere-iso: Found Windows update (2019-06-17; 44.52 MB): Windows Malicious Software Removal Tool x64 - June 2019 (KB890830)
    vsphere-iso: Found Windows update (2019-07-10; 13.45 MB): 2019-07 Servicing Stack Update for Windows Server 2019 for x64-based Systems (KB4509095)
    vsphere-iso: Found Windows update (2019-07-10; 63.01 MB): 2019-07 Cumulative Update for .NET Framework 3.5, 4.7.2, 4.8 on Windows Server 2019 for x64 (KB4507419)
    vsphere-iso: Found Windows update (2019-07-10; 256.92 MB): 2019-07 Cumulative Update for Windows Server 2019 for x64-based Systems (KB4507469)
    vsphere-iso: Downloading Windows updates (7 updates; 428.6 MB)...
    vsphere-iso: Waiting for operation to complete (system performance: 5% cpu; 31% memory)...
    vsphere-iso: Installing Windows updates...
    vsphere-iso: Waiting for operation to complete (system performance: 15% cpu; 36% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 19% cpu; 36% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 20% cpu; 39% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 27% cpu; 48% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 14% cpu; 48% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 12% cpu; 49% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 4% cpu; 51% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 5% cpu; 52% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 30% cpu; 51% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 7% cpu; 55% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 13% cpu; 51% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 6% cpu; 49% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 5% cpu; 47% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 12% cpu; 46% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 5% cpu; 54% memory)...
    vsphere-iso: Waiting for the Windows Modules Installer to exit...
    vsphere-iso: Waiting for operation to complete (system performance: 2% cpu; 44% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 1% cpu; 43% memory)...
    vsphere-iso: Waiting for operation to complete (system performance: 1% cpu; 43% memory)...

Obviously packer is waiting "for the Windows Modules Installer to exit". On the VM this process ("tiworker.exe") goes into idle after updating and will not exit.

After manually killing the process on the VM packer moves on with the next provisioner, so it's definitely this specific process on the Windows Server 2019 guest.

Am I missing something in my code/settings so the provisioning gets stuck? Maybe someone can help =)

Software:

  • vSphere 6.0
  • packer 1.4.2
  • packer-builder-vsphere plugin v2.3
  • guest OS: Windows Server 2019 (installed via autounattend.xml)

Thx!

Not able to create `Windows-Server-Core-2016-1809` image!

I am trying to create Windows-Server-Core-2016-1809 image but getting below errors any suggestions -
windows-server-core-2016
windows-server-core-2016-2

I have found other solutions https://support.microsoft.com/en-us/help/900936/error-code-0x8024402c-when-you-try-to-install-updates-on-windows-updat here but it doesn't help!

I didn't use any packer template just used PowerShell script

Updates not being applied

Packer: v1.4.3
Packer-provisioner-windows-update: v0.7.1

My packer json template:

{
  "builders": [{
    "type": "vmware-iso",
    "vm_name": "{{ user `vm_name` }}",
    "vmdk_name": "{{ user `vm_name` }}",
    "output_directory": "{{ user `output_directory`}}",
    "iso_url": "{{ user `iso_url` }}",
    "iso_checksum": "{{user `iso_checksum`}}",
    "iso_checksum_type": "{{ user `iso_checksum_type` }}",
    "communicator": "winrm",
    "winrm_username": "administrator",
    "winrm_password": "password",
    "winrm_timeout": "12h",
    "winrm_port": "5985",
    "vnc_port_min": 5900,
    "vnc_port_max": 5980,
    "shutdown_command": "a:/Start-Shutdown.bat",
    "shutdown_timeout": "15m",
    "headless": "{{ user `vmWareBuilder_headless` }}",
    "guest_os_type": "{{ user `guest_os_type` }}",
    "disk_size": "50000",
    "keep_registered": false,
    "skip_validate_credentials": true,
    "version": "14",
    "floppy_files": [
      "extra/files/win2016/autounattend.xml",
      "extra/scripts/bootstrap.ps1",
      "extra/scripts/Start-Shutdown.bat"
    ],
    "floppy_dirs": [
      "extra/files/vmwareTools/drivers"
    ],
    "network": "{{ user `vmWareBuilder_network` }}",
    "cpus": 2,
    "memory": 4096,
    "boot_wait": "10s",
    "vmx_data": {
      "scsi0.virtualDev": "pvscsi",
      "annotation": "{{ user `vmWareBuilder_annotation` }}"
    }
  }],
  "provisioners": [
    {
      "type": "windows-update",
      "filters": [
          "include:$_.Title -like '*Servicing Stack Update for Windows*'"
      ]
    },
    {
      "type": "windows-update"
    },
    {
      "type": "powershell",
      "inline": [
        "Write-Output Phase-5-Deprovisioning",
        "if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}"
      ]
    },
    {
      "type": "windows-restart",
      "restart_timeout": "2h",
      "pause_before": "30s",
      "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
    }
  ]
}

I am trying to create a very basic image, that is nothing but a base Windows 2016 with the most recent patches, and nothing else.

When this runs, the first windows update is executed properly as evidenced by the following log:

019/09/27 10:01:20 packer.exe: 2019/09/27 10:01:20 Running the provision hook
2019/09/27 10:01:20 [INFO] (telemetry) Starting provisioner windows-update
2019/09/27 10:01:20 ui: �[1;32m==> vmware-iso: Uploading the Windows update elevated script...�[0m
2019/09/27 10:01:20 packer-provisioner-windows-update.exe: 2019/09/27 10:01:20 [INFO] 3898 bytes written for 'uploadData'
2019/09/27 10:01:20 [INFO] 3898 bytes written for 'uploadData'
2019/09/27 10:01:20 packer.exe: 2019/09/27 10:01:20 Uploading file to 'C:/Windows/Temp/packer-windows-update-elevated.ps1'
2019/09/27 10:01:21 packer.exe: #< CLIXML
2019/09/27 10:01:22 packer.exe: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 #< CLIXML
2019/09/27 10:01:22 ui: �[1;32m==> vmware-iso: Uploading the Windows update check for reboot required elevated script...�[0m
2019/09/27 10:01:22 packer-provisioner-windows-update.exe: 2019/09/27 10:01:22 [INFO] 3767 bytes written for 'uploadData'
2019/09/27 10:01:22 [INFO] 3767 bytes written for 'uploadData'
2019/09/27 10:01:22 packer.exe: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 2019/09/27 10:01:22 Uploading file to 'C:/Windows/Temp/packer-windows-update-pending-reboot-elevated.ps1'
2019/09/27 10:01:23 packer.exe: #< CLIXML
2019/09/27 10:01:23 packer.exe: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 #< CLIXML
2019/09/27 10:01:23 ui: �[1;32m==> vmware-iso: Uploading the Windows update script...�[0m
2019/09/27 10:01:23 packer-provisioner-windows-update.exe: 2019/09/27 10:01:23 [INFO] 9281 bytes written for 'uploadData'
2019/09/27 10:01:23 [INFO] 9281 bytes written for 'uploadData'
2019/09/27 10:01:23 packer.exe: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 2019/09/27 10:01:23 Uploading file to 'C:/Windows/Temp/packer-windows-update.ps1'
2019/09/27 10:01:25 packer.exe: #< CLIXML
2019/09/27 10:01:25 packer.exe: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 #< CLIXML
2019/09/27 10:01:25 ui: �[1;32m==> vmware-iso: Running Windows update...�[0m
2019/09/27 10:01:25 packer.exe: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 2019/09/27 10:01:25 [INFO] starting remote command: PowerShell -ExecutionPolicy Bypass -OutputFormat Text -File C:/Windows/Temp/packer-windows-update-elevated.ps1
2019/09/27 10:01:32 ui: �[0;32m vmware-iso: Searching for Windows updates...�[0m
2019/09/27 10:02:29 ui: �[0;32m vmware-iso: Waiting for operation to complete (system performance: 1 % cpu; 28 % memory)...�[0m
2019/09/27 10:03:31 ui: �[0;32m vmware-iso: Waiting for operation to complete (system performance: 1 % cpu; 28 % memory)...�[0m
2019/09/27 10:04:33 ui: �[0;32m vmware-iso: Waiting for operation to complete (system performance: 54 % cpu; 38 % memory)...�[0m
2019/09/27 10:05:34 ui: �[0;32m vmware-iso: Skipped (filter) Windows update (2018-05-17; 1273.25 MB): 2018-05 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4103720)�[0m
2019/09/27 10:05:35 ui: �[0;32m vmware-iso: Skipped (filter) Windows update (2019-08-13; 44.17 MB): Windows Malicious Software Removal Tool x64 - August 2019 (KB890830)�[0m
2019/09/27 10:05:35 ui: �[0;32m vmware-iso: Found Windows update (2019-09-10; 11.52 MB): 2019-09 Servicing Stack Update for Windows Server 2016 for x64-based Systems (KB4512574)�[0m
2019/09/27 10:05:35 ui: �[0;32m vmware-iso: Skipped (filter) Windows update (2019-09-27; 97.71 MB): Security Intelligence Update for Windows Defender Antivirus - KB2267602 (Version 1.303.295.0)�[0m
2019/09/27 10:05:35 ui: �[0;32m vmware-iso: Downloading Windows updates (1 updates; 11.52 MB)...�[0m
2019/09/27 10:05:38 ui: �[0;32m vmware-iso: Waiting for operation to complete (system performance: 100 % cpu; 27 % memory)...�[0m
2019/09/27 10:06:28 ui: �[0;32m vmware-iso: Installing Windows updates...�[0m
2019/09/27 10:06:41 ui: �[0;32m vmware-iso: Waiting for operation to complete (system performance: 46 % cpu; 30 % memory)...�[0m
2019/09/27 10:06:45 packer.exe: 2019/09/27 10:06:45 [INFO] command 'PowerShell -ExecutionPolicy Bypass -OutputFormat Text -File C:/Windows/Temp/packer-windows-update-elevated.ps1' exited with code: 0

But the subsequent windows update, doesn't seem to do everything it's supposed to do. It outputs that it is "searching", but never sends the names of the updates it found, or the "Downloading Windows updates" and "Installing Windows updates" messages. Here is the log for the second windows update attempt:

2019/09/27 10:06:45 [INFO] (telemetry) Starting provisioner windows-update
2019/09/27 10:06:45 ui: �[1;32m==> vmware-iso: Uploading the Windows update elevated script...�[0m
2019/09/27 10:06:45 packer-provisioner-windows-update.exe: 2019/09/27 10:06:45 [INFO] 3954 bytes written for 'uploadData'
2019/09/27 10:06:45 [INFO] 3954 bytes written for 'uploadData'
2019/09/27 10:06:45 packer.exe: 2019/09/27 10:06:45 Uploading file to 'C:/Windows/Temp/packer-windows-update-elevated.ps1'
2019/09/27 10:06:46 packer.exe: #< CLIXML
2019/09/27 10:06:46 packer.exe: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 #< CLIXML
2019/09/27 10:06:46 ui: �[1;32m==> vmware-iso: Uploading the Windows update check for reboot required elevated script...�[0m
2019/09/27 10:06:46 packer-provisioner-windows-update.exe: 2019/09/27 10:06:46 [INFO] 3767 bytes written for 'uploadData'
2019/09/27 10:06:46 [INFO] 3767 bytes written for 'uploadData'
2019/09/27 10:06:46 packer.exe: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 2019/09/27 10:06:46 Uploading file to 'C:/Windows/Temp/packer-windows-update-pending-reboot-elevated.ps1'
2019/09/27 10:06:47 packer.exe: #< CLIXML
2019/09/27 10:06:47 packer.exe: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 #< CLIXML
2019/09/27 10:06:47 ui: �[1;32m==> vmware-iso: Uploading the Windows update script...�[0m
2019/09/27 10:06:47 packer-provisioner-windows-update.exe: 2019/09/27 10:06:47 [INFO] 9281 bytes written for 'uploadData'
2019/09/27 10:06:47 [INFO] 9281 bytes written for 'uploadData'
2019/09/27 10:06:47 packer.exe: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 2019/09/27 10:06:47 Uploading file to 'C:/Windows/Temp/packer-windows-update.ps1'
2019/09/27 10:06:48 packer.exe: #< CLIXML
2019/09/27 10:06:48 packer.exe: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 #< CLIXML
2019/09/27 10:06:48 ui: �[1;32m==> vmware-iso: Running Windows update...�[0m
2019/09/27 10:06:48 packer.exe: System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first use.0-1-1Completed-1 2019/09/27 10:06:48 [INFO] starting remote command: PowerShell -ExecutionPolicy Bypass -OutputFormat Text -File C:/Windows/Temp/packer-windows-update-elevated.ps1
2019/09/27 10:06:54 ui: �[0;32m vmware-iso: Searching for Windows updates...�[0m
2019/09/27 10:07:52 ui: �[0;32m vmware-iso: Waiting for operation to complete (system performance: 90 % cpu; 53 % memory)...�[0m
2019/09/27 10:08:56 ui: �[0;32m vmware-iso: Waiting for operation to complete (system performance: 68 % cpu; 93 % memory)...�[0m
2019/09/27 10:10:01 ui: �[0;32m vmware-iso: Waiting for operation to complete (system performance: 83 % cpu; 92 % memory)...�[0m
2019/09/27 10:11:04 ui: �[0;32m vmware-iso: Waiting for operation to complete (system performance: 97 % cpu; 89 % memory)...�[0m
2019/09/27 10:12:09 ui: �[0;32m vmware-iso: Waiting for operation to complete (system performance: 61 % cpu; 93 % memory)...�[0m
2019/09/27 10:13:13 ui: �[0;32m vmware-iso: Waiting for operation to complete (system performance: 63 % cpu; 92 % memory)...�[0m
2019/09/27 10:14:15 ui: �[0;32m vmware-iso: Waiting for operation to complete (system performance: 36 % cpu; 98 % memory)...�[0m
2019/09/27 10:15:18 ui: �[0;32m vmware-iso: Waiting for operation to complete (system performance: 51 % cpu; 99 % memory)...�[0m
2019/09/27 10:20:48 packer.exe: 2019/09/27 10:20:48 [INFO] command 'PowerShell -ExecutionPolicy Bypass -OutputFormat Text -File C:/Windows/Temp/packer-windows-update-elevated.ps1' exited with code: 0

After this, it exits the provisioner and continues on the packer process as if there was no issue.

When I bring up the completed VM afterwards, I see that the only update applied was the "Servicing Stack Update for Windows Server 2016 for x64-based Systems (KB4512574)" and all the other updates are still not done.

updatesAvailable

updateHistory

Do I have my packer template incorrectly configured for using this provisioner?

ERROR: Value does not fall within the expected range.

Hello,
I have being experiencing some issues while performing windows updates in a Win7 azure-arm type builder.
Actual result
ERROR: Value does not fall within the expected range.
Expected result
The windows updates should be applied without errors

My template:
packer v1.3.1
windows-update v0.6.0

{
  "variables": {
    "client_id": "{{env `CLIENT_ID`}}",
    "client_secret": "{{env `CLIENT_SECRET`}}",
    "resource_group": "{{env `RESOURCE_GROUP`}}",
    "storage_account": "{{env `STORAGE_ACCOUNT`}}",
    "subscription_id": "{{env `SUBSCRIPTION_ID`}}",
    "vm_size": "{{env `VM_SIZE`}}",
    "saPwd": "{{env `SA_PWD`}}",
    "admin_username": "{{env `ADMIN_USERNAME`}}",
    "location": "{{env `LOCATION`}}",
    "script_folder": "{{env `SCRIPT_FOLDER`}}"
  },
  "builders": [
    {
      "type": "azure-arm",
      "client_id": "{{user `client_id`}}",
      "client_secret": "{{user `client_secret`}}",
      "resource_group_name": "{{user `resource_group`}}",
      "storage_account": "{{user `storage_account`}}",
      "subscription_id": "{{user `subscription_id`}}",
      "capture_container_name": "custom-vhd-images",
      "capture_name_prefix": "packer",
      "os_type": "Windows",
      "image_publisher": "microsoftvisualstudio",
      "image_offer": "Windows",
      "image_sku": "Win7-SP1-Ent-N-x64",
      "communicator": "winrm",
      "winrm_use_ssl": "true",
      "winrm_insecure": "true",
      "winrm_timeout": "4h",
      "winrm_username": "{{user `admin_username`}}",
      "vm_size": "{{user `vm_size`}}",
      "location": "{{user `location`}}"
    }
  ],
  "provisioners": [
    {
      "type": "powershell",
      "inline":[
        "Get-Date"
      ]
    },
    {
      "type": "windows-update"
    },
    {
      "type": "windows-restart",
      "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
    },
    {
      "type": "powershell",
      "inline": [
        "if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}",
        "& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit",
        "while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10  } else { break } }"
      ]
    }
  ]
}

And the output logs

2018-10-24T01:22:08.8852308Z 
2018-10-24T01:22:08.8888294Z ##[debug]Parsing log line to extract output...
2018-10-24T01:22:08.8889802Z ##[debug]/*************************************
2018-10-24T01:22:08.8891350Z ##[debug]    azure-arm: WinRM connected.

2018-10-24T01:22:08.8892317Z ##[debug]**************************************/
2018-10-24T01:22:08.8893312Z ##[debug]Match start index: -1
2018-10-24T01:22:08.8894477Z ##[debug]Match start index: -1
2018-10-24T01:22:08.8917546Z     azure-arm: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>
2018-10-24T01:22:09.8198372Z 
2018-10-24T01:22:09.8203792Z ##[debug]Parsing log line to extract output...
2018-10-24T01:22:09.8205382Z ##[debug]/*************************************
2018-10-24T01:22:09.8207505Z ##[debug]    azure-arm: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>

2018-10-24T01:22:09.8209534Z ##[debug]**************************************/
2018-10-24T01:22:09.8210313Z ##[debug]Match start index: -1
2018-10-24T01:22:09.8211106Z ##[debug]Match start index: -1
2018-10-24T01:22:09.8211666Z ==> azure-arm: Connected to WinRM!
2018-10-24T01:22:09.8212007Z 
2018-10-24T01:22:09.8212678Z ##[debug]Parsing log line to extract output...
2018-10-24T01:22:09.8213521Z ##[debug]/*************************************
2018-10-24T01:22:09.8214371Z ##[debug]==> azure-arm: Connected to WinRM!

2018-10-24T01:22:09.8215924Z ##[debug]**************************************/
2018-10-24T01:22:09.8216637Z ##[debug]Match start index: -1
2018-10-24T01:22:09.8217269Z ##[debug]Match start index: -1
2018-10-24T01:22:09.8217756Z ==> azure-arm: Provisioning with Powershell...
2018-10-24T01:22:09.8218071Z 
2018-10-24T01:22:09.8218700Z ##[debug]Parsing log line to extract output...
2018-10-24T01:22:09.8219403Z ##[debug]/*************************************
2018-10-24T01:22:09.8220149Z ##[debug]==> azure-arm: Provisioning with Powershell...

2018-10-24T01:22:09.8220886Z ##[debug]**************************************/
2018-10-24T01:22:09.8221565Z ##[debug]Match start index: -1
2018-10-24T01:22:09.8222190Z ##[debug]Match start index: -1
2018-10-24T01:22:09.8222823Z ==> azure-arm: Provisioning with powershell script: C:\Users\FABuild\AppData\Local\Temp\packer-powershell-provisioner081654639
2018-10-24T01:22:09.8223254Z 
2018-10-24T01:22:09.8223888Z ##[debug]Parsing log line to extract output...
2018-10-24T01:22:09.8224599Z ##[debug]/*************************************
2018-10-24T01:22:09.8225475Z ##[debug]==> azure-arm: Provisioning with powershell script: C:\Users\FABuild\AppData\Local\Temp\packer-powershell-provisioner081654639

2018-10-24T01:22:09.8227702Z ##[debug]**************************************/
2018-10-24T01:22:09.8228359Z ##[debug]Match start index: -1
2018-10-24T01:22:09.8229211Z ##[debug]Match start index: -1
2018-10-24T01:22:19.5118218Z     azure-arm:
2018-10-24T01:22:19.5119470Z 
2018-10-24T01:22:19.5122541Z ##[debug]Parsing log line to extract output...
2018-10-24T01:22:19.5125080Z ##[debug]/*************************************
2018-10-24T01:22:19.5127713Z ##[debug]    azure-arm:

2018-10-24T01:22:19.5131416Z ##[debug]**************************************/
2018-10-24T01:22:19.5133020Z ##[debug]Match start index: -1
2018-10-24T01:22:19.5134294Z ##[debug]Match start index: -1
2018-10-24T01:22:19.5300038Z     azure-arm: Wednesday, October 24, 2018 1:22:19 AM
2018-10-24T01:22:19.5301127Z ==> azure-arm: Uploading the Windows update elevated script...
2018-10-24T01:22:19.5301678Z 
2018-10-24T01:22:19.5303954Z ##[debug]Parsing log line to extract output...
2018-10-24T01:22:19.5304757Z ##[debug]/*************************************
2018-10-24T01:22:19.5305729Z ##[debug]    azure-arm: Wednesday, October 24, 2018 1:22:19 AM
==> azure-arm: Uploading the Windows update elevated script...

2018-10-24T01:22:19.5306726Z ##[debug]**************************************/
2018-10-24T01:22:19.5307405Z ##[debug]Match start index: -1
2018-10-24T01:22:19.5308047Z ##[debug]Match start index: -1
2018-10-24T01:22:23.7977814Z ==> azure-arm: Uploading the Windows update check for reboot required elevated script...
2018-10-24T01:22:23.7979253Z 
2018-10-24T01:22:23.7980728Z ##[debug]Parsing log line to extract output...
2018-10-24T01:22:23.7982153Z ##[debug]/*************************************
2018-10-24T01:22:23.7983868Z ##[debug]==> azure-arm: Uploading the Windows update check for reboot required elevated script...

2018-10-24T01:22:23.7986426Z ##[debug]**************************************/
2018-10-24T01:22:23.7988688Z ##[debug]Match start index: -1
2018-10-24T01:22:23.7989566Z ##[debug]Match start index: -1
2018-10-24T01:22:25.8331890Z ==> azure-arm: Uploading the Windows update script...
2018-10-24T01:22:25.8332572Z 
2018-10-24T01:22:25.8333646Z ##[debug]Parsing log line to extract output...
2018-10-24T01:22:25.8334611Z ##[debug]/*************************************
2018-10-24T01:22:25.8338858Z ##[debug]==> azure-arm: Uploading the Windows update script...

2018-10-24T01:22:25.8341847Z ##[debug]**************************************/
2018-10-24T01:22:25.8342865Z ##[debug]Match start index: -1
2018-10-24T01:22:25.8344132Z ##[debug]Match start index: -1
2018-10-24T01:22:27.7959273Z ==> azure-arm: Running Windows update...
2018-10-24T01:22:27.7960435Z 
2018-10-24T01:22:27.7962054Z ##[debug]Parsing log line to extract output...
2018-10-24T01:22:27.7963678Z ##[debug]/*************************************
2018-10-24T01:22:27.7965399Z ##[debug]==> azure-arm: Running Windows update...

2018-10-24T01:22:27.7967272Z ##[debug]**************************************/
2018-10-24T01:22:27.7968471Z ##[debug]Match start index: -1
2018-10-24T01:22:27.7970253Z ##[debug]Match start index: -1
2018-10-24T01:22:33.0899294Z     azure-arm: Searching for Windows updates...
2018-10-24T01:22:33.0900706Z 
2018-10-24T01:22:33.0902424Z ##[debug]Parsing log line to extract output...
2018-10-24T01:22:33.0903416Z ##[debug]/*************************************
2018-10-24T01:22:33.0904384Z ##[debug]    azure-arm: Searching for Windows updates...

2018-10-24T01:22:33.0905128Z ##[debug]**************************************/
2018-10-24T01:22:33.0905805Z ##[debug]Match start index: -1
2018-10-24T01:22:33.0906429Z ##[debug]Match start index: -1
2018-10-24T01:37:10.5822659Z     azure-arm: Found Windows update (2018-10-21; 12.23 MB): Definition Update for Windows Defender Antivirus - KB915597 (Definition 1.279.208.0)
2018-10-24T01:37:10.5824221Z 
2018-10-24T01:37:10.5825926Z ##[debug]Parsing log line to extract output...
2018-10-24T01:37:10.5826857Z ##[debug]/*************************************
2018-10-24T01:37:10.5827779Z ##[debug]    azure-arm: Found Windows update (2018-10-21; 12.23 MB): Definition Update for Windows Defender Antivirus - KB915597 (Definition 1.279.208.0)

2018-10-24T01:37:10.5829889Z ##[debug]**************************************/
2018-10-24T01:37:10.5830744Z ##[debug]Match start index: -1
2018-10-24T01:37:10.5831428Z ##[debug]Match start index: -1
2018-10-24T01:37:10.5837678Z     azure-arm: Downloading Windows updates (1 updates; 12.23 MB)...
2018-10-24T01:37:10.5838990Z 
2018-10-24T01:37:10.5840565Z ##[debug]Parsing log line to extract output...
2018-10-24T01:37:10.5841455Z ##[debug]/*************************************
2018-10-24T01:37:10.5842257Z ##[debug]    azure-arm: Downloading Windows updates (1 updates; 12.23 MB)...

2018-10-24T01:37:10.5843033Z ##[debug]**************************************/
2018-10-24T01:37:10.5843705Z ##[debug]Match start index: -1
2018-10-24T01:37:10.5844344Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8730741Z     azure-arm: ERROR: Value does not fall within the expected range.
2018-10-24T01:37:10.8732401Z 
2018-10-24T01:37:10.8733895Z ##[debug]Parsing log line to extract output...
2018-10-24T01:37:10.8734915Z ##[debug]/*************************************
2018-10-24T01:37:10.8736734Z ##[debug]    azure-arm: ERROR: Value does not fall within the expected range.

2018-10-24T01:37:10.8738421Z ##[debug]**************************************/
2018-10-24T01:37:10.8739518Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8740612Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8741732Z     azure-arm: ERROR: at <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: line 195
2018-10-24T01:37:10.8742290Z 
2018-10-24T01:37:10.8743083Z ##[debug]Parsing log line to extract output...
2018-10-24T01:37:10.8743978Z ##[debug]/*************************************
2018-10-24T01:37:10.8744961Z ##[debug]    azure-arm: ERROR: at <ScriptBlock>, C:\Windows\Temp\packer-windows-update.ps1: line 195

2018-10-24T01:37:10.8746419Z ##[debug]**************************************/
2018-10-24T01:37:10.8748044Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8749005Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8756199Z     azure-arm: ERROR: at <ScriptBlock>, <No file>: line 1
2018-10-24T01:37:10.8756910Z 
2018-10-24T01:37:10.8758389Z ##[debug]Parsing log line to extract output...
2018-10-24T01:37:10.8759598Z ##[debug]/*************************************
2018-10-24T01:37:10.8760877Z ##[debug]    azure-arm: ERROR: at <ScriptBlock>, <No file>: line 1

2018-10-24T01:37:10.8761881Z ##[debug]**************************************/
2018-10-24T01:37:10.8762880Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8763758Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8785947Z     azure-arm: ERROR EXCEPTION: System.ArgumentException: Value does not fall within the expected range.
2018-10-24T01:37:10.8786951Z 
2018-10-24T01:37:10.8788239Z ##[debug]Parsing log line to extract output...
2018-10-24T01:37:10.8789385Z ##[debug]/*************************************
2018-10-24T01:37:10.8791143Z ##[debug]    azure-arm: ERROR EXCEPTION: System.ArgumentException: Value does not fall within the expected range.

2018-10-24T01:37:10.8792724Z ##[debug]**************************************/
2018-10-24T01:37:10.8793929Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8795232Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8796753Z     azure-arm: ERROR EXCEPTION:    at System.Management.Automation.ComInterop.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo& excepInfo, ComMethodDesc method, Object[] args, UInt32 argErr)
2018-10-24T01:37:10.8797713Z 
2018-10-24T01:37:10.8798990Z ##[debug]Parsing log line to extract output...
2018-10-24T01:37:10.8803206Z ##[debug]/*************************************
2018-10-24T01:37:10.8804316Z ##[debug]    azure-arm: ERROR EXCEPTION:    at System.Management.Automation.ComInterop.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo& excepInfo, ComMethodDesc method, Object[] args, UInt32 argErr)

2018-10-24T01:37:10.8805633Z ##[debug]**************************************/
2018-10-24T01:37:10.8806312Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8806930Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8814610Z     azure-arm: ERROR EXCEPTION:    at CallSite.Target(Closure , CallSite , ComObject , Int32 )
2018-10-24T01:37:10.8815303Z 
2018-10-24T01:37:10.8816196Z ##[debug]Parsing log line to extract output...
2018-10-24T01:37:10.8817874Z ##[debug]/*************************************
2018-10-24T01:37:10.8819235Z ##[debug]    azure-arm: ERROR EXCEPTION:    at CallSite.Target(Closure , CallSite , ComObject , Int32 )

2018-10-24T01:37:10.8824818Z ##[debug]**************************************/
2018-10-24T01:37:10.8826268Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8827155Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8828397Z     azure-arm: ERROR EXCEPTION:    at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
2018-10-24T01:37:10.8831949Z 
2018-10-24T01:37:10.8834859Z ##[debug]Parsing log line to extract output...
2018-10-24T01:37:10.8836223Z ##[debug]/*************************************
2018-10-24T01:37:10.8837425Z ##[debug]    azure-arm: ERROR EXCEPTION:    at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)

2018-10-24T01:37:10.8838494Z ##[debug]**************************************/
2018-10-24T01:37:10.8839469Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8840527Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8841389Z     azure-arm: ERROR EXCEPTION:    at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
2018-10-24T01:37:10.8841954Z 
2018-10-24T01:37:10.8842765Z ##[debug]Parsing log line to extract output...
2018-10-24T01:37:10.8843654Z ##[debug]/*************************************
2018-10-24T01:37:10.8844715Z ##[debug]    azure-arm: ERROR EXCEPTION:    at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)

2018-10-24T01:37:10.8845793Z ##[debug]**************************************/
2018-10-24T01:37:10.8846623Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8847515Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8848516Z     azure-arm: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
2018-10-24T01:37:10.8849166Z 
2018-10-24T01:37:10.8850576Z ##[debug]Parsing log line to extract output...
2018-10-24T01:37:10.8851522Z ##[debug]/*************************************
2018-10-24T01:37:10.8852574Z ##[debug]    azure-arm: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)

2018-10-24T01:37:10.8853592Z ##[debug]**************************************/
2018-10-24T01:37:10.8867482Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8869283Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8906351Z     azure-arm: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2018-10-24T01:37:10.8907207Z 
2018-10-24T01:37:10.8913644Z ##[debug]Parsing log line to extract output...
2018-10-24T01:37:10.8916114Z ##[debug]/*************************************
2018-10-24T01:37:10.8917565Z ##[debug]    azure-arm: ERROR EXCEPTION:    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

2018-10-24T01:37:10.8918724Z ##[debug]**************************************/
2018-10-24T01:37:10.8920154Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8921266Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8935379Z ==> azure-arm: 
2018-10-24T01:37:10.8935971Z 
2018-10-24T01:37:10.8937119Z ##[debug]Parsing log line to extract output...
2018-10-24T01:37:10.8953881Z ##[debug]/*************************************
2018-10-24T01:37:10.8954623Z ##[debug]==> azure-arm: 

2018-10-24T01:37:10.8955314Z ##[debug]**************************************/
2018-10-24T01:37:10.8956311Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8956956Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8957441Z ==> azure-arm: Cleanup requested, deleting resource group ...
2018-10-24T01:37:10.8957907Z 
2018-10-24T01:37:10.8958550Z ##[debug]Parsing log line to extract output...
2018-10-24T01:37:10.8959414Z ##[debug]/*************************************
2018-10-24T01:37:10.8960185Z ##[debug]==> azure-arm: Cleanup requested, deleting resource group ...

2018-10-24T01:37:10.8960907Z ##[debug]**************************************/
2018-10-24T01:37:10.8961572Z ##[debug]Match start index: -1
2018-10-24T01:37:10.8962212Z ##[debug]Match start index: -1
2018-10-24T01:41:46.5541340Z ==> azure-arm: Resource group has been deleted.
2018-10-24T01:41:46.5542779Z ```

Skipped / Filtered Updates

Firstly thank you for a great provisioner!

I was wondering why there are certain updates skipped / filtered when using the recommended filters? I am getting the following: -

Skipped (filter) Windows update (2018-09-13; 1.06 MB): 2018-09 Update for Windows Server 2016 (1803) for x64-based Systems (KB4100347)

When using the following filters: -

    {
      "type": "windows-update",
      "update_limit": "20",
      "filters": [
        "exclude:$_.Title -like '*Preview*'",
        "include:$_.Title -like '*Cumulative Update for Windows*'",
        "include:$_.AutoSelectOnWebSites"
      ]
    }

It did not appear to be a '*Preview*' update so was windering why it got filtered.

Thanks again!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.