Remove-HostNetworkAdapter
VMware: Removes the specified host network adapter
#Requires -Version 5.1
#Requires -Modules VMware.VimAutomation.Core
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$VIServer,
[Parameter(Mandatory = $true)]
[pscredential]$VICredential,
[Parameter(Mandatory = $true)]
[string]$HostName,
[Parameter(Mandatory = $true)]
[string]$AdapterName
)
Process {
$vmServer = $null
try {
$vmServer = Connect-VIServer -Server $VIServer -Credential $VICredential -ErrorAction Stop
$vAdapter = Get-VMHostNetworkAdapter -Server $vmServer -Name $AdapterName -VMHost $HostName -ErrorAction Stop
$null = Remove-VMHostNetworkAdapter -Nic $vAdapter -Confirm:$false -ErrorAction Stop
$output = [PSCustomObject]@{
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
Status = "Success"
Message = "Adapter $AdapterName successfully removed"
}
Write-Output $output
}
catch { throw }
finally { if ($null -ne $vmServer) { Disconnect-VIServer -Server $vmServer -Force -Confirm:$false -ErrorAction SilentlyContinue } }
}IP address or DNS name of the vSphere server
PSCredential object for authenticating with the server
Name of the host whose network adapter to remove
Name of the host network adapter to remove