Before upgrading my NSX-T nodes I wanted to take a snapshot. To my surprise, I was not able to do so, as I received an error message: Exceeded the maximum number of permitted snapshots. There were no snapshots for this particular virtual machine.
Having looked at the KB provided by VMware I learned that settings snapshot.maxSnapshots must be set to 0 to disable taking snapshots. However, as I am running vSphere 7.0 this setting is not listed by default in the Edit Settings menu of the virtual machine.
PowerShell to the rescue!
Hence I would need to manually enter this configuration setting and I have three nodes, I wrote a quick script to do it for me:
Disconnect-viserver *
Connect-VIServer hostname/IP_of_your_vCenter
What I like to do is to run the disconnect
command to make sure I would not have any duplication sessions. And next to connect to vCenter.
$snapcheck = Get-VM | where name -Like "*nsxt*"
Now I am looking for all my NSX-T nodes. Once I have them in my $snapcheck
variable I will do a test to see if this snapshot.maxSnapshots setting exist:
foreach ($snap in $snapcheck) {
$test = $snapcheck | Get-AdvancedSetting ‘snapshot.maxSnapshots’
If the napshot.maxSnapshots doesn’t exist, I will create new settings by using New-AdvanceSetting and set the value to 1. Otherwise, I will change it to value 1 where it’s not equal to 1.
if ($test -eq $null) {
New-AdvancedSetting -Name snapshot.maxSnapshots -Value 1 -Entity -Confirm:$false -Force:$true
}
else {
$test | where value -ne 1 | Set-AdvancedSetting -Value 1 -Confirm:$false
}
}
The full script is on my Github repository, please feel free to download
Please like and share to spread the knowledge in the community.
If you want to chat with me please use Twitter: @AngrySysOps
Join my VMware Knowledge Base Group: https://bit.ly/3w54tbc
Visit my FB page: https://www.facebook.com/AngrySysOps
Subscribe to my channel: https://bit.ly/3vY16CT
TikTok: https://www.tiktok.com/@angrysysops.com