# MrNetTek # eddiejackson.net # 7/15/2022 # free for public use # free to claim as your own #DETECT CURRENT AUTOSCALING function Get-DisplayPrimaryScaling { [CmdletBinding()] param () #Add-Type -Assembly System.Drawing # Get DPI Scaling #[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") Add-Type @' using System; using System.Runtime.InteropServices; using System.Drawing; public class DPI { [DllImport("gdi32.dll")] static extern int GetDeviceCaps(IntPtr hdc, int nIndex); public enum DeviceCap { VERTRES = 10, DESKTOPVERTRES = 117 } public static float scaling() { Graphics g = Graphics.FromHwnd(IntPtr.Zero); IntPtr desktop = g.GetHdc(); int LogicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.VERTRES); int PhysicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.DESKTOPVERTRES); return (float)PhysicalScreenHeight / (float)LogicalScreenHeight; } } '@ -ReferencedAssemblies 'System.Drawing.dll' -ErrorAction Stop Return [DPI]::scaling() * 100 } $ScreenScale = Get-DisplayPrimaryScaling if ($ScreenScale -eq '100') {$ScreenScale='0'} if ($ScreenScale -eq '125') {$ScreenScale='1'} if ($ScreenScale -eq '150') {$ScreenScale='2'} if ($ScreenScale -eq '175') {$ScreenScale='3'} [System.Windows.MessageBox]::Show($ScreenScale)