Author Posts

December 6, 2017 at 11:03 am

Hi, I need this command to be repeated. When someone accidentally allows the adapter to always deactivate. At the same time it is confirmed by automatic. (Yes to All)

I have this

Get-NetAdapter -physical | where status -eq 'up' | Disable-NetAdapter


December 6, 2017 at 11:08 am

So you want this to run without confirmation? if so adding -Force to the script will tell powershell "hey, i know what im doing, run the command and trust me"

December 6, 2017 at 11:12 am

Parameter -Force does not work :/

December 6, 2017 at 11:23 am

I got IT! With this Disable-NetAdapter –Confirm:$False. But I need help with repeating when someone allow the adapter so I need disable it again.

December 6, 2017 at 11:43 am

Is this something not more suited to Group Policy? As you would need a script to actively listen for that event to occur, then run itself – Something which is beyond me im afraid!

December 6, 2017 at 3:01 pm

Is their an event generated when the adapter is turned on? If so write a scheduled task with a trigger of that event ID to run your script to disable the adapter.

December 7, 2017 at 8:11 am

Now I need to run the script silently with Task manager. In order not to see it started. I dont know which argue I should use.

December 7, 2017 at 11:53 pm

Any process / task will show up in Task Manager.
Why are you trying to hide it?
If you mean hide the PowerShell Console or ISE Window, you just need to minimize it using the hidden option.

Start-Process -WindowStyle hidden -FilePath notepad.exe
PowerShell.exe -windowstyle hidden { your script.. }

One more thing. about doing this as a scheduled task. Scripts can/will run silently without -WindowStyle Hidden if the task is set to Run whether user is logged on or not on the General tab under "Security Options" section.

Yet, as noted, GPO or PowerShell DSC is a more enterprise solution for this sort of thing.

GPO example:
Under User Configuration > Administrative Templates > Network > Network Connections
you will find numerous settings to help you secure the LAN connections.
Prohibit access to the Properties of a LAN connection should do it for you.
It will greyed out the option to change. Yet, if they are savvy, the can just drop
to the command line and use netsh, powershell, vbscript to mess wiht stuff.

So, this also means you have to ensure these folsk doing tis are not local admins.