I am using a IO.FileSystemWatcher FileCreated object event to detect when a zip file is placed in a folder, once the zip is detected the script needs to extract the contents and save the files in another directory. If I simply call
Expand-ArchiveC:\source.zip-DestinationPathC:\dest\-Verbose-Force inside the IO.FileSystemWatcher FileCreated object event, the output window says
VERBOSE:Performing the operation“Expand-Archive”on target“C:\source.zip”. and will hang here during execution forever.
If I place the cmdlet
Expand-Archive outside of the object event, everything works, all contents in the zip file are extracted. This seems to me that there is a different thread the object event is located on. How would i get
Expand-Archive cmdlet to work inside a object event? Below is the script that wont expand a zip file.