Created
June 25, 2025 21:59
-
-
Save scriptjunkie/12bc05bd3cdd46eb2655e559fc2a74f3 to your computer and use it in GitHub Desktop.
PowerShell script to scan to your desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$deviceManager = new-object -ComObject WIA.DeviceManager | |
$device = $deviceManager.DeviceInfos.Item(1).Connect() | |
$wiaFormatPNG = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}" | |
foreach ($item in $device.Items) { | |
$image = $item.Transfer($wiaFormatPNG) | |
if($image.FormatID -ne $wiaFormatPNG) | |
{ | |
$imageProcess = new-object -ComObject WIA.ImageProcess | |
$imageProcess.Filters.Add($imageProcess.FilterInfos.Item("Convert").FilterID) | |
$imageProcess.Filters.Item(1).Properties.Item("FormatID").Value = $wiaFormatPNG | |
$image = $imageProcess.Apply($image) | |
} | |
$i = 1 | |
while (test-path ("$env:userprofile\desktop\scan$i.png" ) ) { $i += 1 } | |
$image.SaveFile("$env:userprofile\desktop\scan$i.png") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment