vmware-archive / powernsx

PowerShell module that abstracts the VMware NSX-v API to a set of easily used PowerShell functions
173 stars 89 forks source link

Rename Logical Switch #586

Closed CernSteve closed 5 years ago

CernSteve commented 5 years ago

I may be missing it but we need need to mass re-name Logical Switches. I see how to get, remove, and create but not modify. Any thoughts?

alagoutte commented 5 years ago

Hi Steve,

Yes, it is not possible for the moment... but you can try this (not tested..)

$ls = Get-NsxTransportZone | Get-NsxLogicalSwitch MyLogicalSwitch
$ls.name = "new name"
$uri = "/api/2.0/vdn/virtualwires/$($ls.ObjectId)"
Invoke-NSXWebRequest -method "put" -uri $uri -body $ls.OuterXml
CernSteve commented 5 years ago

Thanks for the update we'll give that a shot.

alagoutte commented 5 years ago

working ?

alagoutte commented 5 years ago

Fixed a typo on -body (need to use XML output...)

CernSteve commented 5 years ago

Thanks for the update! We are in the process of testing here in a week or two. I'll let you know what we run into.

justinmossb commented 5 years ago

Sorry for the delay in our response. However, the script worked really well. I used this code in a larger script that loaded a csv file with the old names and new names and was able to do a mass rename without issues.

alagoutte commented 5 years ago

@justinmossb Thanks for feedback

the next release with be include a Set-NsxLogicalSwitch (See #587)