'Is Start-Process -Passthru unable to grab the process ID?
I have a PowerShell script able to open and close .txt and .exe via a returned PID from Start-process $type -Passthru. However, if I try to do this same thing with .pngs I get this error:
Start-Process : This command cannot be run completely because the system cannot find all the information required.
I am trying to get a returned PID so I can close the default photo editor without having to explicitly call it by name. Code sample:
$object = Get-ChildItem | Where-Object {$_.LastWriteTime -gt (Get-Date).AddDays(-730)} | Select-Object -Property Name
[System.Collections.ArrayList] $filearray = $object
$removed = $filearray[-1].Name
$open_photo = Start-Process -FilePath $removed -passthru
$open_photo.Id
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
