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 ","
Related
I want to add my internal network folders to the trusted sites dynamically because Excel is blocking the macros inside them (when opening the Excel document via network folder).
I want my users to be able to read and update the document as their wish, meaning that I don't want to make local copies of the file onto the user's computers every time they want to use, edit or add a macro.
Is there a way to replicate the "Internet Options -> Security -> Trusted sites -> Sites -> Add site" process using a PowerShell (or a bash) script?
If you want to add the domain name to the trusted site list in the IE browser then you could refer to the Powershell script example below.
Set-Location "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains"
New-Item test.com
Set-Location test.com
New-ItemProperty . -Name http -Value 2 -Type DWORD
If you want to add the IP address to the trusted site list in the Ie browser then you could refer to the Powershell script example below.
Set-Location "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges"
New-Item Range1 # Modify it if it is exists#
Set-Location "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1" #Modify the path, if you modify the Range key in line above#
New-ItemProperty . -Name ":Range" -Value "129.0.0.1"
New-ItemProperty . -Name "file" -Value 2
Note:
If you receive an error that A key in this path already exists then you need to modify the key name (e.g. Range2, Range3, etc.)
After you modify the Key name(in 2nd line), you need to modify the path(in 3rd line) according to the new key name.
Further, you could modify the above example as per your requirements.
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).
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.