# encoding: ascii
# api: powershell
# title: Release-ComObject
# description: Author unknown.
# version: 0.1
# type: function
# author: redyey
# license: CC0
# function: Remove-ComObject
# x-poshcode-id: 5703
# x-archived: 2015-01-24T06:41:52
# x-published: 2015-01-22T02:00:00
#
#
# Release COM Object
function Remove-ComObject {
# Requires -Version 2.0
[CmdletBinding()]
param()
end {
Start-Sleep -Milliseconds 500
[Management.Automation.ScopedItemOptions]$scopedOpt = 'ReadOnly, Constant'
Get-Variable -Scope 1 | Where-Object {
$_.Value.pstypenames -contains 'System.__ComObject' -and -not ($scopedOpt -band $_.Options)
} | Remove-Variable -Scope 1 -Verbose:([Bool]$PSBoundParameters['Verbose'].IsPresent)
[gc]::Collect()
}
}