- <#
- .SYNOPSIS
- Disables active network cards
- .DESCRIPTION
- This script looks at each network card that is currently IP enabled, and
- disables it by releasing the DHCP Lease. To re-enable the network interrace,
- you just run IPCONFIG /RENEW.
- This script is an MSDN Sample, rewritten using PowerShell
- .NOTES
- File Name : Disable-NetworkCard.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- PowerShell script posted to:
- http://pshscripts.blogspot.com/2009/02/disable-networkcardps1.html
- Original MSDN Sample at:
- http://msdn.microsoft.com/en-us/library/aa394595(VS.85).aspx
- .EXAMPLE
- PSH [C:\foo]: .\Disable-NetworkCard.ps1
- Releasing lease on: [00000006] Broadcom NetXtreme Gigabit Ethernet
- Releasing lease on: [00000012] Microsoft Virtual Network switch Adapte
- #>
- ###
- # Starting Script
- ###
- $Computer = "."
- $net = Get-WMIObject -class Win32_NetworkAdapterConfiguration -ComputerName $computer
- $netenabled = $net | where {$_.IPenabled}
- foreach ($NetCard in $netenabled) {
- "Releasing lease on: {0}" -f $netcard.caption
- $netcard.ReleaseDHCPLease()
- }
- # End of Script
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Saturday 7 February 2009
Disable-NetworkCard.ps1
Subscribe to:
Post Comments (Atom)
1 comment:
I wouldn't really consider a script which disabled the NIC, rather a script which releases an IP from an NIC. A disabler would truely disable the device
Post a Comment