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

Manually Create a SSL Certificate with LetsEncrypt

Step 1: Install certbot-auto mkdir /etc/letsencryptcd /etc/letsencrypt/wget chmod a+x certbot-auto Step 2: Create the Cert…

PowerShell: Fix All VMs CPU Compatibility Setting

# fixAllVmCpuCompatibility.ps1 # version 0.01 function getHyperVHostsInForest{ function includeRSAT{ $ErrorActionPreference='stop' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 #$rsatWindows7x32='https://download.microsoft.com/download/4/F/7/4F71806A-1C56-4EF2-9B4F-9870C4CFD2EE/Windows6.1-KB958830-x86-RefreshPkg.msu' $rsatWindows7x64='https://download.microsoft.com/download/4/F/7/4F71806A-1C56-4EF2-9B4F-9870C4CFD2EE/Windows6.1-KB958830-x64-RefreshPkg.msu'…

PowerShell: Hyper-V Guest-VM C-Volume Expansion

# Hyper-V-Guest-VM-Volume-Expansion.ps1 # Set variables: $vmName="TESTWindows.intranet.kimconnect.net"; $driveLetter="C"; $newSize="160GB"; function selectDisk($vmname){ $paths=(get-vm $vmName | select -expand…
Other project: DragonCoin.com