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: Exchange 2010 Server Update & Restart

function stopExchange{ net stop msexchangeadtopology /y net stop msexchangefba /y net stop msftesql-exchange /y net…

Docker DRUPAL Container

# Preseed drupal files with persitent storagemkdir /var/www/html/kimconnect/{modules,profiles,sites,themes}docker run --rm drupal tar -cC /var/www/html/sites .…

Basic CSS: Add a Negative Margin to an Element

<style>.injected-text {margin-bottom: -25px;text-align: center;}.box {border-style: solid;border-color: black;border-width: 5px;text-align: center;}.yellow-box {background-color: yellow;padding: 10px;}.red-box {background-color: crimson;color: #fff;padding:…