vmtools installation issue using powershell

36 views
Skip to first unread message

Shyam J

unread,
May 28, 2019, 2:20:28 AM5/28/19
to Packer
Hi,

I am trying to install vmtools using a powershell script below. Above snippets are for dealing with TLS issues. 
I am facing issue with installing with last command for installation. Same command works fine when run manually but not when run through Packer.



add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy {
        public bool CheckValidationResult(
            ServicePoint srvPoint, X509Certificate certificate,
            WebRequest request, int certificateProblem) {
            return true;
        }
    }
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy;
(New-Object System.Net.WebClient).DownloadFile('https://10.7.64.21/swrepo/VMwareTools.zip','C:\Windows\Temp\VMwareTools.zip');
Start-Sleep -Seconds 60;
#Microsoft.PowerShell.Archive\Expand-Archive -literalpath 'C:\Windows\Temp\VMwareTools.zip' -destinationpath 'C:\Windows\Temp\VMwareTools';
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
{
    param([string]$zipfile, [string]$outpath)

    [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}

Unzip "C:\Windows\Temp\VMwareTools.zip" "C:\Windows\Temp\VMwareTools"
Start-Sleep -Seconds 20;
Start-Process -Wait -PassThru -FilePath C:\Windows\Temp\VMWaretools\VMWaretools\setup64.exe -ArgumentList "/S /l C:\Windows\Temp\vmware_tools.log /v""/qn REBOOT=R""";
Start-Sleep -Seconds 300;



Please see output below in logging mode. No errors are being thrown and showing successful, but nothing has happened inside VM. Tried installing changing different parameters but no luck.

Output
======

==> vmware-iso: Provisioning with Powershell...

==> vmware-iso: Provisioning with powershell script: post_windows2.ps1

2019/05/21 08:30:01 cracklib-packer: 2019/05/21 08:30:01 Opening post_windows2.ps1 for reading

2019/05/21 08:30:01 cracklib-packer: 2019/05/21 08:30:01 Uploading env vars to c:/Windows/Temp/packer-ps-env-vars-5ce3f82d-9a5e-bf27-ac72-f14cc6752312.ps1

2019/05/21 08:30:01 cracklib-packer: 2019/05/21 08:30:01 [INFO] 76 bytes written for 'uploadData'

2019/05/21 08:30:01 [INFO] 76 bytes written for 'uploadData'

2019/05/21 08:30:01 cracklib-packer: 2019/05/21 08:30:01 Uploading file to 'c:/Windows/Temp/packer-ps-env-vars-5ce3f82d-9a5e-bf27-ac72-f14cc6752312.ps1'

2019/05/21 08:30:25 cracklib-packer: 2019/05/21 08:30:25 Uploading file to 'c:/Windows/Temp/script-5ce3f82d-affa-c82d-499f-42e5b41dcf37.ps1'

2019/05/21 08:30:25 cracklib-packer: 2019/05/21 08:30:25 [INFO] 1226 bytes written for 'uploadData'

2019/05/21 08:30:25 [INFO] 1226 bytes written for 'uploadData'

2019/05/21 08:30:36 cracklib-packer: 2019/05/21 08:30:36 [INFO] starting remote command: powershell -executionpolicy bypass "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};. c:/Windows/Temp/packer-ps-env-vars-5ce3f82d-9a5e-bf27-ac72-f14cc6752312.ps1; &'c:/Windows/Temp/script-5ce3f82d-affa-c82d-499f-42e5b41dcf37.ps1'; exit $LastExitCode }"

    vmware-iso:

    vmware-iso: Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName

    vmware-iso: -------  ------    -----      ----- -----   ------     -- -----------

    vmware-iso:      54       5      768       3216    43     0.06    908 setup64

2019/05/21 08:36:21 cracklib-packer: 2019/05/21 08:36:21 [INFO] command 'powershell -executionpolicy bypass "& { if (Test-Path variable:global:ProgressPreference){set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};. c:/Windows/Temp/packer-ps-env-vars-5ce3f82d-9a5e-bf27-ac72-f14cc6752312.ps1; &'c:/Windows/Temp/script-5ce3f82d-affa-c82d-499f-42e5b41dcf37.ps1'; exit $LastExitCode }"' exited with code: 0

2019/05/21 08:36:21 cracklib-packer: 2019/05/21 08:36:21 [INFO] RPC endpoint: Communicator ended with: 0

2019/05/21 08:36:21 [INFO] 245 bytes written for 'stdout'

2019/05/21 08:36:21 [INFO] 0 bytes written for 'stderr'

2019/05/21 08:36:21 [INFO] RPC client: Communicator ended with: 0

2019/05/21 08:36:21 [INFO] RPC endpoint: Communicator ended with: 0

2019/05/21 08:36:21 cracklib-packer: 2019/05/21 08:36:21 [INFO] 245 bytes written for 'stdout'

2019/05/21 08:36:21 cracklib-packer: 2019/05/21 08:36:21 [INFO] 0 bytes written for 'stderr'

2019/05/21 08:36:21 [INFO] (telemetry) ending powershell


Thanks in advance

Shyam

Shyam J

unread,
May 30, 2019, 5:58:37 AM5/30/19
to Packer
Tried the install with a batch script as well, but same result. Any suggestions?

==> vmware-iso: Provisioning with shell script: install_vmtools.bat

2019/05/28 04:52:27 cracklib-packer: 2019/05/28 04:52:27 Opening install_vmtools.bat for reading

2019/05/28 04:52:27 cracklib-packer: 2019/05/28 04:52:27 Uploading file to 'c:/Windows/Temp/script.bat'

2019/05/28 04:52:27 cracklib-packer: 2019/05/28 04:52:27 [INFO] 80 bytes written for 'uploadData'

2019/05/28 04:52:27 [INFO] 80 bytes written for 'uploadData'

2019/05/28 04:52:43 cracklib-packer: 2019/05/28 04:52:43 [INFO] starting remote command: set "PACKER_BUILDER_TYPE=vmware-iso" && set "PACKER_BUILD_NAME=vmware-iso" && "c:/Windows/Temp/script.bat"

    vmware-iso:

    vmware-iso: C:\Users\vagrant>cmd /c C:\Windows\Temp\VMWaretools\VMWaretools\setup64.exe /S /v"/qn REBOOT=R\"

2019/05/28 04:53:44 [INFO] 0 bytes written for 'stderr'

2019/05/28 04:53:44 cracklib-packer: 2019/05/28 04:53:44 [INFO] command 'set "PACKER_BUILDER_TYPE=vmware-iso" && set "PACKER_BUILD_NAME=vmware-iso" && "c:/Windows/Temp/script.bat"' exited with code: 0

2019/05/28 04:53:44 cracklib-packer: 2019/05/28 04:53:44 [INFO] RPC endpoint: Communicator ended with: 0

2019/05/28 04:53:44 [INFO] 101 bytes written for 'stdout'

2019/05/28 04:53:44 [INFO] RPC client: Communicator ended with: 0

2019/05/28 04:53:44 [INFO] RPC endpoint: Communicator ended with: 0

2019/05/28 04:53:44 cracklib-packer: 2019/05/28 04:53:44 [INFO] 0 bytes written for 'stderr'

2019/05/28 04:53:44 cracklib-packer: 2019/05/28 04:53:44 [INFO] 101 bytes written for 'stdout'

2019/05/28 04:53:44 cracklib-packer: 2019/05/28 04:53:44 [INFO] RPC client: Communicator ended with: 0

2019/05/28 04:53:44 [INFO] (telemetry) ending windows-shell

2019/05/28 04:53:44 [INFO] (telemetry) Starting provisioner windows-restart



Command used: cmd /c C:\Windows\Temp\VMWaretools\VMWaretools\setup64.exe /S /v"/qn REBOOT=R\"


Thanks

Shyam

Jordan Borean

unread,
May 30, 2019, 3:17:18 PM5/30/19
to Packer
If the executable is reporting an rc of 0 then Packer is doing what it should, which is just continue on. You will need to find some lots on the server from the installer which might let you know what is going on. With no output or an erroneous rc there is not much we can do to help.
Reply all
Reply to author
Forward
0 new messages