Expand Archive Wont Complete Execution In Object Event

Welcome Forums General PowerShell Q&A Expand Archive Wont Complete Execution In Object Event

Viewing 0 reply threads
  • Author
    Posts
    • #263978
      Participant
      Topics: 1
      Replies: 0
      Points: 11
      Rank: Member

      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-Archive C:\source.zip -DestinationPath C:\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.

      • This topic was modified 1 week, 3 days ago by ghzn8820.
      • This topic was modified 1 week, 3 days ago by grokkit.
      • This topic was modified 1 week, 3 days ago by grokkit.
Viewing 0 reply threads
  • You must be logged in to reply to this topic.