Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Using-Object(
- [System.IDisposable]
- $InputObject,
- [scriptblock]
- $ScriptBlock = {throw "ScriptBlock is mandatory, please provide a value."})
- {
- try
- {
- . $ScriptBlock
- }
- finally
- {
- if ($null -ne $InputObject -and $InputObject -is [System.IDisposable])
- {
- $InputObject.Dispose()
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement