Posted On December 21, 2019

PowerShell: Remove Nic Teaming

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Remove Nic Teaming
# Check NIC Teaming
PS C:\Windows\system32> get-NetLbfoTeam
Name : ISCSI
Members : {iSCSI-B, iSCSI-A}
TeamNics : ISCSI
TeamingMode : SwitchIndependent
LoadBalancingAlgorithm : Dynamic
Status : Up

# Get NIC Team object and assign it to a variable
$teamName="ISCSI"
$teamInterface=Get-NetIPAddress -InterfaceAlias $teamName

# Remove IP Address
$teamInterface|Remove-NetIPAddress -Confirm:$false

# Remove Team members
$members=(get-NetLbfoTeam $teamName).Members
$members|%{Remove-NetLbfoTeamMember -Name $_ -Team $teamName -Confirm:$false}

<# error to be expected
Remove-NetLbfoTeamMember : Cannot remove the only member 'iSCSI-A' of team 'ISCSI'
At line:1 char:12
+ $members|%{Remove-NetLbfoTeamMember -Name $_ -Team $teamName -Confirm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (MSFT_NetLbfoTea...E6B0A67E936C}"):root/StandardCi...tLbfoTeamMember) [
Remove-NetLbfoTeamMember], CimException
+ FullyQualifiedErrorId : MI RESULT 4,Remove-NetLbfoTeamMember
#>

# Remove NIC Team
Remove-NetLbfoTeam $teamName -Confirm:$false

# Set IP Address on NIC by its label
$interfaceAlias1="iSCSI-A"
$ipAddress1="1.1.1.1"
$netMask1="24"
$nicInterface1=Get-NetIPAddress -InterfaceAlias $interfaceAlias1
$nicInterface1|Set-NetIPAddress -IPAddress $ipAddress1 -PrefixLength $netMask1
Enable-NetAdapter -Name $interfaceAlias1

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: How To Append to Windows Environmental Paths Permanently

Often, when we install applications such as Python, its bin directory may not automatically be…

Reset Internet Explorer Settings Script

You can reset Internet Explorer settings to return them to the state they were in when…

PowerShell: Quick Script to Get Storage Utilization

$volumes = (gwmi -Class win32_volume -Filter "DriveType!=5" -ea stop| ?{$_.DriveLetter -ne $isnull}|` Select-object @{Name="Letter";Expression={$_.DriveLetter}},` @{Name="Label";Expression={$_.Label}},`…
Other project: DragonCoin.com