有人可以帮我创建一个可与 Windows 10 Enterprise 一起使用的 PowerShell 脚本,该脚本将DWORD
的值更改ConnectionType
为1
,并将下的用户注册表中的DWORD
的值更改DeferFlags
为。4
HKCU:\Network\[drive letter]
以下是我尝试过的但无法正常工作的方法
$registryPath = "HKCU\Network\G"
$Name = "Connection Type"
$value = "0"
IF(!(Test-Path HKCU\Network\G))
{
New-Item -Path "HKCU\Network\G" -Force | Out-Null
New-ItemProperty -Path "HKCU\Network\G" -Name "Connection Type" -Value 1 `
-PropertyType DWORD -Force | Out-Null}
ELSE {
New-ItemProperty -Path "HKCU\Network\G" -Name "Connection Type" -Value 1 `
-PropertyType DWORD -Force | Out-Null}
答案1
您几乎已经拥有它了,但是还需要一点点推动,因此下面的 PowerShell 应该可以满足您的需要。
电源外壳
$registryPath = "HKCU:\Network\G";
If ( !(Test-Path $registryPath) ) { New-Item -Path $registryPath -Force; };
New-ItemProperty -Path $registryPath -Name "Connection Type" -Value 1 -PropertyType DWORD -Force;
New-ItemProperty -Path $registryPath -Name "DeferFlags" -Value 4 -PropertyType DWORD -Force;