I hope this question find you well.
I’m a work-study IT technician and I need your help with a script that doesn’t work as it should in PowerShell.
Please bear in mind that this is not a graded assignment, nor is it for an exam.
So, I’ve created a script in PowerShell to partially automate the deployment of new workstations.
In this script, I’ve included a function that should set the display to 125% instead of the recommended 150%.
The script works, except that parameter -1 gives 175, parameter 0 gives 150 and neither 2 nor 3 does anything.
I’m sharing my function with you, hoping you can help.
PS: When I run it on a machine with an external screen, the external screen display changes to 125 as requested, I’m on Windows 11.
Here’s my code :
your text
`function Configure-DisplayScaling
{
param ([int]$scaling)
$sourceScale = @”
using System;
using System.Runtime.InteropServices;
public class User32
{
[DllImport("user32.dll", SetLastError = true)]
public static extern bool SystemParametersInfo(
uint uiAction,
uint uiParam,
IntPtr pvParam,
uint fWinIni);
}
"@
Add-Type -TypeDefinition $sourceScale -Language CSharp
$apicall = [User32]
$apicall::SystemParametersInfo(0x009F, $scaling, [IntPtr]::Zero, 1) | Out-Null
}
Configure-DisplayScaling -scaling 1`
LysTheIT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.