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: Windows Automated Disk Cleanup

##################################################################################     <#      This script is created to automate the cleanup activity. Doing so will benefit to reduce the size of disk.     This script will perform the following   1. Clear windows temp and user temp folder   2. Empty recycle bin   3. Disk Cleanup   4. Clear CBS cabinet log files   5. Clear downloaded patches   6. Clear downloaded driver   7. Clean download folder      Note:  …

PowerShell: Compare Time Stamps of Items in Mirroring Directories

# compareTimeStamps.ps1# Set variables$source="T:\DIRECTORY1"$destination="\\FILESHERVER\DIRECTORY1"$sampleSize=100$logFile="\\FILESHERVER\SHERVER1\sampleTimeStampLog.txt"function sampleTimeStamp{ param( [string]$sourceDirectory=$source, [string]$destinationDirectory=$destination, [int]$sampleCount=$sampleSize, [string]$timeStampLog=$logFile ) $timeStampTimer=[System.Diagnostics.Stopwatch]::StartNew() # Enable Remote…

How To Run Python Interactive Command Line Mode (CLI)

Windows PS C:\WINDOWS\system32> python Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit…
Other project: DragonCoin.com