Automation

 View Only
  • 1.  Add server name when listing local user accounts

    Posted Dec 19, 2014 05:17 PM

    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?    



  • 2.  RE: Add server name when listing local user accounts
    Best Answer

    Posted Dec 19, 2014 05:49 PM

    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



  • 3.  RE: Add server name when listing local user accounts

    Posted Dec 22, 2014 03:38 PM

    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.



  • 4.  RE: Add server name when listing local user accounts

    Posted Dec 22, 2014 04:30 PM

    Can't you retrieve the passwords from a source (CSV file, database query...) ?



  • 5.  RE: Add server name when listing local user accounts

    Posted Dec 22, 2014 09:08 PM

    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?    



  • 6.  RE: Add server name when listing local user accounts

    Posted Dec 22, 2014 10:29 PM

    Yes, the Connect-VIServer cmdlet accepts an array on the Server parameter.