I'm facing a weird situation about editing the registry value.
I record an video here: https://www.youtube.com/watch?v=Au8NRF-SMDY
It because I want to turn off News and interests feeds by changing Registry directly. I'm changing a registry value from HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds key and the ShellFeedsTaskbarViewMode value from 2 to 0. After the value changed without any error, I hit the Refresh (F5) immediately. Then the value changed back. I don't know what's going on. Does anyone can explain?
This answer from Ill_Branch1293 worked for me : https://www.reddit.com/r/sysadmin/comments/s1iomh/comment/hw0soe4/?utm_source=share&utm_medium=web2x&context=3
Here is the code:
# Turn off News and Interests
Write-Host "Turning off News and Interests..."
TASKKILL /IM explorer.exe /F
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds" -Name "ShellFeedsTaskbarViewMode" -Type DWord -Value 2
Start-Process explorer.exe
Related
My goal is to configure Microsoft Edge with Powershell only.
So for example, the first window does not appear when you open it for the first time, to adjust the overlay etc. .
Set the home page, show the home button at the top, set favorites, etc.
What is the best way to do this with Powershell?
The logic to configuring MS Edge with PowerShell is you need to access and modify the relevant registry keys using PowerShell.
For configuring different Edge browser features, you need to configure the corresponding registries. so you would need to know which registry key is used for which feature.
Below is an example to set the Homepage for the Edge browser using Powershell.
# Ensure Edge key exists
$EdgeHome = 'HKCU:\Software\Policies\Microsoft\Edge'
If ( -Not (Test-Path $EdgeHome)) {
New-Item -Path $EdgeHome | Out-Null
}
# Set RestoreOnStartup value entry
$IPHT = #{
Path = $EdgeHome
Name = 'RestoreOnStartup'
Value = 4
Type = 'DWORD'
}
Set-ItemProperty #IPHT -verbose
# Create Startup URL's registry key
$EdgeSUURL = "$EdgeHome\RestoreOnStartupURLs"
If ( -Not (Test-Path $EdgeSUURL)) {
New-Item -Path $EdgeSUURL | Out-Null
}
# Create a single URL startup page
$HOMEURL = 'https://duckduckgo.com'
Set-ItemProperty -Path $EdgeSUURL -Name '1' -Value $HomeURL
Helpful References:
How to Change the Start Page for the Edge Browser
How can I set the home page in Edge Chromium with Powershell?
The above example will give you an idea about how to access and modify the registry using PowerShell to configure the Edge features.
Further, you could make tests on your side to configure other options for the Edge browser.
Note: Some Edge options/ features are only available to configure if the machine is AD joined. If you try to configure and the machine is not AD joined then it will be ignored.
Our current scenario is this:
We have more than 80 tablet computers (running Windows 10) in our network that run under the same user (DefaultUser). In order to verify that the display settings are correctly set, we would like to use a powershell script to automatically check the used resolution remotely with a support user account.
So far, we know how to get the primary screen resolution for the user under which the script gets executed (which is rather easy):
// get primary screen width
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width // height accordingly
In case we execute this script on one of the tablets using the support account, we get the primary screen resolution for the support account user - but not for the desired user DefaultUser.
How can we get the resolution for the DefaultUser?
The only solution that easily comes to my mind is a rather ugly thing:
Using the windows task scheduler i could create a task that executes the script (under the defaultUser) to get the screen resolution and write the result(s) into a file that can be accessed by the support user account. But i am looking for something more elegant.
It sounds like you're looking for the screen scaling values, based on your code checking the PrimaryScreen values:
# My monitor resolution is 3000x2000
Add-Type -AssemblyName System.Windows.Forms
# [Screen] returns screen size AFTER scaling (200% here)
[System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height
1000
# [SystemInformation] returns the hardware screen resolution (applies to all users)
[System.Windows.Forms.SystemInformation]::VirtualScreen.Height
2000
Scaling can be set on a per-user basis, though there is a machine-wide "Default" setting. Screen scaling is weird, and gets done differently depending on what version of windows you have. Here's how it works in Windows 10 at least.
You can check the current values like so:
# AllUsers setting, which shows as (default)
Get-ItemProperty -path "HKCU:\Control Panel\Desktop\WindowMetrics" | fl AppliedDPI
# User's current scaling setting (I use a * instead of the per-monitor ID)
Get-ItemProperty -path "HKCU:\Control Panel\Desktop\PerMonitorSettings\*" | fl DpiValue
# AppliedDPI shows the "Default" scaling setting on a system level like:
96 : 100%
120 : 125%
144 : 150%
192 : 200% (my default)
# DpiValue shows how many steps up or down the current user's scaling setting is. For example on my machine:
#250%
DpiValue : 2 # +2
#200% (default)
DpiValue : 0
#150%
DpiValue : 4294967294 # -1
#100%
DpiValue : 4294967292 # -3
Finding and overriding scaling for other user profiles is pretty involved, but has been done by other people. I found this script and usage details by user romaliceishimwe2. I have not tested, but it does show how to look at and change other users' profiles:
#First we configure the default, later we will configure any existing users.
#Load the ntuser.dat of the default user
REG LOAD HKU\Default_User C:\users\default\ntuser.dat
#Assign new registry keys
New-ItemProperty -path registry::"HKU\Default_User\Control Panel\Desktop" -Name LogPixels -Value 120 -Type DWord
New-ItemProperty -path registry::"HKU\Default_User\Control Panel\Desktop" -Name Win8DpiScaling -Value 1 -Type DWord
#unload default user ntuser.dat
REG UNLOAD HKU\Default_User
#Here we configure any eixting users
# Regex pattern for SIDs
$PatternSID = 'S-1-5-21-\d+-\d+\-\d+\-\d+$'
# Get Username, SID, and location of ntuser.dat for all users
$ProfileList = gp 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\*' | Where-Object {$_.PSChildName -match $PatternSID} |
Select #{name="SID";expression={$_.PSChildName}},
#{name="UserHive";expression={"$($_.ProfileImagePath)\ntuser.dat"}},
#{name="Username";expression={$_.ProfileImagePath -replace '^(.*[\\\/])', ''}}
# Get all user SIDs found in HKEY_USERS (ntuder.dat files that are loaded)
$LoadedHives = gci Registry::HKEY_USERS | ? {$_.PSChildname -match $PatternSID} | Select #{name="SID";expression={$_.PSChildName}}
# Get all users that are not currently logged
$UnloadedHives = Compare-Object $ProfileList.SID $LoadedHives.SID | Select #{name="SID";expression={$_.InputObject}}, UserHive, Username
# Loop through each profile on the machine
Foreach ($item in $ProfileList) {
# Load User ntuser.dat if it's not already loaded
IF ($item.SID -in $UnloadedHives.SID) {
reg load HKU\$($Item.SID) $($Item.UserHive) | Out-Null
}
#####################################################################
# This is where you can read/modify a users portion of the registry
"{0}" -f $($item.Username) | Write-Output
New-ItemProperty -path registry::"HKU\$($Item.SID)\Control Panel\Desktop" -Name LogPixels -Value 120 -Type DWord -force
New-ItemProperty -path registry::"HKU\$($Item.SID)\Control Panel\Desktop" -Name Win8DpiScaling -Value 1 -Type DWord -force
#####################################################################
# Unload ntuser.dat
IF ($item.SID -in $UnloadedHives.SID) {
### Garbage collection and closing of ntuser.dat ###
[gc]::Collect()
reg unload HKU\$($Item.SID) | Out-Null
}
}
You may be able to use CIM or WMI to get from point a to b.
CIM_VideoController is the class that would contain the resolution.
Using PowerShell Core:
Get-CimInstance CIM_VideoController | Select SystemName, CurrentHorizontalResolution, CurrentVerticalResolution
Using Windows PowerShell:
Get-WmiObject Win32_VideoController | Select SystemName, CurrentHorizontalResolution, CurrentVerticalResolution
You should be able to open the proper ports to use either of these options remotely (though you could also probably get away with using Invoke-Command to run them, as long as you use CredSSP or Kerberos Delegation to take the 2nd hop problem into account).
I never tried doing this, but I think it is possible. I need a executable file,
or a script, that can automatically change Default Windows Format and Digital symbol.
I need it so that I can one click change the default Region on many PCs.
I made a shortcut for opening intl.cpl:
C:\Windows\System32\rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,0
But I want it all to be automatic:
Change format to:
Serbian (Latin, Serbia)
Change Decimal and grouping Symbol to:"." and "," respectively
And Change RegionSetings to:Serbian (Latin, Serbia)
I found this PowerShell Script but I don't know how to make all changes that I want.
These are the three commands I use for changing Windows 10 to UK English (en-GB / 242), I had a look for the Serbian values and found these from a bit of google-fu:
sr-Latn-RS language (from Windows table of Language IDs)
271 for GeoId (from table-of-geographical-locations)
Hopefully those are the correct values for your language/location.
I can't test these commands as I don't have a VM to hand and don't want to change the language on my own system.
Set-WinSystemLocale -SystemLocale sr-Latn-RS
Set-WinHomeLocation -GeoId 271
Set-WinUserLanguageList -LanguageList (New-WinUserLanguageList -Language sr-Latn-RS) -Force
EDIT:
OP found the settings for the other configuration changes:
Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sDecimal -Value "."
Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sThousand -Value ","
To disable FSRM quota with PowerShell is command below.
Set-FsrmQuota D:\test -Disabled
Please tell me how to enable with PowerShell.
Best regards,
I think you know how to open PowerShell. The command you gave is quite similar, but if you add "-Disabled" you basically just set a switch to tell the template to be disabled. You could use the switch in case you want to set a certain template, but do not want to have it enabled yet. Or just to disable it. To enable, first check the exact name of the template.
Run:
Get-FsrmQuotaTemplate
After that use the command Gert Jan gave you, with the exact name of the template you choose from the previous command, and run it:
Reset-FsrmQuota -Path "D:\Test" -Template "5 GB Limit"
Please note that "5 GB Limit" is the exact template name found with
the first command.
Now the template is set for the folder you chose.
If you want to set on a series of Homefolders for instance, you could do something like.
$homefolders = Get-ChildItem -Path "D:\home"
foreach($folder in $homefolders){
Reset-FsrmQuota -Path "D:\Test\$($folder.name)" -Template "5 GB Limit"
}
I hope this helps!
On all the Windows 10 computers I re-image, I want to disable the option in Sound for giving exclusive control to each device to applications. I have located the registry keys and values:
HKLM\Software\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Capture\RANDOM_STRING\Properties
HKLM\Software\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\RANDOM_STRING\Properties
Within each of these keys (1st one is for Mics and 2nd is for Speakers) their are the two DWORD-32 values in each:
{b3f8fa53-0004-438e-9003-51a46e139bfc},3
{b3f8fa53-0004-438e-9003-51a46e139bfc},4
I want to basically make a batch script that will find these two values and set them to 0 for each audio devices. I'll have it run via Task Scheduler or something to make sure it gets new devices too.
The problem for me is that RANDOM_STRING portion of each path. Each one is ~25 random characters; it looks similar to the value names with the ,# at the end. I know how to change a value via a specific path, but here their is that randomized key name, and then new ones as new devices are plugged in.
Is their any way for me to create a batch file (or VBS/PowerShell) that will search the registry (or just Audio to narrow it down quicker) for those two values, and change their values to 0? Or if any other ways of going about this if so?
An example of the process I'd like (or again, something else similar):
Search for the DWORD-32 value "{b3f8fa53-0004-438e-9003-51a46e139bfc},3" within
the path
"HKLM\Software\Microsoft\Windows\CurrentVersion\MMDevices\Audio\"
and all the sub-keys within.
Set the value of the DWORD-32 value
"{b3f8fa53-0004-438e-9003-51a46e139bfc},3" to 0.
Search for the DWORD-32 value "{b3f8fa53-0004-438e-9003-51a46e139bfc},4" within
the path
"HKLM\Software\Microsoft\Windows\CurrentVersion\MMDevices\Audio\"
and all the sub-keys within.
Set the value of the DWORD-32 value
"{b3f8fa53-0004-438e-9003-51a46e139bfc},4" to 0.
I hope you know what are you doing. Manipulating registry is very risky. If you are absolutely sure, take a look at this script:
ls 'HKLM:\Software\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Capture\*\Properties\' | `
where {$_.Property -contains '{b3f8fa53-0004-438e-9003-51a46e139bfc},3'} | `
Get-ItemProperty -Name '{b3f8fa53-0004-438e-9003-51a46e139bfc},3'
#Set-ItemProperty -Name '{b3f8fa53-0004-438e-9003-51a46e139bfc},3' -Value 0
Make sure this script (with Get-ItemProperty) gets only desired keys. To change values, replace last line with commented one. Make sure you have proper permissions. And finally: do it at you own risk :)
I was unable to get the other answer working. I am trying to ban the Netflix app from being unbearably loud (which it does if it gets exclusive control of the sound device) every time I reinstall the geforce drivers (when the exclusive control resets).
So:
Get-ChildItem -recurse -path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\'| `
Foreach-Object { if ($_.Property -eq '{b3f8fa53-0004-438e-9003-51a46e139bfc},3') {$_|Get-ItemProperty -Name '{b3f8fa53-0004-438e-9003-51a46e139bfc},3'} }`
Gives me this output:
{b3f8fa53-0004-438e-9003-51a46e139bfc},3 : 0
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\
Windows\CurrentVersion\MMDevices\Audio\Render\{94743724-8af1-4abc-8d45-275
7184ec5f2}\Properties
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\
Windows\CurrentVersion\MMDevices\Audio\Render\{94743724-8af1-4abc-8d45-275
7184ec5f2}
PSChildName : Properties
PSProvider : Microsoft.PowerShell.Core\Registry
{b3f8fa53-0004-438e-9003-51a46e139bfc},3 : 0
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\
Windows\CurrentVersion\MMDevices\Audio\Render\{b4ed07ae-0ee7-4ffb-8370-8bb
08a59a941}\Properties
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\
Windows\CurrentVersion\MMDevices\Audio\Render\{b4ed07ae-0ee7-4ffb-8370-8bb
08a59a941}
PSChildName : Properties
PSProvider : Microsoft.PowerShell.Core\Registry
This looks good.
To write it the Get-ItemProperty needs to change to Set-ItemProperty but it results in a security error, please consult https://stackoverflow.com/a/35844259/308851 to take ownership of the relevant key.