Skip to content
www.mytechnote.ru
Menu
  • Administration
    • Scripts
  • Equipment
    • Reviews
    • Instructions
  • Other
  • English
    • English
    • Русский
Menu

Managing local ESXi users with PowerCli

In todays short article, I want to show you a couple of examples of managing local Esxi users, with the help of PowerShell – PowerCli and EsxCli.

Connect-VIServer -Server vcenter.some.domain
#for example, we want to make some action on all hosts in the cluster
$hosts=Get-Cluster ClusterName | Get-VMHost
foreach ($vmhost in $hosts){
    $esxcli = Get-EsxCli -VMHost $vmhost.name -V2
    $esxcli.system.account.list.invoke()
    #you can add examples below to that cycle
}
#adding a user
$esxcli = Get-EsxCli -VMHost $vmhost.name -V2
$sAccount = $esxcli.system.account.add.CreateArgs()
$sAccount.Item('description') = 'Test account'
$sAccount.Item('password') = 'verysecretp@ss!@#A'
$sAccount.Item('passwordconfirmation') = 'verysecretp@ss!@#A'
$sAccount.Item('id') = 'test_user'
$esxcli.system.account.add.Invoke($sAccount)

#set a role to the user
$sRole = $esxcli.system.permission.set.CreateArgs()
$sRole.id = 'test_user'
$sRole.role = 'Admin'
$esxcli.system.permission.set.Invoke($sRole)

#update password
$sAccount = $esxcli.system.account.set.CreateArgs()
$sAccount.id = "test_user"
$sAccount.password = "verysecretp@ss!@#A"
$sAccount.passwordconfirmation = "verysecretp@ss!@#A"
$esxcli.system.account.set.Invoke($sAccount)

#remove user
$sAccount = $esxcli.system.account.remove.CreateArgs()
$sAccount.id = "test_user"
$esxcli.system.account.remove.Invoke($sAccount)

 

Posted on 10.03.202330.05.2024 by sanglyb

Post navigation

← Searching where a user is logged on [PowerShell]
Restoring a datastore in vCenter: A Step-by-Step Guide →

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Подписывайтесь

Youtube
vk
telegram
github
twitter
rss
  • Форум
  • Об авторе
  • Поддержать автора

Популярные записи

Новые записи

  • How to Extend an LVM Partition in Linux
  • SCCM Reporting Errors After Migrating from SQL Server 2016 to 2019
  • Problem Using PassFiltEx on Older CPUs
  • How to remove attachments from old calendar events in Exchange using a script
  • How to download and install Office 2024 LTSC

Архивы

  • 2026 (3)
  • 2025 (5)
  • 2024 (7)
  • 2023 (30)
  • 2022 (4)
  • 2020 (17)
  • 2017 (82)
  • 2016 (5)
© 2015-2026 www.mytechnote.ru
Использование материалов сайта возможно только с разрешения владельца или обязательна индексируемая, прямая, передающая вес ссылка на материал.