It is 5.1. Here is what I did:
1- Create a credential file
New-VICredentialStoreItem -Host 10.1.1.2 -User "administrator@vsphere.local" -Password 'PLAIN_PASSWORD' -File c:\cred.xml
The content of the file is
<?xml version="1.0" encoding="UTF-8"?>
-<viCredentials>
<version>2.0</version>
-<passwordEntry>
<host>10.1.1.2</host>
<username>administrator@vsphere.local</username>
<password>AQAAANCMn.....giL9/phMbbkT/R13kD8Bz9YgKOCOWcDLY=</password>
</passwordEntry>
</viCredentials>
2- Write the following script to modify the notes
$Name = "deh"
$NewDate = "Jun 09"
$vcenter_server ="10.1.1.2"
$Credentials = Get-VICredentialStoreItem -Host $vcenter_server -File C:\pwd.xml
Connect-VIServer $vcenter_server -User $Credentials.User -Password $Credentials.Password
$VMList = Get-VM
Foreach ($vm in $VMList) {
if ($vm.Name -match $Name) {
Set-VM -VM $vm -Note "$NewDate" -Confirm:$false
Write-Host("Updated " + $vm)
}
}
However, I get this output
PS C:\Users\user> C:\Users\user\Desktop\extend.ps1
Name Port User
---- ---- ----
10.1.1.2 443 VSPHERE.LOCAL\Administrator
Set-VM : 5/10/2021 4:34:16 PM Set-VM vSphere single sign-on failed for connection
'/VIServer=vsphere.local\administrator@10.1.1.2:443/' during a previous operation. The current operation requires such
single sign-on and therefore failed. Future operations which require single sign-on on this connection will fail. The
underlying cause was available in the error message which initially reported the single sign-on failure.
At C:\Users\user\Desktop\extend.ps1:11 char:9
+ Set-VM -VM $vm -Note "$NewDate" -Confirm:$false
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-VM], SsoNotAuthenticatedException
+ FullyQualifiedErrorId : VICore_SsoExceptionCausedByEarlierSsoFailure,VMware.VimAutomation.ViCore.Cmdlets.Commands.Set
VM
In the end, I see the notes has been updated. I wonder what is the error...