VMware Cloud Community
VIToolkit
Contributor
Contributor

Count VMs with users Logged On

Hello everybody,

I was trying to get the number of VMs in my datacenter that have a user logged on themselves.

I´ve seen this command:

Get-VM | Where-Object { $_.powerstate -eq 'PoweredOn' } | measure-object | Select Count

But I want to exclude from this query those that do not have a user logged On

It would be possible to do this?

Thaks

0 Kudos
4 Replies
halr9000
Commander
Commander

Well, the concept of a user being logged on is specific to the operating system of the Guest OSs in each VM. VI does not have any visibility into that type of data. Or do you mean to look at who has the VI console open for a VM?






[PowerShell MVP|https://mvp.support.microsoft.com/profile=5547F213-A069-45F8-B5D1-17E5BD3F362F], VI Toolkit forum moderator

Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
0 Kudos
VIToolkit
Contributor
Contributor

Hi halr,

I was not referring to the VI console. I supouse that i woluld be dificult to achieve it but I was trying to see the number of the VMs with a user logged on to compare with the total VMs in my datacenter to obtain a percentage of use.

Thaks for the aswer anycase

0 Kudos
halr9000
Commander
Commander

What guest OSs are we talking about? I didn't say it couldn't be done, I just wanted to narrow down the scope.






[PowerShell MVP|https://mvp.support.microsoft.com/profile=5547F213-A069-45F8-B5D1-17E5BD3F362F], VI Toolkit forum moderator

Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
0 Kudos
VIToolkit
Contributor
Contributor

I'm working with a VDI platform and they are all Windows XP with SP2 or SP3 Operating Systems. Also I have some Windows Server 2003.

Thanks

0 Kudos