February 20th, 2015

PowerTip: Release COM Object in PowerShell

Doctor Scripto
Scripter

Summary: Learn how to release a COM object in Windows PowerShell. 

  How can I make sure that a COM object in my Windows PowerShell automation script releases?

  Use the ReleaseCOMObject static method from the Marshal class, and then pass it to the variable
           that holds the COM object, for example:

[System.Runtime.Interopservices.Marshal]::ReleaseComObject($doc) | Out-Null

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.