piercj2's Posts

I had exactly that problem :smileyconfused: Thanks for following up before I had the chance to ask for more help
LucD, you are The Man I started thinking that I needed to collect everything in an array and, spent the last hour or two attempting it. I only succeeded in making the code look ugly! Your so... See more...
LucD, you are The Man I started thinking that I needed to collect everything in an array and, spent the last hour or two attempting it. I only succeeded in making the code look ugly! Your solution was simple, efficient and clean. Thank you so mush, you've (again) made my life that bit easier
Hi LucD, Thanks for the advice on this. What you advised worked and I was able to use it to also get some needed Network Config information. The script is almost working 100%, there's just on... See more...
Hi LucD, Thanks for the advice on this. What you advised worked and I was able to use it to also get some needed Network Config information. The script is almost working 100%, there's just one small issue. It only returns the information for a single VM, despite a list of VM's being given in C:\Temp\vmList.txt The line $content = get-vm (Get-Content C:\Temp\vmList.txt) works. When I output $content I see the entire list of VM names, their PowerState, Num CPUs and MemoryGB I would expect the foreach($computer in $content) loop to iterate for every VM but, it doesn't for some reason. I just get the results that I need for a single (random) VM in the list. Can you see what's wrong with the following ? $content = get-vm (Get-Content C:\Temp\vmList.txt) foreach($Computer in $content){    $GeneralProp=[ordered]@{         'ComputerName'=$computer.Name;         'PowerState'=$Computer.PowerState;         'OS'=$Computer.GuestId;         'VMware Tools'=$Computer.Guest.ToolsVersion;         'Num CPU'=$Computer.NumCpu;         'Memory GB'=$Computer.MemoryGB;         'Host'=$Computer.VMHost;         'ResourcePool'=$Computer.ResourcePool;    }      $hdd = 1    $Computer | Get-HardDisk | foreach {         $GeneralProp.Add("HDD$($hdd) Name",$_.Name)         $GeneralProp.Add("HDD$($hdd) Path",$_.FileName)         $GeneralProp.Add("HDD$($hdd) Capacity",$_.CapacityGb)         $hdd++    }    $nic = 1    $Computer | Get-VirtualPortGroup | foreach {         $GeneralProp.Add("NIC$($nic) vSwitch",$_.VirtualSwitch)         $GeneralProp.Add("NIC$($nic) PortGroup",$_.Name)         $GeneralProp.Add("NIC$($nic) VLAN ID",$_.VlanID)         $GeneralProp.Add("NIC$($nic) IP", $Computer.Guest.IPAddress[$nic-1])         $nic++     }    $Obj=New-Object -TypeName PSObject -Property $GeneralProp    $Obj | Export-Csv C:\Temp\SRM\VMdetails.csv -NoTypeInformation }
Hi, I'm trying to create a script that will provide some General VM info. I'm collecting this information as I'm about to perform an SRM failover and want to have as much info about each VM a... See more...
Hi, I'm trying to create a script that will provide some General VM info. I'm collecting this information as I'm about to perform an SRM failover and want to have as much info about each VM as is necessary in case I need to rebuild anything from Scratch :smileycry: I've put the following together and it works except I'd like to export it to a csv in the case of a VM with multiple HDD's or multiple NIC's, I'd like the output to be in separate columns For example, my script produced the following output for HDD's in the VM HDD Info     : {@{Name=Hard disk 1; Filename=[VMFS_IRL_1] Server1/Server1_2.vmdk; CapacityGB=40}, @{Name=Hard disk 2;                Filename=[VMFS_IRL_1] Server1/Server1_1.vmdk; CapacityGB=90}} I would prefer the following for each VM's Hard Disk info HDD1 Name HDD1 Path HDD1 CapacityGB HDD2 Name HDD2 Path HDD2 CapacityGB HDD3 Name Hard disk 1 [VMFS_IRL_1] Server1/Server1_2.vmdk 40 Hard disk 2 [VMFS_IRL_1] Server1/Server1_1.vmdk 90 Here's the script $content = get-vm (Get-Content C:\Temp\vmList.txt) foreach($Computer in $content){               $GeneralProp=[ordered]@{         'ComputerName'=$computer.Name;         'PowerState'=$Computer.PowerState;         'OS'=$Computer.GuestId;         'VMware Tools'=$Computer.Guest.ToolsVersion;         'Num CPU'=$Computer.NumCpu;         'Memory GB'=$Computer.MemoryGB;         'Host'=$Computer.VMHost;         'ResourcePool'=$Computer.ResourcePool;         'Num HDD'=$Computer.HardDisks.Count;         'HDD Info'=$Computer | Get-HardDisk | select Name, Filename, CapacityGB;         'Num NIC'=$Computer.NetworkAdapters.Count;         'NIC Info'=$Computer | Get-VirtualPortGroup | select VirtualSwitch, vlanID, Name;         'NIC IP'=$Computer.Guest.IPAddress;     } $Obj=New-Object -TypeName PSObject -Property $GeneralProp Write-Output $Obj }     Any help would be great, Thanks
Hi Guys, Is there a way to use PowerCLI to remediate only Patches/Baselines that have already been staged ? I'm using PowerCLI to automate the Patching of approx 1000 ESXi 5.5 Hosts. The Pro... See more...
Hi Guys, Is there a way to use PowerCLI to remediate only Patches/Baselines that have already been staged ? I'm using PowerCLI to automate the Patching of approx 1000 ESXi 5.5 Hosts. The Process first Stages one of two available Baselines, depending on the Host Hardware (Dell or Cisco). I've got this working with Stage-Patch and some Where-Object statements. I now want to use Remediate-Inventory to remediate the Patches that have already been staged, without having to check them again to see if they are for Dell or Cisco Thanks
Hi, I need to Storage vMotion approx 300 VM's from an old SAN to a new SAN. The new SAN has 10 4TB LUNs provisioned, these are called New_SAN_1, New_SAN_2, etc... What I would like to do i... See more...
Hi, I need to Storage vMotion approx 300 VM's from an old SAN to a new SAN. The new SAN has 10 4TB LUNs provisioned, these are called New_SAN_1, New_SAN_2, etc... What I would like to do is the following provide a .txt tile with a list of VM's to be migrated for each VM in this list Calculate the Used Space (GB) Randomly, select one of the 10 new LUNs Migrate the VM to the LUN only if free space equal to the amount of space used by the VM plus 25% E.G. if the VM is using 100GB, only svMotion it if the randomly selected LUN has 125GB free Here's what i've come up with $VMs = get-vm (get-content c:\temp\VmList.txt) foreach ($v in $VMs) { $VmUsedSpace = $_.UsedSpaceGB     $random = Get-Random -InputObject 1,2,3,4,5,6,7,8,9,10     $random_New_Datastore  = get-datastore | where-object {$_.name -match “New_SAN_$random”}     if ($random_New_Datastore.FreeSpaceGB -gt ($VmUsedSpace * 1.25)) {         Move-VM -VM $v -Datastore $random_New_Datastore -RunAsync -Confirm:$false     } } If the randomly selected LUN, does not have enough free space, how can I cleanly select a different LUN verify that it has enough free space svMotion the VM Thanks
Issue resolved. I upgrades from PowerCLI 5.5 Release 1 to PowerCLI Release 5.8 Release 1 and the get-vmhostsnmp command works now. Better still Get-VMHostSnmp | select VMHost,TrapTargets work... See more...
Issue resolved. I upgrades from PowerCLI 5.5 Release 1 to PowerCLI Release 5.8 Release 1 and the get-vmhostsnmp command works now. Better still Get-VMHostSnmp | select VMHost,TrapTargets works
Hi All, I need to push out a bunch of SNMP settings to some ESXi 5.5 Hosts. That bit is easy. I say that because when I issue the set-vmhostsnmp command to add the targets and community names... See more...
Hi All, I need to push out a bunch of SNMP settings to some ESXi 5.5 Hosts. That bit is easy. I say that because when I issue the set-vmhostsnmp command to add the targets and community names, no error is returned. It's when I try to verify the settings, or lookup SNMP settings on different Hosts that I run into trouble. I want to add that I've tried the following on PowerShell (v3), the Powershell ISE and, VMware's PowerCLI (5.5 Release 1). Always with the same results. connect-viserver MyESXiHost -credential (get-credential) Get-VMHostSNMP   #returns nothing Get-VMHostSNMP -Server MyESXiHost # returns the below error Get-VMHostSnmp : Jun/26/2015 12:14:18 Get-VMHostSnmp    The method or operation is not implemented. At line:1 char:1 + Get-VMHostSnmp -Server MyESXiHost + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo      : NotSpecified: (:) [Get-VMHostSnmp], VimException + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetVMHostSnmp I've checked the snmpd Service and it is running Get-VMHostService -VMHost MyESXiHost | where {$_.Key -eq "snmpd"} Key                  Label                          Policy     Running  Required ---                  -----                          ------     -------  -------- snmpd                snmpd                          on         True     False   I've even restarted the snmpd service after adding the SNMP Settings using Get-VMHostService -VMHost MyESXiHost | where {$_.Key -eq "snmpd"} | Restart-VMHostService -Confirm:$false Key              Label                      Policy Running  Required ---              -----                      ------ -------  -------- snmpd            snmpd                      on     True False   I've even tried Get-EsxCli $esxcli = Get-EsxCli -VMHost siprb3esx01.corp.emc.com $esxcli.system.snmp.get() more errors returned Community string was not specified in trap target When I put something inside the brackets, I get the following The method 'get' is invoked with '1' parameters, but the expected parameter count is '0' Any help that can be offered would be much appreciated. Thanks all
Hi LucD, Thanks again for the assist. I've come up with the following to allow me test VM's. It's handy if you're Patching a number of Hosts and want a quick view of everything before and aft... See more...
Hi LucD, Thanks again for the assist. I've come up with the following to allow me test VM's. It's handy if you're Patching a number of Hosts and want a quick view of everything before and after the patching. Given a list of ESXi Hosts in a Text file, the script will test connectivity to each host and will let you know if it's corresponding VM's are - Powered Off, Suspended, Powered on - If VMware Tools are installed, it'll also ping the VM I'd like to improve the script by adding two extra features but, don't know how to do this 1) if Ping to a VM fails on an IPv4 address but, an IPv6 address is returns, I'd like for the script to handle this better. Currently it returns an error 2) I'd like to have the results output to a (.csv) file with 3 columns.      - first column is Date and Time      - Second column is name of Esxi Host      - Third column is name of VM running on the Host      - fourth column is Description of Current Status Eg Date & Time ESXi Host VM Status 12 May 2015 09:00:00 ESXi1 Connected and replying to Pings on vmk0 - 10.10.10.1 12 May 2015 09:00:00 ESXi1 vm1 PoweredOn and replying to Ping from IP Address 10.10.10.10 12 May 2015 09:00:00 ESXi1 vm2 PoweredOn and replying to Ping from IP Address 10.10.10.11 12 May 2015 09:02:00 ESXi2 Connected and replying to Pings on vmk1 - 11.11.11.1 $statusloaded=$false $snapins=("VMware.VimAutomation.Core","VMware.VumAutomation") foreach ($snapin in $snapins) {         Add-PSSnapin $snapin               if((Get-PSSnapin $snapin) –eq $null){          }         else {                  $statusloaded=$true         } } Write-Host -BackgroundColor White -ForegroundColor Black "*************************************************************" Write-Host -BackgroundColor White -ForegroundColor Black "*** Ensure you are logged into the correct vCenter Server ***" Write-Host -BackgroundColor White -ForegroundColor Black "*************************************************************" Write-Host "" Connect-VIServer Write-Host "" Write-Host "" Write-Host "*** The specified file must contain FQDN Nmaes of ESXi Hosts ***" Write-Host "***            Enter one FQDN Name per line                  ***" Write-Host "" Write-Host "" # Enter the filename that contains the list of ESXi Hosts $filelocation = Read-Host "Please enter the Filename, including full path, of the target file" # Places the ESXi Host names contained in the named file into a variable                                                                                                                                                         $TargetHosts = Get-VMHost (Get-Content $filelocation)   # Test connectivity to each ESXi Host                                                                                                         foreach ($ESXiHost in $TargetHosts) {         $MgmtNic = Get-VMHost $ESXiHost | Get-VMHostNetworkAdapter | Where-Object {$_.ManagementTrafficEnabled}         $MgmtIP = $MgmtNic.IP             $TestHostConnection = Test-Connection $MgmtIP -Quiet -Count 1              if ($TestHostConnection -eq $true) {                       $time = (Get-Date).ToString()                       $hoststatus = (Get-VMHost $ESXiHost).ConnectionState                       Write-Host ""                       Write-Host $time "-- ESXi Host " $ESXiHost " is " $hoststatus " and replying to Pings on " $MgmtNic " - " $MgmtIP                                      # for each active ESXi Host, test connectivity to it's VM's                       $TargetVMs = $ESXiHost | Get-VM                       foreach ($vm in $TargetVMs) {                                 # variable to hold Power State of VM's                           $powerstate = (Get-VM $vm).PowerState                           # variable to hold installation status of VMware Tools                           $getview = Get-VM $vm | Get-View                           $checkToolsStatus = $getview.Guest.ToolsStatus                           # variable to hold IP Addresses configured on VM's                           $vmip = (Get-VM $vm).Guest.IPAddress                           # If VM Power State is anything other than Powered On (Powered Off, Suspended, etc...) let me know                           if ($powerstate -ne "PoweredOn") {                                    Write-Host -ForegroundColor Red "$time --      VM $vm is $powerstate"                                    }                           # If VMware Tools in not installed, let me know                           elseif ($checkToolsStatus -eq "toolsNotInstalled") {                                    Write-Host -ForegroundColor Cyan "$time --      VM $vm does not have VMware Tools Installed. Unable to get IP Address as a result"                               }                                                      # If the VM is Powered On and, VMware Tools are installed, test each of the VM's IP Addresses for connectivity                           else {                                    foreach ($ip in $vmip) {                                             $TestVMConnection = Test-Connection $ip -Quiet -Count 1                                             if ($TestVMConnection -eq $true) {                                                      Write-Host "$time --      VM $vm is $powerstate and,is replying to Ping on Interface with IP Address $ip"                                                      }                                              else {                                                      Write-Host -ForegroundColor Red "$time --      VM $vm is $powerstate but, is not replying to Ping on Interface with IP Address $ip"                               }                     }                 }               }             }     # Let me know if it's not possible to Ping the ESXi Host         else {                   Write-Host -ForegroundColor Red "$time -- ESXi Host $ESXiHost is not replying to Ping, get to work!"         } } Write-Host "" Read-Host "Press Enter to exit"
Hi Guys, I'm trying to get IP  Addresses associated with VM's. I need to take into account the following situations - VM has no IP Address - VM has a single IP Address - VM has multiple... See more...
Hi Guys, I'm trying to get IP  Addresses associated with VM's. I need to take into account the following situations - VM has no IP Address - VM has a single IP Address - VM has multiple IP Addresses. I need to Ping an IP Address to verify Network Connectivity. In the case of VM's with multiple IP's, I don't care if I can't ping all addresses (e.g. private IP's), I just need to ping one to prove some level of Network connection. I'm using (Get-VM vmname).Guest.IPAddress.Count to get the total number of IP Addresses configured on a VM. This is then used in a foreach loop to ping each IP, which is found using (Get-VM).Guest.IPAddress for example: $count = (Get-VM).Guest.IPAddress.Count for ($I=1 ; $I -le $count+1 ; $I++) {      blah blah blah      $vmip = (Get-VM $vm).Guest.IPAddress      Test-Connection $vmip -Quiet -Count 1 } I've found in testing that sometimes (Get-VM vmname).Guest.IPAddress returns a null value. I suspect that this is because VMware Tools isn't installed on all VMs. If I'm right and this is a result of a lack of VMware Tools on particular VMs, is there any other way to get the VM's IP Address ? Thanks
I wanted to post an updated script that runs a little nicer (in case anyone is following this post) I've introduced a loop that runs twice - first time through, it identifies any Hosts where th... See more...
I wanted to post an updated script that runs a little nicer (in case anyone is following this post) I've introduced a loop that runs twice - first time through, it identifies any Hosts where the compliance status is unknown. then it scans them to get the status - Next time through, any required patches are staged. I've commented out the remediation command at the end, as a safeguard to prevent unintentional reboots Thanks again to all those who helped with this and to all the contributors on the forum. your help has been invaluable # Change to Powershell Version 2 and load required snap-ins powershell -version 2 $statusloaded=$false $snapins=("VMware.VimAutomation.Core","VMware.VumAutomation") foreach ($snapin in $snapins) {      Add-PSSnapin $snapin       if((Get-PSSnapin $snapin) –eq $null){        } else {                $statusloaded=$true         } } $vc = Read-Host "Enter the name of the vCenter used to manage the ESXi Hosts" Connect-VIServer $vc Set-PowerCLIConfiguration -InvalidCertificateAction ignore -Confirm:$False $hosts = Get-VMHost (Get-Content c:\temp\targets.txt) $BL_Name = Read-Host "please enter the name of the Baseline to scan against, eg Q2 Primary ESX Patches 2015" $baseline = Get-Baseline | Where-Object {$_.Name -match "$($BL_Name)"} $count = 2 for ($i = 1 ; $i -lt $count + 1 ; $i++ ) {        # the first time through the loop, check to see if the Compliance Status is unknown, if it is, run a scan         if ($i -eq 1) {             foreach ($item in $hosts) {                     $unknown = Get-Compliance -Entity $item -ComplianceStatus Unknown                      if ($unknown) {                             Scan-Inventory -Entity $item -RunAsync                     }             }                   # the second time through the loop, if a host is non-compliant, stage the required Patches             foreach ($item in $hosts) {                      $notcompliant = Get-Compliance -Entity $item -ComplianceStatus NotCompliant                     if ($notcompliant) {                              Stage-Patch -Entity $item -Baseline $baseline -RunAsync -Confirm:$false                                   }             }       } } # foreach ($item in $hosts) {Remediate-Inventory -Entity $item -Baseline $baseline -HostRetryDelaySeconds 60 -HostNumberOfRetries 2 -HostPreRemediationPowerAction PowerOffVMs -RunAsync  -Confirm:$False }
Hi LucD, Thanks, your last suggestions worked perfectly. By "... not as clean as I would like", I guess I meant that I'm new to PowerCLI so there are probably elements written by me that are ... See more...
Hi LucD, Thanks, your last suggestions worked perfectly. By "... not as clean as I would like", I guess I meant that I'm new to PowerCLI so there are probably elements written by me that are frowned upon by more expert users. Lines of code that could be optimized or cleaned up for example. Thanks also for again sending on some interesting reading, by way of "PowerShell Magazine". I took the code provided and reworked it, to see if I could make it more applicable for what I need. I couldn't Again, what I would like to do is ping all the ESXi550 Hosts and their corresponding VMs to make sure they are on the network after Remediation of Patches. Here's what I attempted $hosts = Get-VMHost (Get-Content c:\temp\ListOfHosts.txt) $esx = $hosts | Select-Object @{N="Hosts" ; E={$_.Name}} $vm_name = $hosts | Select-Object @{N="VM Name" ; E={($_ | Get-VM).Name}} $vm_ip = $hosts | Select-Object @{N="VM IP" ; E={($_ | Get-VM).Guest.IPAddress}} $targets = $esx . $vm_name , $vm_ip foreach ($target in $targets) { Write-Verbose "Ping Computer: $target" if (Test-Connection -ComputerName $target -quiet -Count 2)      {           Write-Verbose "Computer: $target is alive"      }      Write-Verbose "Computer $target cannot be contacted, get to work!!!" } I need to ping the VM's by both Name and IP as not all of them are registered in DNS. If results the above could be output to a file, that would be better again.
Here's my latest attempt, it's working but, not as clean as I would like. LucD, Would you mind casting your expert eye over this and let me know if it can be improved in any way ? Thanks ... See more...
Here's my latest attempt, it's working but, not as clean as I would like. LucD, Would you mind casting your expert eye over this and let me know if it can be improved in any way ? Thanks $vc = Read-Host "Enter the name of the vCenter used to manage the ESXi Hosts"    Connect-VIServer $vc Set-PowerCLIConfiguration -InvalidCertificateAction ignore -Confirm:$False $hosts = Get-VMHost (Get-Content C:\Temp\ListOfHosts.txt) $BL_Name = Read-Host "please enter the name of the Baseline to scan against, eg Q2 Primary ESX Patches 2015" $baseline = Get-Baseline | Where-Object {$_.Name -contains $BL_Name}    foreach ($item in $hosts) {       $compliancestatus = Get-Compliance -Entity $item -ComplianceStatus Unknown               if ($compliancestatus.Count -gt 0) {           Scan-Inventory -Entity $item -RunAsync      }      Stage-Patch -Entity $item -Baseline $baseline -RunAsync -Confirm:$false        }
Thanks for the replies Guys, The recommended reading by LucD was especially helpful. By following the suggestions, I was able to piece together a lot of what I'm attempting to do in PowerCLI. ... See more...
Thanks for the replies Guys, The recommended reading by LucD was especially helpful. By following the suggestions, I was able to piece together a lot of what I'm attempting to do in PowerCLI. As a refresher, a central Security Team creates the Baselines and attaches them to the ESXi Hosts throughout the company. What I need to do is: Scan the ESXi Hosts (approx. 150) against the Baselines Stage any needed Patches Remediate the Hosts Report on the results Here's what I've done so far. # switch back to PowerShell v2      powershell -version 2 # Install the VMware snap-ins      Add-PSSnapin VMware.VimAutomation.core      Add-PSSnapin VMware.VumAutomation # Connect to vCenter Servers      Connect-VIServer VC1 -user xxxxx -password yyyyy # set PowerShell to ignore invalid certificates      Set-PowerCLIConfiguration -InvalidCertificateAction ignore -Confirm:$false # Define variables      $hosts = Get-VMHost (Get-Content C:\Temp\ListOfHosts.csv) # file containing list of ESXi550 Hosts that need to be checked for compliance against attached VUM Baselines      $compliancestatus = foreach ($item in $hosts) {Get-Compliance -Entity $item -ComplianceStatus Unknown}      $scan-results = Get-VMHost (Get-Content c:\temp\scan-results.csv)      $baseline = Get-Baseline -Entity $HostToPatch # verify if an ESXi550 Host has at least one baseline with unknown compliance status attached to it # if an ESXi550 Host has an unknown compliance status, begin a scan and create a task for each scan in vCenter      foreach ($item in $hosts)      {           if ($compliancestatus.count -gt 0)           {             Scan-Inventory -Entity $item -RunAsync           }      } # I would like  for the above scan to create a report showing a list of the ESXi550 Hosts where the compliance status is "NotCompliant" and, # showing the Baseline Names that each ESXi550 Host is non-compliant against. # I have attempted to use $compliancestatus | export-csv c:\temp\scan-results.csv but, the baseline names in this report do not match the Baseline names in VUM # Once the above report is available, it should be used to Stage patches for specific Baselines only      foreach ($HostToPatch in $scan-results)      {       Stage-Patch -Entity $HostToPatch -baseline BASELINENAME      } # At a predetermined date and time, remediate the ESXi550 Hosts # ( I don't know how to schedule within the script)          foreach ($HostToPatch in $scan-results)      {       Remediate-Inventory -Entity $HostToPatch -Baseline $baseline -HostRetryDelaySeconds 120 -HostNumberOfRetries 2 -HostPreRemediationAction PowerOffVMs -RunAsync      } # repeat the compliance Check at the end and, export the results to csv $hosts = $null $compliancestatus = $null $hosts = Get-VMHost (Get-Content C:\Temp\ListOfHosts.csv) $compliancestatus = foreach ($item in $hosts) { Get-Compliance -Entity $item } $ compliancestatus | Export-CSV c:\temp\FinalPatchReport.csv # If there was also a way to Ping all impacted VM's after remediation, to ensure that they were back up, that would be good Thanks again for the help guys and, my apologies for any glaring mistakes / inefficiencies in the above
Hi Guys, I need to update a bunch of ESXi5.5 Standalone Hosts, in approx. 160 remote locations. As the Hosts are Standalone, vMotion, etc... aren't available options I'm trying to create a... See more...
Hi Guys, I need to update a bunch of ESXi5.5 Standalone Hosts, in approx. 160 remote locations. As the Hosts are Standalone, vMotion, etc... aren't available options I'm trying to create a script to do the following Stage Updates ESXi55 from VUM Power-Down all running VM's on each host (I have found how to do this by calling a list of VM's from a .csv and using the Stop-VM command on each VM) Place the Host in Maintenance Mode install the Patches / Updates Reboot the Host once the installations of Patches/Updates is complete Power-up the same VM's that were earlier shutdown (again, found this by using the Start-VM command in step 2 above) Run a report on the Patching for Compliance checks (following a discussion by LucD for this) Has anyone tried this from PowerCLI or, will I need to stick with the GUI ? Any help on any piece above would be great. Thanks
Thanks Luc, That worked perfectly. I had an issue at first when running the command on the PowerShell window, the "Get-VMHost hostname | Get-Compliance" still caused Power to frash, returning... See more...
Thanks Luc, That worked perfectly. I had an issue at first when running the command on the PowerShell window, the "Get-VMHost hostname | Get-Compliance" still caused Power to frash, returning the error "Process is Terminated due to StackOverflowException". I read the detail in the URL you provided again and, changed to "Powershell -version 2". I then ran "Get-VMHost hostname | Get-Compliance" again and bingo Got the results I needed :smileygrin: Thanks again, Jason
Hi Guys, Has anyone come across the following and if so, any solution. If I run the following command it crashed the PowerShell ISE "Get-VMHost hostname | Get-Compliance" I'm running th... See more...
Hi Guys, Has anyone come across the following and if so, any solution. If I run the following command it crashed the PowerShell ISE "Get-VMHost hostname | Get-Compliance" I'm running the following on Windows 7 64-bit PowerCLI Version ----------------    VMware vSphere PowerCLI 5.5 Release 1 build 1295336 --------------- Snapin Versions ---------------    VMWare AutoDeploy PowerCLI Component 5.5 build 1262826    VMWare ImageBuilder PowerCLI Component 5.5 build 1262826    VMware License PowerCLI Component 5.5 build 1265954    VMware VDS PowerCLI Component 5.5 build 1295334    VMware vSphere PowerCLI Component 5.5 build 1295334    VMware vSphere Update Manager PowerCLI 5.5 build 1302474 My goal is identify installed updates/patches on a wide range of ESXi5.5 Hosts as the Get-VMHostPatch command doesn't seem to work with ESXi5.5 Thanks,
Thanks for the quick reply Luc, With reference to my example, I did a Get-Datacenter Field* | Get-VMHost | Sort Name | Get-View | Get-Member I couldn't see any listing in the results for "... See more...
Thanks for the quick reply Luc, With reference to my example, I did a Get-Datacenter Field* | Get-VMHost | Sort Name | Get-View | Get-Member I couldn't see any listing in the results for "Config.Network.Vnic" or for "Hardware.CpuInfo.NumCpuPackages" I do see results for the following ConfigStatus                    Property     VMware.Vim.ManagedEntityStatus     ConfigStatus {get;} Hardware                         Property     VMware.Vim.HostHardwareInfo      Hardware {get;} I'm guessing that the above two properties, somehow lead to "Config.Network.Vnic" or for "Hardware.CpuInfo.NumCpuPackages" but I don't understand how this works. I've looked in the online help, time and time again, it may as well be in a foreign language. In smaller environments, I was able to get everything from the GUI, now I really want to become more proficient in PowerCLI. I've ordered a copy of your book :smileygrin: but am looking for any guidance I can get while waiting for it to be delivered. thanks again
hi All, I'm new to PowerCLI (VERY new). I've seen the $_ and $_. being used in a lot of Scripts on this forum and (almost) understand that they are being used as variables to hold/call variou... See more...
hi All, I'm new to PowerCLI (VERY new). I've seen the $_ and $_. being used in a lot of Scripts on this forum and (almost) understand that they are being used as variables to hold/call various properties. What I don't understand is, where to find what properties can be referenced. For Example Get-Datacenter MyDataCenter |   Get-VMHost | Get-View |   Select Name,   @{N=“IP Address“;E={($_.Config.Network.Vnic | ? {$_.Device -eq "vmk0"}).Spec.Ip.IpAddress}},   @{N=“CPU count“;E={$_.Hardware.CpuInfo.NumCpuPackages}} |   Export-Csv c:\Temp\Example.csv The above first looks in the "MyDataCenter" object, then for every Host in this object it returns the Name, IP Address and number of CPU in the Host, exporting everything to a .csv file. My question is, where do "Config.Network.Vnic" and "Hardware.CpuInfo.NumCpuPackages" exist ? How can I find out what other Properties exist or, can be referenced for each Host so that I can return values for them also ? Thanks
Hi, I'm new to PowerCLI, am currently learning PowerShell but, have an immediate requirement that i'm hoping someone can help me with. I work for a company with a large ESXi deployment, over ... See more...
Hi, I'm new to PowerCLI, am currently learning PowerShell but, have an immediate requirement that i'm hoping someone can help me with. I work for a company with a large ESXi deployment, over 2000 hosts, multiple vCenters, etc... The topology/layout within each vCenter is quiet similar. everything is version 5.5 There can be one or more DataCenters under each DataCenter will be a number of folders within each folder will be a number of ESXi Hosts and their corresponding VMs For Example      vCenter "MyVcenter" DataCenter1 "Europe" Folder1 "France" ESXi Host "France1" ESXi Host "France2" Folder2 "Germany" Folder3 "xyz" DataCenter2 "Americas" Folder1 "Washington" Folder2 "Massachusetts" ESXi Host "Ma1" ESXi Host "Ma2" etc... We have a continuous Patching Policy to ensure that the ESXi Hosts have the latest VMware Patches/Updates installed. I need a script that will allow me to nominate a particular DataCenter and then for each host within the DataCenter will provide the following Host name Management IP Build Number Summary of Patches installed Confirmation if a Reboot is required or not (after patches have been installed) Current State (connected, not connected, in Maintenance Mode, powered off, etc...) As you can imagine, going through all the DataCenters and Hosts to get the above information is extremely time consuming. I've been searching through the Communities, Forums, bloggers websites, etc... I've found various scripts that individually will give me pieces of the puzzle but nothing that will give the above in one nicely packaged script. I've tried combining the various scripts that I've come across but, they are using both cmdlets and Get-View, I'm getting tripped up trying to combine the lot. I understand that from a performance perspective, Get-View is better but, I'm still coming to grips with Managed Objects, and am a long way from being able to create the above on my own. Any help that can be offered would be appreciated, even if it's just naming a few good books/training courses on PowerCLI. Thanks