Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 199442

Re: Query: VMparameter script working on 1 vcenter but not on another vCenter

$
0
0

Nothing specific...Would like to know is there any hardening parameters in case any ..

 

JUst FYI: If I use POWERGUI software, RUNSPACE panel at the right side of console showed last executed virtual machine name, Harddisk and other parameter values, but couldn't able to see in the CSV sheet.

 

So I tried script below to avoid the variables but still no luck..

 

Connect-VIserver -server vcservername -user vcusername -password vcpassword | Out-File -FilePath C:\Scripts\Test.txt

 

$VMs = @()

 

$VMs = Get-VM

 

#Array to store the VM Parameters               

$VMHealthInfo = @()

 

$VMs | % {

 

  " " |Out-File -FilePath C:\Scripts\Test.txt -Append

 

    #Assign Virtual machine attributes to variables

    $VirtualMachine = $_

    $VMview = $VirtualMachine | Get-View

     

    $VirtualMachine | Get-HardDisk | where {$_.StorageFormat -eq 'Thin'} | % {

 

  #Virtual Machine Name

  $VirtualMachine.Name | Out-File -FilePath C:\Scripts\Test.txt -Append

 

    #DNS Name

  $VMview.Guest.HostName  | Out-File -FilePath C:\Scripts\Test.txt -Append

 

    $VirtualHardDisk = $_

  ($VirtualHardDisk.Name) | Out-File -FilePath C:\Scripts\Test.txt -Append

 

    #Virtual Machine Creation Date

  ($VirtualMachine.CustomFields["CreatedOn"])  | Out-File -FilePath C:\Scripts\Test.txt -Append

 

    #Virtual Machine PowerState Status

  ($VirtualMachine.Powerstate)  | Out-File -FilePath C:\Scripts\Test.txt -Append

 

    #VirtualMachine Operation System Name

  ($VirtualMachine.Guest.OSFullName)  | Out-File -FilePath C:\Scripts\Test.txt -Append

 

    #Virtual Machine Hardware Version

  ($VMview.Config.Version)  | Out-File -FilePath C:\Scripts\Test.txt -Append

 

    #VMware Tools Version

  ($VMview.Config.Tools.ToolsVersion)  | Out-File -FilePath C:\Scripts\Test.txt -Append

 

    #Vmware Tools Status

  ($VMview.Guest.ToolsStatus)  | Out-File -FilePath C:\Scripts\Test.txt -Append

 

    #Displays the status of CPU HotAddEnabled for the virtual machine (True = Enabled)

  ($VMview.Config.CPUHotAddEnabled)  | Out-File -FilePath C:\Scripts\Test.txt -Append

 

    #Displays the status of Memory HotAddEnabled for the virtual machine (True = Enabled)

  ($VMview.Config.MemoryHotAddEnabled)  | Out-File -FilePath C:\Scripts\Test.txt -Append 

 

    #Dispalys CPU Reservation in GHz for the Virtual Machine

  ($VMview.Config.CpuAllocation.Reservation/1000)  | Out-File -FilePath C:\Scripts\Test.txt -Append

 

    #Dispalys CPU Limit in GHz for the Virtual Machine

  (&{if($VMView.Config.CpuAllocation.Limit -eq -1){"NULL"} else {$VMView.Config.CpuAllocation.Limit/1000}})  | Out-File -FilePath C:\Scripts\Test.txt -Append

 

    #Dispalys Memory Reservations in GB for the Virtual Machine

  ($VMView.Config.MemoryAllocation.Reservation/1024)  | Out-File -FilePath C:\Scripts\Test.txt -Append  

 

    #Dispalys Memory Limit in GB for the Virtual Machine

  (&{if($VMView.Config.MemoryAllocation.Limit -eq -1){"NULL"} else {$VMView.Config.MemoryAllocation.Limit/1024}})  | Out-File -FilePath C:\Scripts\Test.txt -Append

      }

 

 

 

 

(2) If I run individual commands in PowerCLI command propmt

PowerCLI>Connect-VIserver -server vcservername -user vcusername -password vcpassword

vCenter Connected with Hostname and portnumber info

PowerCLI>$VMview = Get-VM VMNAME | Get-View

PowerCLI> ($VMview.Config.Tools.ToolsVersion)

Got the Result for ToolsVersion

 

 

Main query is why results are not saved in CSV file/text file

 

Thanks,

Girish Sai J


Viewing all articles
Browse latest Browse all 199442

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>