Automation

 View Only
  • 1.  runing script in guest OS

    Posted Sep 15, 2016 11:32 AM

    Hello


    I have powershell script to get the list of application installed on the servers through get-itemproperty,, now i want to run this on all virtual machine through powerCLI, can you please help me?

    Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |  Select DisplayName, DisplayVersion, InstallDate,PSComputerName  |?{$_.DisplayName -like "VMware Tools" -or $_.DisplayName -like "IBM Tivoli Monitoring" -or $_.DisplayName -like "Symantec Endpoint Protection" -or $_.DisplayName -like "ILMT-TAD4D Agent" -or $_.DisplayName -like "IBM BigFix Client" -or $_.DisplayName -like "IBM Tivoli Storage Manager Client" | select -ExcludeProperty RunspaceId }} | ForEach-Object { $D += $_ }

    Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*  | Select  DisplayName, DisplayVersion,InstallDate,PSComputerName| ?{$_.DisplayName -like "VMware Tools" -or $_.DisplayName -like "IBM Tivoli Monitoring" -or $_.DisplayName -like "Symantec Endpoint Protection" -or $_.DisplayName -like "ILMT-TAD4D Agent" -or $_.DisplayName -like "IBM BigFix Client" -or $_.DisplayName -like "IBM Tivoli Storage Manager Client"



  • 2.  RE: runing script in guest OS

    Posted Sep 15, 2016 12:23 PM

    You can use the Invoke-VMScript cmdlet to run a PowerShell script inside the guest OS (use the -ScriptType PowerShell parameter)

    The VM needs to have VMware Tools installed.



  • 3.  RE: runing script in guest OS

    Posted Sep 15, 2016 01:01 PM

    if I use invoke-vmscript, does it cause any issue on VM?  cause its running very slow if I run it on all the server



  • 4.  RE: runing script in guest OS

    Posted Sep 15, 2016 01:17 PM

    Not sure what you mean by "issue on VM".

    What is slow, the VM globally, or the script running inside the guest OS of the VM?

    Note that there is a bit of overhead for running a script inside the guest OS.

    The results might not return as fast as if you run them locally.



  • 5.  RE: runing script in guest OS

    Posted Sep 15, 2016 01:36 PM

    $Sinfo=@()

    $user= Get-Credential supplier.coop\in05750m

    Get-VM gb02qdc412cpkwm| ForEach-Object {

        $VM = $_

    $Report = "" | Select-Object VMname,displayname1,displayname2,displayversion1,displayversion2

    $Report.VMName = $VM.name

    $Report.displayname1=Invoke-VMScript -VM $VM -GuestCredential $user -scripttype Powershell -scripttext {Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |  Select-object DisplayName |?{$_.DisplayName -like "VMware Tools" -or $_.DisplayName -like "IBM Tivoli Monitoring" -or $_.DisplayName -like "Symantec Endpoint Protection" -or $_.DisplayName -like "ILMT-TAD4D Agent" -or $_.DisplayName -like "IBM BigFix Client" -or $_.DisplayName -like "IBM Tivoli Storage Manager Client" }}

    $Report.displayname2=Invoke-VMScript -VM $VM -GuestCredential $user -scripttype Powershell -scripttext {Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*  | Select-object  DisplayName| ?{$_.DisplayName -like "VMware Tools" -or $_.DisplayName -like "IBM Tivoli Monitoring" -or $_.DisplayName -like "Symantec Endpoint Protection" -or $_.DisplayName -like "ILMT-TAD4D Agent" -or $_.DisplayName -like "IBM BigFix Client" -or $_.DisplayName -like "IBM Tivoli Storage Manager Client" }}

    $Report.displayversion1=Invoke-VMScript -VM $VM -GuestCredential $user -scripttype Powershell -scripttext {Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |  Select-object * |?{$_.DisplayName -like "VMware Tools" -or $_.DisplayName -like "IBM Tivoli Monitoring" -or $_.DisplayName -like "Symantec Endpoint Protection" -or $_.DisplayName -like "ILMT-TAD4D Agent" -or $_.DisplayName -like "IBM BigFix Client" -or $_.DisplayName -like "IBM Tivoli Storage Manager Client" }}

    $Report.displayversion2=Invoke-VMScript -VM $VM -GuestCredential $user -scripttype Powershell -scripttext {Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*  | Select-object * | ?{$_.DisplayName -like "VMware Tools" -or $_.DisplayName -like "IBM Tivoli Monitoring" -or $_.DisplayName -like "Symantec Endpoint Protection" -or $_.DisplayName -like "ILMT-TAD4D Agent" -or $_.DisplayName -like "IBM BigFix Client" -or $_.DisplayName -like "IBM Tivoli Storage Manager Client" }}

    $Sinfo+=$Report

    }

    $Sinfo | export-csv ff.csv  -NoTypeInformation -useculture

    I have few question

    1. If I use vm-invokescript, does it impact VM performance as output i am getting slow compare to what i run through powershell

    2. above script not giving proper output in csv.. i would like to see  something like below



  • 6.  RE: runing script in guest OS

    Posted Sep 15, 2016 07:18 PM

    The object that is returned by the Invoke-VMScript cmdlet has a property named ScriptOutput

    In that property you'll find the output from your script.