VMware Cloud Community
JPM00
Contributor
Contributor

Powershell 5.1 and Export-VDSwitch creates unusable file

Using Powershell 5.1 and PowerCLI 12.7 or 13.0 along with Export-VDSwitch to backup a vDS generates a .zip file without error, but when trying to use that file to Import Distributed Switch results in the error "Select a valid distributed switch backup to proceed."

Using the same computer and same commands, but using Powershell 7.3 with PowerCLI 13.0 generates a backup file that is usable by vCenter 7.0 U3 to import a distributed switch.

Unsure at this time what is different between the files, but concerning that it looks to generate a file properly, but it is not actually usable to restore.

0 Kudos
7 Replies
LucD
Leadership
Leadership

Did you open an SR?

Update: just tested the process, works perfectly for me with PSv5.1 in vSphere 7


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
JPM00
Contributor
Contributor

I just opened 22385911812 and attached example files there.

I've used 2 different computers joined to different domains with the same results, and I'm pretty sure I also tried different vCenters and vDS

On a Windows Powershell 5.1 with PowerCLI 12.5 it is working as expected for me.

Hopefully it is just something in my environment.

Here is the exact code block I'm using:

$FormattedTime = (Get-Date).ToString("yyyy-MM-dd-hh-mm")
$OutputPath = "C:\temp"
foreach ($vdswitch in (Get-VDSwitch)) {
Export-VDSwitch -VDSwitch $vdswitch -Destination "$OutputPath\vDS-$($vdswitch.name)-$FormattedTime.zip" -Force
}
0 Kudos
LucD
Leadership
Leadership

I used.
I let the cmdlet create the name of the ZIP file.
And I restored to a different Datacenter

PowerCLI 13.0.0.20829139
PS 5.1.19041.1682
vSphere 7.0.3 build 20395099

Get-VDSwitch -name vdSw1 | Export-VDSwitch -Destination C:\Temp
New-VDSwitch -Name TestVD -BackupPath 'C:\Temp\vdSW1 - 2022-12-02 17h 15m.backup.zip' -Location DC

.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
JPM00
Contributor
Contributor

Can you try to import the switch inside of the HTML interface?

Right click on the DC>Distributed Switch>Import Distributed Switch

and use the same zip file?

When I use New-VDSwitch like you showed, it does seem to accept it (complains about an existing port-group), but using the GUI, I can even get that far since it says "Select a valid distributed switch backup to proceed."

0 Kudos
LucD
Leadership
Leadership

I get the same error when I try to use the ZIP file from the Web GUI.

After looking into the ZIP files, one created with PowerCLI and one created from the Web Gui, it looks as if the problem is in the META-INF/data.xml files.
The one generated with PowerCLI seems to be using the WSDL format, while the one generated from the Web GUI seems to be using the NASSL format.

Looks like you can only use exportd from the Web GUI via the Web GUI, and similar for the ones from PowerCLI.
Seems the PowerCLI Team has to talk with the Web GUI Team, and vice-versa.

META file from PowerCLI

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://vmware.com/vds/envelope/1">

META file from the Web GUI

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:Envelope xmlns:ns1="http://vmware.com/vds/envelope/1">





Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
JPM00
Contributor
Contributor

Working with support we found something even stranger.

If we take the .zip file created by PS5.1 and expand it, and then zip it up again, with no changes to the files, then it imports in the web GUI without issue.

And as far as the concern that you can only use a file exported from web GUI to import to web GUI, I don't think that is fully accurate, because if I create the zip with PS7, it imports in the GUI just fine.

0 Kudos
LucD
Leadership
Leadership

Then it is probably related to how the META XML file is generated in PSv5.1


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos