Thanks. I had a couple of days off. Sometimes, I find that sometimes I look for the solution in the most complicated places!
Easier with your suggestion:
($SwitchVersion and $SwitchNotes as optional script parameters)
$SwitchParams = @{
Server = $vCenter
Name = $SwitchName
Location = $Location
NumUplinkPorts = $NumUplinks
Mtu = $DefaultMtu
LinkDiscoveryProtocol = $LinkDiscoveryProtocol
LinkDiscoveryProtocolOperation = $LinkDiscoveryProtocolOperation
}
if ($SwitchVersion) {$SwitchParams.Add('Version',$SwitchVersion)}
if ($SwitchNotes) {$SwitchParams.Add('Notes',$SwitchNotes)}
$VDSwitch = New-VDSwitch @SwitchParams
Simples!
Steve