When I run the code you sent I get this error:
ERROR:
Invoke-RestMethod: {
"httpStatus" : "BAD_REQUEST",
"error_code" : 220,
"module_name" : "common-services",
"error_message" : "Unexpected character (']' (code 93)): expected a value"
CODE:
#############################
# Connect to vCenter #
#############################
Import-Module -Name VMware.PowerCLI
Set-PowerCLIConfiguration -DisplayDeprecationWarnings $false -InvalidCertificateAction ignore -confirm:$false
$vc = 'URL'
$Cred = Import-Clixml /home/scripts/creds/creds.xml
Connect-VIServer $VC -Credential $Cred
#############################
# Connect to NSX-T #
#############################
Import-Module -Name VMware.PowerCLI
Import-Module PowerNSX
Set-PowerCLIConfiguration -DisplayDeprecationWarnings $false -InvalidCertificateAction ignore -confirm:$false
$NSXCred = Import-Clixml /home/scripts/creds/nsxt.xml
$skipcertcheck = $true
$AuthMethod = “Basic”
$NSXMgr = ”URL”
$policyapi = "/policy/api/v1"
$base_url = ( "https://" + $NSXMgr + $policyapi )
$posturl = "https://$NSXMgr/api/v1/fabric/virtual-machines?action=update_tags"
$NSXTag = 'TAG'
$vmName = 'SINGLE VM'
$vm = Get-VM -Name $vmName
$vmid = $vm.ExtensionData.Config.InstanceUuid
$geturl = "https://$NSXMgr/api/v1/fabric/virtual-machines?external_id=$vmid&included_fields=tags"
$getrequest = Invoke-RestMethod -Uri $geturl -Authentication Basic -Credential $nsxcred -Method Get -ContentType "application/json" -SkipCertificateCheck
$getresult = $getrequest.results | ConvertTo-Json -Compress
$currenttags = [regex]::match($getresult,'\[([^\)]+)\]').Groups[1].Value
$JSON = @"
{"external_id":"$vmid","tags": [{"scope":"$newscope","tag":"$NSXTag"},$currenttags]}
"@
Invoke-RestMethod -Uri $posturl -Authentication Basic -Credential $NSXCred -Method Post -Body $JSON -ContentType "application/json" -SkipCertificateCheck