Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. Function Using-Object(
  2. [System.IDisposable]
  3. $InputObject,
  4.  
  5. [scriptblock]
  6. $ScriptBlock = {throw "ScriptBlock is mandatory, please provide a value."})
  7. {
  8. try
  9. {
  10. . $ScriptBlock
  11. }
  12. finally
  13. {
  14. if ($null -ne $InputObject -and $InputObject -is [System.IDisposable])
  15. {
  16. $InputObject.Dispose()
  17. }
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement