This has to be an easy one, and maybe I have been looking at the screen for too long today? I am setting up an automated script to run once a month that simply just looks and the local accounts on each hosts and sends the output to a file. I can use Get-Vmhost | foreach {get--viaccount} which outputs the ID and description of each user on every host attached to my vCenter, but it just runs them all together. I need to get the server name in there on each one so I know which host the ID belongs to?
The VIAccount object which is returned by Get-VIAccount, has more properties, including the Server property.
From there you should be able to extract the servername.
Note that you need to be connected to the ESXi server, to retrieve the local accounts from the ESXi server.
Otherwise you will get the vCenter accounts
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The VIAccount object which is returned by Get-VIAccount, has more properties, including the Server property.
From there you should be able to extract the servername.
Note that you need to be connected to the ESXi server, to retrieve the local accounts from the ESXi server.
Otherwise you will get the vCenter accounts
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the reply Luc and I was so hoping that would work.This is a unique situation for sure.The hosts in question are in lockdown mode and have unique passwords so attaching to the local host is not simple. I initially started down that road and I have a script that will turn the lockdown mode off/on created, but the passwords are another issue entirely since there are 150 of them.
Can't you retrieve the passwords from a source (CSV file, database query...) ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It's been a long week 🙂 I forgot that I have AD authentication on those hosts, so it looks like I am good there and I don't need to worry about the multiple password issue. Can I connect to multiple ESXi servers using a list? I am thinking I can run a get-vmhost and pipe that to a variable and use it to call the server names, connect to each one and then run the get-viaccount and output the result to a txt file?
Yes, the Connect-VIServer cmdlet accepts an array on the Server parameter.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference