I have a couple of Powershell scripts for changing my DNS servers - one for changing the DNS setting to static servers, the other for changing back to DHCP. The scripts run OKfrom Powershell when right-clicking the PS icon and selecting "Run as administrator", and then executing either script succeeds, but if I have a non-administrator PS windows open, and try to run either script via sudo:
"sudo <scriptname>.ps1"
I get this error from either script:
The script itself is really simple:
Any suggestion on a possible fix?
"sudo <scriptname>.ps1"
I get this error from either script:
Code:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS D:\Users\Nick\scripts> sudo .\dnsdhcp.ps1
Unknown error: %1 is not a valid Win32 application. (0x800700C1)
PS D:\Users\Nick\scripts>
The script itself is really simple:
Code:
netsh interface ip set dns "Ethernet" dhcp
ipconfig /flushdns
ipconfig /all | findstr /R "DNS\ Servers"
Any suggestion on a possible fix?
- Windows Build/Version
- 25H2 build 26200.9457
My Computer
At a glance
Windows 11 ProIntel i5-12600K128GbnVidia Quadro P1000
- OS
- Windows 11 Pro
- Computer type
- PC/Desktop
- Manufacturer/Model
- Gigabyte
- CPU
- Intel i5-12600K
- Motherboard
- Z690 Aorus Pro
- Memory
- 128Gb
- Graphics Card(s)
- nVidia Quadro P1000
- Sound Card
- N/A
- Monitor(s) Displays
- BenQ PD3205U, Eizo EV3237
- Screen Resolution
- 3840x2160, 3840x2160
- Hard Drives
- Samsung SSD 980 Pro
Samsung SSD 970 EVO Plus
Sabrent Rocket Q
- Case
- Be Quiet




