Question

I'm trying to run a script that copies several files to a group of servers. After words I run another script in another directory to verify they were moved. I can invoke the next folder that I need to go to using:

Invoke-Item c:\scripts\etc

But how can I get it to close a specific comObject? I can close all comObjects using:

(New-Object -comObject Shell.Application).Windows() | foreach-object {$_.quit()}

but this will close all Windows, including IE if open. Is it possible to close it using a specific parameter like LocationName or LocationURL?

Thanks!

Was it helpful?

Solution

Figured it out..

(New-Object -comObject Shell.Application).Windows() | where-object {$_.LocationURL -eq "File:///C:/Scripts/Whatever/Folder/Path"} | foreach-object {$_.quit()}

In case anyone else is dumb like me :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top