charismea
Goto Top

REG DWORD Managed in aktuell geladenem Netzwerkprofil via PowerShell ändern

Hallo Zusammen

Ich versuche ein PowerShell-Script zu erstellen, welches das unter Windows aktuell aktive Netzwerkprofil ausliest und dann in diesem den "REG_DWORD Managed" auf den Wert "1" stellt.
screenshot 2022-02-06 130828

Den Wert "Category" kann man ja direkt via PowerShell beeinflussen, damit man z.B von Öffentlich auf Privat umschalten kann.

Habt ihr hier irgendwelche Ideen, wie dies gehen könnte?

Ich danke für Feedbacks

Content-Key: 1846455800

Url: https://administrator.de/contentid/1846455800

Printed on: April 26, 2024 at 04:04 o'clock

Member: colinardo
Solution colinardo Feb 06, 2022 updated at 15:58:01 (UTC)
Goto Top
Servus @Charismea, willkommen auf Administrator.de!
# restart script elevated if needed
if(!(new-object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole(544)){start powershell -Verb runas -ArgumentList '-File',$MyInvocation.MyCommand.Definition;exit}  
# get current profile name
$currentprofile = (Get-NetConnectionProfile).Name
# set managed key in registry
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles' | ?{$_.GetValue('ProfileName') -eq $currentprofile} | %{Set-ItemProperty $_.PsPath -Name Managed -Value 1}  
Grüße Uwe
Member: Charismea
Charismea Feb 06, 2022 at 19:50:11 (UTC)
Goto Top
Danke danke danke, es funktioniert genau so wie ich mir dies vorgestellt habe