I'm quite new to Powershell. To be able to run a certain program I need to disable a device. This was not to hard, I created the following:
$DeviceID = (Get-PnpDevice -FriendlyName "*Devicename*").InstanceId
Disable-PnpDevice "$DeviceID" -Confirm:$false
& 'path\file.exe'
So far so good. But now I want to Enable the device after I exit the program. How do I make the script see that I end the program?
Try trapping the result:
& 'path\file.exe' 2>&1
Then test for the exit code which should be held in the environment variable
$LASTEXITCODE
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.