VMware Cloud Community
Squigglymonkey
Enthusiast
Enthusiast
Jump to solution

Can powercli pull "Original Install Date:" from the Windows guest?

I am updating the annotations of VM's, one that our management has asked for is the original build date. Can powercli pull the "Original Install Date:" as is listed in systeminfo?

Reply
0 Kudos
1 Solution

Accepted Solutions
kwhornlcs
Enthusiast
Enthusiast
Jump to solution

Sorry about that...pasted an early draft  - try this one:

Get-VM | Where{$_.PowerState -eq 'PoweredOn' -and $_.GuestId -match 'windows'}|Get-View|`

    Select `

    Name,`

    @{N="OS";E={$_.Guest.GuestFullName}},`

    @{N="InstallDate";E={([WMI] "").ConvertToDateTime((Get-WmiObject Win32_OperatingSystem -ComputerName $_.Guest.HostName).InstallDate)}}

View solution in original post

Reply
0 Kudos
4 Replies
kwhornlcs
Enthusiast
Enthusiast
Jump to solution

AFIAK, not direct from powerCLI, but you could do something like this:

Get-VM | Where{$_.PowerState -eq 'PoweredOn' -and $_.GuestId -match 'windows'}|Get-View|`

    Select `

    @{N="Name";E={$_.Guest.HostName}},`

    @{N="OS";E={$_.Guest.GuestFullName}},`

    @{N="InstallDate";E={([WMI] "").ConvertToDateTime((Get-WmiObject Win32_OperatingSystem -ComputerName $_.Guest.HostName).InstallDate)}}

Reply
0 Kudos
Squigglymonkey
Enthusiast
Enthusiast
Jump to solution

Thanks so much for looking at this. When I run this is pulls a lot of information from the VM, and then just displays below.

Capability           : VMware.Vim.VirtualMachineCapability

Config               : VMware.Vim.VirtualMachineConfigInfo

Layout               : VMware.Vim.VirtualMachineFileLayout

LayoutEx             : VMware.Vim.VirtualMachineFileLayoutEx

Storage              : VMware.Vim.VirtualMachineStorageInfo

EnvironmentBrowser   : EnvironmentBrowser-envbrowser-3608

ResourcePool         : ResourcePool-resgroup-34

ParentVApp           :

ResourceConfig       : VMware.Vim.ResourceConfigSpec

Runtime              : VMware.Vim.VirtualMachineRuntimeInfo

Guest                : VMware.Vim.GuestInfo

Summary              : VMware.Vim.VirtualMachineSummary

Datastore            : {Datastore-datastore-458}

Network              : {DistributedVirtualPortgroup-dvportgroup-53}

Snapshot             :

RootSnapshot         : {}

GuestHeartbeatStatus : green

LinkedView           :

Parent               : Folder-group-v3

CustomValue          : {101, 203, 204, 205...}

OverallStatus        : green

ConfigStatus         : green

ConfigIssue          : {}

EffectiveRole        : {-1}

Permission           : {}

Name                 : SYSTEM-NAME

DisabledMethod       : {Destroy_Task, UnregisterVM, UnmountToolsInstaller, AnswerVM...}

RecentTask           : {}

DeclaredAlarmState   : {alarm-10.vm-3608, alarm-106.vm-3608, alarm-11.vm-3608, alarm-2.vm-3608...}

TriggeredAlarmState  : {}

AlarmActionsEnabled  : True

Tag                  : {}

Value                : {101, 203, 204, 205...}

AvailableField       : {CreatedBy, CreatedOn, Environment (Tier1 or Tier2), Location...}

MoRef                : VirtualMachine-vm-3608

Client               : VMware.Vim.VimClientImpl

Key   : N

Value : Name

Name  : N

Key   : E

Value : $_.Guest.HostName

Name  : E

Key   : N

Value : OS

Name  : N

Key   : E

Value : $_.Guest.GuestFullName

Name  : E

Key   : N

Value : InstallDate

Name  : N

Key   : E

Value : ([WMI] "").ConvertToDateTime((Get-WmiObject Win32_OperatingSystem -ComputerName $_.Guest.HostName).InstallDate)

Name  : E

Reply
0 Kudos
kwhornlcs
Enthusiast
Enthusiast
Jump to solution

Sorry about that...pasted an early draft  - try this one:

Get-VM | Where{$_.PowerState -eq 'PoweredOn' -and $_.GuestId -match 'windows'}|Get-View|`

    Select `

    Name,`

    @{N="OS";E={$_.Guest.GuestFullName}},`

    @{N="InstallDate";E={([WMI] "").ConvertToDateTime((Get-WmiObject Win32_OperatingSystem -ComputerName $_.Guest.HostName).InstallDate)}}

Reply
0 Kudos
Squigglymonkey
Enthusiast
Enthusiast
Jump to solution

Almost perfect for me, I added |ft -auto as the dates were getting truncated. Otherwise perfect thank you!

Reply
0 Kudos