Disable Nics on server level....

rated by 0 users
Not Answered This post has 0 verified answers | 4 Replies | 1 Follower

Not Ranked
5 Posts
srkrish posted on 03-30-2012 1:20 PM

Hi powershell,


am very new to powershell scripting,as a windows adminstrator.

i want to disable the NIC cards of a partilcuar server.The server list listed on a one notepad,

we can read the server name from notepad,then what ever the servers listed the particlur server nic will disabled.

here really i dont have idea regarding how to disbale the nic of specified server on a cluster.

one of my peermate told to me....each server have 1 to 3 nic configued on server.



Thanks for any information you can provide.. I respect your powershell forum opinion as I have watched you help so many folks on the web.

 I also have your forums which have help me a great deal.


Thanks in advance..


All Replies

Top 25 Contributor
296 Posts
Microsoft MVP
Top Contributor

A few questions - do you want to disable all NICs on the server or just some of them?

A cluster could have a number of NICs for each server - public, private and management networks fro instance. If you disable the NICs on a server in a cluster the cluster won't work properly.  What are you trying to achieve by disabling the NICs

Not Ranked
5 Posts

Am very happy to see  the reply..Thank you..RSiddaway..


just i want to disable the NICs in a particular server .the servers list listed on a notepad..

i have below code ,please colud you help me,how i can run, this....code....thanks in advance..


your ask me about wht achieve ....be frankly ...am a very new to windows admin side....my manager told to me this.......

am fighting to crack this NIC disable in server level....please let me out.....Thanks in advance,...


$computername = Get-Content 'list.txt'

ForEach ($Computer in $computername) {

    Try {

        $Index = Get-WmiObject -Computername $computer win32_networkadapterconfiguration -Filter "IPEnabled='True'" -EA Stop | Select -expand Index

        Get-Wmiobject -Computer computer Win32_NetworkAdapter -Filter "Index !='$index'" -EA Stop | ForEach {

            $nic = $_

            Write-Host ("{0}: Disabling" -f $nic.Name)

            Switch ($nic.Disable()) {

                0 {Write-Host ("{0}: Succesfully disabled!" -f $nic.Name) -Fore Green -Back Black}

                Default {Write-Warning ("{0}: Something happened! Return Value: {1}" -f $nic.name,$_)}



    } Catch {

        Write-Warning ("{0}: {1}" -f $Computer, $_.Exception.Message)



Not Ranked
5 Posts

hi siddaway,


Thank you for giving respond,I was tested  below code,i got the below errors,please colud you help me.
WARNING: USTO277895: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
Thank you,

Top 10 Contributor
655 Posts
Microsoft MVP
Top Contributor

RPC errors = the machine you are trying to connect to does not answer, either because it is not online, or because a firewall blocks access.

Page 1 of 1 (5 items) | RSS
Copyright 2012 PowerShell.com. All rights reserved.