I am trying to get the famous windows updates working in 2012. for 2012r2, all went fine, just installed some power shell libraries I found and ran this:
- all worked fine, fully tested.
Tried on 2012, thought it would be fine - indeed not. after a LOT of faffing about it, it turns out the scheduled task that is created is too big for windows to run it, it just says the scheduled task no longer exists. If you look at the actual task the string it runs is a massive string of base 64 (don't know why but I am sure there is a reason!) - decode this and it's a massive string of variables followed by a path to the actual power shell... It turns out, if I half the base 64, windows let's it run - so the issue seems to be the length of the code in the scheduled task. Can't find anything about this being a a known issue.
Anyway...
I have tried to make things as short as possible, hence the c:/a/1.ps1. This is really annoying because it's a really eligantt solution for 20212r2 but just doesn't work in 2012, anyone know of this, or has any ideas how I can troubleshoot it?
==> vmware-iso: Provisioning with Powershell...
2017/08/20 12:46:47 ui: ==> vmware-iso: Provisioning with Powershell...
2017/08/20 12:46:47 ui: ==> vmware-iso: Provisioning with shell script: ./scripts/windows-update-all.ps1
==> vmware-iso: Provisioning with shell script: ./scripts/windows-update-all.ps1
2017/08/20 12:46:47 packer: 2017/08/20 12:46:47 Opening ./scripts/windows-update-all.ps1 for reading
2017/08/20 12:46:47 packer: 2017/08/20 12:46:47 Building elevated command wrapper for: if (Test-Path variable:global:ProgressPreference){$ProgressPreference='SilentlyContinue'};$env:PACKER_BUILDER_TYPE="vmware-iso"; $env:PACKER_BUILD_NAME="vmware-iso"; $env:PACKER_HTTP_ADDR="
192.168.100.65:8000"; &'c:/a/1.ps1';exit $LastExitCode
2017/08/20 12:46:47 packer: 2017/08/20 12:46:47 Uploading elevated shell wrapper for command [if (Test-Path variable:global:ProgressPreference){$ProgressPreference='SilentlyContinue'};$env:PACKER_BUILDER_TYPE="vmware-iso"; $env:PACKER_BUILD_NAME="vmware-iso"; $env:PACKER_HTTP_ADDR="
192.168.100.65:8000"; &'c:/a/1.ps1';exit $LastExitCode] to [${env:TEMP}\packer-elevated-shell-5999e727-ddcf-e4d7-2216-cee952a4992d.ps1] from [/tmp/packer-elevated-shell.ps1791211094]
2017/08/20 12:46:47 packer: 2017/08/20 12:46:47 [INFO] 3016 bytes written for 'uploadData'
2017/08/20 12:46:47 [INFO] 3016 bytes written for 'uploadData'
2017/08/20 12:46:47 packer: 2017/08/20 12:46:47 Uploading file to '${env:TEMP}\packer-elevated-shell-5999e727-ddcf-e4d7-2216-cee952a4992d.ps1'
2017/08/20 12:46:48 packer: 2017/08/20 12:46:48 [INFO] 63 bytes written for 'uploadData'
2017/08/20 12:46:48 [INFO] 63 bytes written for 'uploadData'
2017/08/20 12:46:48 packer: 2017/08/20 12:46:48 Uploading file to 'c:/a/1.ps1'
2017/08/20 12:46:49 packer: 2017/08/20 12:46:49 [INFO] starting remote command: powershell -executionpolicy bypass -file "%TEMP%\packer-elevated-shell-5999e727-ddcf-e4d7-2216-cee952a4992d.ps1"
vmware-iso: Exception calling "Run" with "1" argument(s): "Could not load file or assembly
2017/08/20 12:46:50 ui: vmware-iso: Exception calling "Run" with "1" argument(s): "Could not load file or assembly
vmware-iso: 'Microsoft.PowerShell.Commands.Management' or one of its dependencies. The
2017/08/20 12:46:50 ui: vmware-iso: 'Microsoft.PowerShell.Commands.Management' or one of its dependencies. The
2017/08/20 12:46:50 ui: vmware-iso: system cannot find the file specified."
vmware-iso: system cannot find the file specified."
vmware-iso: At C:\Users\vagrant\AppData\Local\Temp\packer-elevated-shell-5999e727-ddcf-e4d7
2017/08/20 12:46:50 ui: vmware-iso: At C:\Users\vagrant\AppData\Local\Temp\packer-elevated-shell-5999e727-ddcf-e4d7
2017/08/20 12:46:50 ui: vmware-iso: -2216-cee952a4992d.ps1:51 char:1
vmware-iso: -2216-cee952a4992d.ps1:51 char:1
2017/08/20 12:46:50 ui: vmware-iso: + $t.Run($null) | Out-Null
vmware-iso: + $t.Run($null) | Out-Null
2017/08/20 12:46:50 ui: vmware-iso: + ~~~~~~~~~~~~~~~~~~~~~~~~
vmware-iso: + ~~~~~~~~~~~~~~~~~~~~~~~~
2017/08/20 12:46:50 ui: vmware-iso: + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
vmware-iso: + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
2017/08/20 12:46:50 ui: vmware-iso: + FullyQualifiedErrorId : ComMethodTargetInvocation
vmware-iso: + FullyQualifiedErrorId : ComMethodTargetInvocation
vmware-iso:
2017/08/20 12:46:50 ui: vmware-iso:
2017/08/20 12:47:00 packer: 2017/08/20 12:47:00 [INFO] command 'powershell -executionpolicy bypass -file "%TEMP%\packer-elevated-shell-5999e727-ddcf-e4d7-2216-cee952a4992d.ps1"' exited with code: 1
2017/08/20 12:47:00 packer: 2017/08/20 12:47:00 [INFO] RPC endpoint: Communicator ended with: 1
2017/08/20 12:47:00 [INFO] 509 bytes written for 'stderr'
2017/08/20 12:47:00 [INFO] 0 bytes written for 'stdout'
2017/08/20 12:47:00 [INFO] RPC client: Communicator ended with: 1
2017/08/20 12:47:00 [INFO] RPC endpoint: Communicator ended with: 1