VMware Cloud Community
Akopylov
Commander
Commander
Jump to solution

vpxd.motd

Hello there.

I want to modify vCenter web client mesasge of the day periodically, but it seems, that this advanced setting is read-only.

PS C:\Users\agkopyl1> Get-AdvancedSetting -Entity $vc -name "*vpxd.mot*" | Set-AdvancedSetting -Value "Test2"

Perform operation?

Modifying advanced setting 'vpxd.motd'.

[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y

Set-AdvancedSetting : 26-Mar-20 21:47:36        Set-AdvancedSetting             The value of the specified advanced setting 'vpxd.motd' is read only.

At line:1 char:54

+ ... g -Entity $vc -name "*vpxd.mot*" | Set-AdvancedSetting -Value "Test2"

+                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [Set-AdvancedSetting], ViError

    + FullyQualifiedErrorId : Client20_SystemManagementServiceImpl_UpdateVIServerAdvancedSetting_ReadOnly,VMware.VimAutomation.ViCore.Cmdlets.Commands.SetAdvancedSetting

I'm pretty sure, there should be a way to do this.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I see, try like this

$si = Get-View ServiceInstance -Server $global:DefaultVIServer  

$sessMgr = Get-View -Id $si.Content.SessionManager -Server $global:DefaultVIServer 

$sessMgr.Message

$sessMgr.UpdateServiceMessage("MyTest")

$sessMgr.UpdateViewData()

$sessMgr.Message


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

View solution in original post

0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

There is, try like this

Get-AdvancedSetting -Entity $global:DefaultVIServer -Name 'etc.motd' |

Set-AdvancedSetting -Value "Test line1`nTest line 2`n" -Confirm:$false


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

0 Kudos
Akopylov
Commander
Commander
Jump to solution

Hello.

I'm looking for a way to change the message in a web client:

pastedImage_0.png

etc.motd is a shell banner.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I see, try like this

$si = Get-View ServiceInstance -Server $global:DefaultVIServer  

$sessMgr = Get-View -Id $si.Content.SessionManager -Server $global:DefaultVIServer 

$sessMgr.Message

$sessMgr.UpdateServiceMessage("MyTest")

$sessMgr.UpdateViewData()

$sessMgr.Message


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

0 Kudos
Akopylov
Commander
Commander
Jump to solution

Yep, this works. Thank you.

Well, may be you can answer one more question: I'm trying to measure script execution time with ($endtime - $starttime).someproperty

#Update vCenter message of the day

$si = Get-View ServiceInstance -Server $vcenter 

$sessMgr = Get-View -Id $si.Content.SessionManager -Server $vcenter

$executionmins = $($EndTime - $StartTime).Minutes

$executionsecs = $($EndTime - $StartTime).Seconds

$sessMgr.UpdateServiceMessage("IOPS robot last run finished at $EndTime. This script took $executionmins minutes $executionsecs seconds to execute.")

And this is what I get:

pastedImage_0.png

How so?

Also:

PS C:\Users\saiopsuser> echo "IOPS robot last run finished at $EndTime. This script took $(($EndTime - $StartTime).Minutes) minutes $(($EndTime - $StartTime).Seconds) seconds to execute."

IOPS robot last run finished at 03/27/2020 13:52:56. This script took 0 minutes 17 seconds to execute.

But if I try it in script, then I get:

pastedImage_2.png

0 Kudos
Akopylov
Commander
Commander
Jump to solution

Nvm, it's my fault, put $endtime = get-date in a bas spot.

Also found the way of stopwatch, which is seems to be much better.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You could also use Measure-Command.
With your script on the Expression parameter


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