VMware Cloud Community
NeenaJim
Enthusiast
Enthusiast
Jump to solution

Powercli in Powershll

Hello,

I am new to scripting world.

Is there anyway I can use the powercli commands in powershell?

I was trying to add welcome note for an ESXi host via powershell by the below commands. And I am struggling for that. Can someone please help me how to do it via powershell (not via putty)

$esxcli = Get-EsxCli -VMhost <ESXi host name> -V2

$esxcli.system.settings.advanced.welcomemsg.get()

$esxcli.system.settings.advanced.welcomemsg.set('Hi')

NeenaJim_0-1645480010634.png

This is what I am getting:

NeenaJim_0-1645480632214.png

 

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

When you use the V2 switch, you have to use the Invoke() method
The parameters are passed in a hash table (for which you can get a template with the CreateArgs() method)

$esxcli = Get-EsxCli -VMhost <ESXi host name> -V2
$esxcli.system.welcomemsg.get.Invoke()
$esxcli.system.welcomemsg.set.Invoke(@{message='Hi'})

.
 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

When you use the V2 switch, you have to use the Invoke() method
The parameters are passed in a hash table (for which you can get a template with the CreateArgs() method)

$esxcli = Get-EsxCli -VMhost <ESXi host name> -V2
$esxcli.system.welcomemsg.get.Invoke()
$esxcli.system.welcomemsg.set.Invoke(@{message='Hi'})

.
 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
NeenaJim
Enthusiast
Enthusiast
Jump to solution

That works. Thank you very much. You the BEST!

Reply
0 Kudos