In C#, you can easily dispose of objects by making use of the using statement, so long at the object implements the IDisposable interface.
So how do you do this in PowerShell? Fortunately, Adam Weigert and Keith Dahlby have done the hard work:
- Adam shows a technique that emulates the using statement in Powershell.
- Adam shows a technique for emulating try … catch … finally blocks.
- Keith expands these techniques to flush out a more general purpose solution.
Thanks guys!