Get-ESXiMemoryDimms

I had to get some info about host memory dimms layout, so i wrote this one.
It is utilizing CIM_PhysicalMemory. Not sure if i haven’t written it before, but i couldn’t find it on my disk so…
Here it is.

Function Get-ESXiMemoryDimms {
<#
    .SYNOPSIS
        Returns memory dimms configuration for esxi
  
    .DESCRIPTION
        This function utilizes wsman / cim in order to download configuration of memory dims in ESXi.
  
    .PARAMETER  esxi
        Specify esxi host for which you want to get the report
          
    .PARAMETER  rootpw
        Password for user root inside esxi
 
    .EXAMPLE
        PS C:\> Get-ESXiMemoryDimms -Esxi 'Esxi048.domain.local' -rootpw 'password.123' | ft *
        BankLabel               Manufacturer Description SizeGB MemoryType MemoryDef
        ---------               ------------ ----------- ------ ---------- ---------
        P0_Node0_Channel0_Dimm0 Samsung      P1-DIMMA1       16 24         DDR3
        P0_Node0_Channel0_Dimm1 Samsung      P1-DIMMA2       16 24         DDR3
        P0_Node0_Channel1_Dimm0 Samsung      P1-DIMMB1       16 24         DDR3
        P0_Node0_Channel1_Dimm1 Samsung      P1-DIMMB2       16 24         DDR3
        P0_Node0_Channel2_Dimm0 Samsung      P1-DIMMC1       16 24         DDR3
        P1_Node1_Channel2_Dimm0 Samsung      P2-DIMMG1       16 24         DDR3
        P1_Node1_Channel2_Dimm1 Samsung      P2-DIMMG2       16 24         DDR3
        P1_Node1_Channel3_Dimm0 Samsung      P2-DIMMH1       16 24         DDR3
        P1_Node1_Channel3_Dimm1 Samsung      P2-DIMMH2       16 24         DDR3
                                Winbond                  ...625 11         Flash
         

    .NOTES
        NAME:  Get-ESXiMemoryDimms
          
        AUTHOR: Grzegorz Kulikowski
          
        NOT WORKING ? #powercli @ irc.freenode.net 
          
    .LINK
  
https://psvmware.wordpress.com
  
#>
param([String]$Esxi,[string]$rootpw)

#MemoryTypes from: https://msdn.microsoft.com/en-us/library/aa394347(v=vs.85).aspx
$MemHash = @{
'0'='Unknown';
'1'='Other';
'2'='DRAM';
'3'='Synchronous DRAM';
'4'='Cache DRAM';
'5'='EDO';
'6'='EDRAM';
'7'='VRAM';
'8'='SRAM';
'9'='RAM';
'10'='ROM';
'11'='Flash';
'12'='EEPROM';
'13'='FEPROM';
'14'='EPROM';
'15'='CDRAM';
'16'='3DRAM';
'17'='SDRAM';
'18'='SGRAM';
'19'='RDRAM';
'20'='DDR';
'21'='DDR2';
'22'='DDR2 FB-DIMM';
'23'='DDR2 FB-DIMM';
'24'='DDR3';
'25'='FBD2'
}
$pwd = ConvertTo-SecureString $rootpw -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential (“root”, $pwd)
$CIMOpt = New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck -Encoding Utf8 –UseSsl
$Session = New-CimSession -Authentication Basic -Credential $cred -ComputerName $esxi -port 443 -SessionOption $CIMOpt
Get-CimInstance -CimSession $Session CIM_PhysicalMemory | select BankLabel, Manufacturer, Description , @{n='SizeGB';e={$_.Capacity/1GB}}, MemoryType, @{n='MemoryDef';e={$MemHash[$_.MemoryType]}}
}

Searching for VMs with active questions.

for exmaple:
$vms = get-view -viewtype virtualmachine
$vms | ?{$_.runtime.question} | select name

In order to answer
assuming there is 1 question:
($vms | ?{$_.runtime.question}) | %{$_.AnswerVM($_.runtime.question.Id,’0′)}
Where 0 is for Retry because :
PowerCLI C:\> ($vms | ?{$_.runtime.question})[0].runtime.question.Choice.ChoiceInfo

Key : 0
Label : Retry
Summary : Retry

Key : 1
Label : Cancel
Summary : Cancel

So we can answer the question now with:

($vms | ?{$_.runtime.question}) | %{$_.AnswerVM($_.runtime.question.Id,’0′)}

Issues with using the Search option in vsphere client

New-Item -Path HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\KeyExchangeAlgorithms -Name Diffie-Hellman –Force
New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\KeyExchangeAlgorithms\Diffie-Hellman -Value 0x00000200 -PropertyType DWord -Name ‘ClientMinKeyBitLength’

How to get a list of hard disks in ESXi host system ?

That’s the only way so far i have figured out how to do it. Getting the information through CIM.

$esxi = 'myhost'
$CIMOpt = New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck -Encoding Utf8 –UseSsl
$Session = New-CimSession -Authentication Basic -Credential $cred -ComputerName $esxi -port 443 -SessionOption $CIMOpt
Get-CimInstance -CimSession $Session -Namespace 'root/cimv2' -ClassName 'CIM_StorageExtent' | ?{$_.CreationClassName -eq 'HPVC_SAStorageExtent'} | Select PSComputerName, Caption, ElementName
$session.close()

In return i get this:

PSComputerName Caption ElementName
-------------- ------- -----------
esxi01.local.lan Disk 1 on HPSA1 Disk 1 on HPSA1 : Port 1I Box 1 Bay 1 : 136GB : Data Disk
esxi02.local.lan Disk 2 on HPSA1 Disk 2 on HPSA1 : Port 1I Box 1 Bay 2 : 136GB : Data Disk

This will work only for HP in this version as i am filtering output with HPVC_SAStorageExtent
Well, better this than nothing 😉

vLanIdentificator – for checking subnets for Virtual Machines and their vlan info.

I have created this tiny program that will help me sometimes look for other vms that are supposed to sit inside some particular vlan/subnet. The idea is really simple. You are given an ip and somebody is asking you which vlan is that , for example. If you don’t have a hobby of memorizing vlans in your networks might try to use this program. If given a particular IP, and netmask, it will scan all ips within it and check if you have Virtual Machines in Virtual Center that are utilizing ips from that range. In addition it will tell you where the VM is being hosted and which portgroup on esxi hostsystem it is utilizing and of course its vlan id. I hope some of you may find it useful. Executable is prepared for powershell version 3. In general i guess it’s compatible only with >PowerShell 3 , since how i wrote it. I have not tested it yet with Distributed Switches. I have not tested it on other version than vsphere 5.0.If you test it on different version , let me know in the comment. I will make sure it runs ok with vDS as well soon. VMware tools need to be installed in VM in order to report the IP back. This tiny program basically just runs a loop for ips utilizing SearchIndex and its FindAllByIp function. There isn’t much magic happening here 😉 In order to write it i used Get-IPrange by Barry Chum – https://goo.gl/TBYujC IP regex – http://goo.gl/Ow7PFf On the computer on which you want to run it , you will need to have PowerCLI installed. When you are asked for credentials, read-only permission will be enough to retrieve information. Screenshot of how it looks is below. vlanidentificator Executable can be found HERE PSF (Powershell Studio) source code can be found HERE No this is not finished 😉 I am still learning windows forms, so that’s why it looks like it looks. Most important for now , is that it does its job. –Update 21/07/2015 Added support for VMware Distributed Switches Fixed minor bugs