Automation

 View Only
  • 1.  VMware Tools installation on Bulk Windows VM

    Posted Sep 30, 2021 01:08 PM

    Hello All,

    I am trying to install standalone VMwareTools in all my Windows VMs. I am using the below commands via PowerShell script.

    ============================================================================================================

    $vCS = 'XXXXXXX'
    $cred = Get-Credential
    #and connect vCenter
    set-PowerCLIConfiguration -InvalidCertificateAction Ignore
    connect-viserver -server $vCS -Credential $cred
    $cred
    if ($error.Count -eq 0) {
        Write-Output ((Get-Date -Format ("[yyyy-MM-dd HH:mm:ss] ")) + ":Info: vCenter $vCS successfully connected" )}

    $computerlist = Get-Content -Path C:\temp\Servers.txt
    $GuestCred = $Host.UI.PromptForCredential("Please enter credentials", "Enter Guest credentials", "", "")

    $computerlist = Get-Content -Path C:\temp\Servers.txt
    $GuestCred = $Host.UI.PromptForCredential("Please enter credentials", "Enter Guest credentials", "", "")

    foreach ($computer in $computerlist) {

    Invoke-VMScript -VM $computer -ScriptType Powershell 'Copy-Item -Recurse -Path "\\RDR-VM1245\VMwareTools" -destination "C:\"' -GuestCredential $GuestCred
    Write-Host "VMwareTools folder copied to C:\" -ForegroundColor Green

    Invoke-Command -ComputerName $computer -ScriptBlock {Start-Process -FilePath C:\VMwareTools\VMware-tools-11.3.0-18090558-x86_64.exe -ArgumentList '/s /v "/qn REBOOT=R ADDLOCAL=ALL"'}

    }

    ============================================================================================

    I am getting the below errors :

    This command cannot be run due to the error: The system cannot find the file specified.
    + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
    + PSComputerName : XXXXXXXXX

    Note : Folder is getting copied to remote VM.

    Please suggest and help to rectify the mistake. I am a beginner at PowerShell. Help!



  • 2.  RE: VMware Tools installation on Bulk Windows VM

    Posted Sep 30, 2021 01:19 PM

    Why are you doing the copy with Invoke-VMScript and the execution with Invoke-Command?
    Also for the copy, you could use the Copy-VMGuestFile cmdlet.

    The error message is quit clear, the Start-Process cmdlet doesn't seem to find the file.
    You can add some checks:
    - add the Verbose switch to the Start-Process
    - first do a "dir" of the folder, to actually confirm the files are there.



  • 3.  RE: VMware Tools installation on Bulk Windows VM

    Posted Sep 30, 2021 04:27 PM

    Hello  ,

    Below result from one of the guest VM:

    1. DIR of the folder which is getting copied to the C:\ of the remote VM.

    aichsurajit_0-1633014450588.png

    2. Added the verbose switch to the script

    aichsurajit_1-1633019058579.png


    VERBOSE: 9/30/2021 6:15:35 PM Invoke-VMScript Finished execution

    VM : XXXXXXX
    ExitCode : 0
    ScriptOutput :
    Uid : /VIServer=XXXXXXXXXXXXXXX:443/VirtualMachine=VirtualMachine-vm-110617/VMScriptResult=371857150_0/
    Length : 0

    VMwareTools folder copied to C:\
    [XXXXXXXXXX] Connecting to remote server XXXXXXXXX failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo : OpenError: (XXXXXXXX:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : AccessDenied,PSSessionStateBroken

     

     

     



  • 4.  RE: VMware Tools installation on Bulk Windows VM

    Posted Sep 30, 2021 05:54 PM

    That error message probably explains what is happening, you don't seem to have the required permissions to use Invoke-Command towards that machine.

    Like I remarked earlier, why the Invoke-Command, you can use just as well the Invoke-VMscript to execute the EXE.