I've edited the following function to read the productname instead and write it to a text file, this is working great.


Now I want to move the MSI it read to a different folder using the Move-Item command.

I keep however getting the following error:


Move-Item : The process cannot access the file because it is being used by another process.

At E:\MSI2APPV\Client\MSI2APPv.ps1:4 char:1

+ Move-Item "$Path" ".\Done\"


+CategoryInfo :WriteError <E:\MSI2APPV\Client\MSIS\CCleaner.msi:FileInfo> [Move-Item], IOException

+FullyQualifiedErrorId: MoveFileInfoItemIOError,Microsoft.PowerShell.Command.MoveItemCommand


This is what's supposed to move the MSI:


$Msi = Get-ChildItem .\MSIS\| Where-Object {$_.Extension -eq ".msi"} | Select-Object -first 1 

$Path = ".\MSIS\$Msi"


Move-Item "$Path" ".\DONE"


Any help would be great.


0 Comments   [ + ] Show Comments


Please log in to comment



it is probably still open by the previous function to get the ProductName?

Answered 04/19/2013 by: jaybee96
Red Belt

  • That's what I thought but how do I close it?
  • http://msdn.microsoft.com/en-us/library/system.management.automation.powershell.dispose(v=vs.85).aspx
  • No, that closes the PS instance. The OP needs to close the database which, off the top of my head, is achieved using the .Close method. As I believe I have mentioned once or twice before, the WI object model is fully documented on MSDN and in the SDK which, no doubt, you still haven't downloaded.
  • thanks vbscab.. I will take a look at that..
Please log in to comment
Answer this question or Comment on this question for clarity