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.
I see, try like this
$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
There is, try like this
Set-AdvancedSetting -Value "Test line1`nTest line 2`n" -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello.
I'm looking for a way to change the message in a web client:
etc.motd is a shell banner.
I see, try like this
$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
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:
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:
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.
You could also use Measure-Command.
With your script on the Expression parameter
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference