Updateded to Show Message to run as administrator. When run without elevated below message would be shown. Which is clear to run as administrator .\set-dockernat-networkategory-to-private.ps1 : The script 'set-dockernat-networkategory-to-private.ps1' cannot be run because it contains a "#requires" statement for running as Administrator. The current Windows PowerShell session is not running as Administrator. Start Windows PowerShell by using the Run as Administrator option, and then try running the script again. At line:1 char:1 + .\set-dockernat-networkategory-to-private.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (set-dockernat-n...-to-private.ps1:String) [], ScriptRequiresException + FullyQualifiedErrorId : ScriptRequiresElevation
3 lines
223 B
PowerShell
3 lines
223 B
PowerShell
#Requires -RunAsAdministrator
|
|
Get-NetConnectionProfile | Where-Object { $_.InterfaceAlias -match "(DockerNAT)" } | ForEach-Object { Set-NetConnectionProfile -InterfaceIndex $_.InterfaceIndex -NetworkCategory Private }
|