Powershell - changing registry entry for Proxyserver - windows

I have a script that changes the internet proxy server. It is under HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer. The problem is, I seem to have to wait a while for the change to be reflected (so I can use the browser) or go into the Internet Options in Windows and click on Connections and open the Lan Settings and click Ok.
Is there something else I can do in my script to make the proxy reflected immediately in my browser? Closing and opening the browser doesn't seem to make it happen either.
I mostly use Chrome, but have the same issue with IE.

I do not experience any delay on Win8.1 with IE and Firefox, did you try it this way ?
Close the browsers before making the change.
$regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
#Enable proxy
Set-ItemProperty -Path $regPath -Name "ProxyEnable" -Value 1
Set-ItemProperty -Path $regPath -Name "ProxyServer" -Value "proxy.domain:1080"
#Disable proxy
Set-ItemProperty -Path $regPath -Name "ProxyEnable" -Value 0
Set-ItemProperty -Path $regPath -Name "ProxyServer" -Value ""

Related

How can I block Ctrl+Alt+Del when it's sent by BeyondTrust Privileged Remote Access to Windows 10 IoT Enterprise?

BeyondTrust Privileged Remote Access has a button to send Ctrl+Alt+Del to the remote system. I've been able to block Ctrl+Alt+Del for non-remote use by using the HKLM:\SYSTEM\CurrentControlSet\Control\Keyboard Layout's Scancode Map property and/or Keyboard Filter. Neither of those block it when sent by Privileged Remote Access. Is there a way to block it when sent by Privileged Remote Access?
In the meantime, I've disabled all of the options on the Ctrl+Alt+Del screen by running the following PowerShell code:
# Disable Ctrl+Alt+Del screen Switch User option.
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name HideFastUserSwitching -Value 1
# Disable remaining Ctrl+Alt+Del screen options.
New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoLogoff -Value 1
New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies -Name System
New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name DisableChangePassword -Value 1
New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name DisableLockWorkstation -Value 1
New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name DisableTaskMgr -Value 1
There are probably two ways to trigger C+A+D in software:
Keyboard driver. Not sure if the scancode map would handle that.
Simulate. Microsoft used to provide a library on request with a function called SimulateSAS. Windows 7 added SendSAS for everyone to use. There is also 3rd-party stuff that does it.
The group policy "Disable or enable software Secure Attention Sequence" can disable the simulation. A driver can be disabled/removed.

Change Font Settings in Windows using PowerShell

In windows machine, Do we have any way to enable the "Allow fonts to be installed using a shortcut (advanced)" option in Control Panel\Appearance and Personalization\Fonts\Font settings using powershell script.
Image of Font Settings Option
Highlighted checkbox should be enabled
Thanks in advance
if (-not (Test-Path "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Font Management"))
{
New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Font Management" -Force
}
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Font Management" -Name "InstallAsLink" -PropertyType DWord -Value 1 -Force

the command " Get-Command -Module Defender" has no output

I need to disable Windows defender in an old build of Windows 10 (en_windows_10_pro_10240_x64_dvd) without activating windows update,
The problem I'm facing is that the usual powershell commands to do that don't work, the command Get-Command -Module Defender has no output!
output of $PSVersionTable.PSVersion:
Major Minor Build Revision
----- ----- ----- --------
5 0 10240 16384
It looks like the Defender module is not installed then.
You can try disable it using the registry. Run this as Administrator. The computer needs to be restarted for the new setting to take effect:
$regpath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender"
if (!(Test-Path $regpath -PathType Container)) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft" -Name 'Windows Defender' -ItemType Container | Out-Null
}
Set-ItemProperty -Path $regpath -Name "DisableAntiSpyware" -Value 1 -Type DWord
You can enable Defender later bu using
Set-ItemProperty -Path $regpath -Name "DisableAntiSpyware" -Value 0 -Type DWord

Editing registry keys remotely with Powershell

Is it possible to edit a registry key remotely with a Powershell script? If it is, how?
I have a list of 7 servers in which I have to disable windows update settings. I've coded the following script but only can be used localy:
$regkey = "HKLM:\SOFTWARE\microsoft\......\auto update"
set-itemproperty -path $regkey -name AUOptions -value 1
set-itemproperty -path $regkey -name ElevateNonAdmins -value 0
set-itemproperty -path $regkey -name IncludeRecommendedUpdates -value 0
Any suggestion? Thanks!
Powershell's support for remote registry is done via .Net. There are lots of Google answers available. Here's one from right this site:
$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computer1)
$RegKey= $Reg.OpenSubKey("SOFTWARE\\Veritas\\NetBackup\\CurrentVersion")
As for how to set the values is left as an exercise to the reader.

Set-ItemProperty sets Registry Value as String on some systems instead of DWord, why?

I try to create an item using Set-ItemProperty in PowerShell, which works on most systems:
New-PSDrive -name HKCR -PSProvider Registry -root HKEY_CLASSES_ROOT
Set-ItemProperty -Path HKCR:\Software\MyCompany\ -Name Level -Value 5 -ErrorAction SilentlyContinue
This creates a DWORD-value on most Windows 7 systems, but I have found one system where this creates a STRING-value instead, and I want to know: why? What could happen that the systems behave differently? All don't have that value already set, all use the same base image using the same Powershell version.
Btw, I found that by using the following code, I can explicitly set a type, so I already solved the problem:
New-ItemProperty -Path HKCR:\Software\MyCompany\ -Name Level -Value 5 -ErrorAction SilentlyContinue -PropertyType DWord
But just for curiosity, I want to know why the systems behave differently.
I don't have an answer to why it happens but to avoid such instances, be explicit. Use the Type (dynamic) Parameter and specify a RegistryValueKind value (you can also use it with New-ItemProperty) :
Set-ItemProperty -Path HKCR:\Software\MyCompany -Name Level -Value 5 -Type DWord
Try this.
[Microsoft.Win32.Registry]::SetValue("HKEY_CLASSES_ROOT\Software\MyCompany","Level",5,[Microsoft.Win32.RegistryValueKind]::DWord)

Resources