3

My network card is rubbish and until I get a new one I need a quickfix. My idea was to have a program ping my router and when the ping failed 3 or 4 times, it would reset the network adaptor for my wifi card, however I do not know the command line commands to do this!

I found the following in a stackoverflow question:

$adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like "*Wireless*"}
$adaptor.Disable()
$adaptor.Enable()

However to run this the script needs to be running under admin privileges and I do not know how to fix that without manually launchign powershell to execute the script

1 Answer 1

5

This post shows how to elevate PowerShell scripts to Administrator access:

Elevate Powershell scripts

To do it, you create a scheduled task (without a set schedule), and set it to run elevated. Then, give your users rights to execute that task. This blog post describes the process in more detail:

http://huddledmasses.org/vista-setuid-how-to-elevate-without-prompting/

In addition, here is a blog post that goes over the Win32_NetworkAdapter class, and how to use it in PowerShell, in detail:

Using PowerShell to Manage Network Interfaces and Windows Services http://rickgaribay.net/archive/2008/09/26/using-powershell-to-manage-network-interfaces-and-windows-services.aspx

Sign up to request clarification or add additional context in comments.

1 Comment

The post by Rick is deprecated and works up until PS5.1 because it uses gwmi and not gcmi.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.