powershell - How to get the Windows install date of virtual machines in a cluster? -
i have 127 virtual machines in hyper-v cluster 6 nodes. i'm trying nice list of windows install dates each vm using powershell. have far, returns install dates of nodes.
$clusternodes = get-clusternode foreach($item in $clusternodes) { gcim win32_operatingsystem | select name, installdate }
how extend grabs info vms instead of nodes themselves?
i don't have hyper-v host (much less cluster) @ hand, i'd try following:
- enumerate cluster nodes
- enumerate vms on each node
- get network adapter each vm
- expand ip address(es) each adapter , select one
- run
get-wmiobject
query against each selected ip address
something (untested):
get-clusternode -cluster clustername | foreach-object { get-vm -computer $_.name | get-vmnetworkadapter | select-object -expand ipaddresses | where-object { $_ -like '192.168.23.*' } | foreach-object { get-wmiobject -computer $_ -class win32_operatingsystem | select-object __server, name, @{n='installdate';e={$_.converttodatetime($_.installdate)}} } }
the calculated property convert wmi date strings actual datetime
values.
Comments
Post a Comment