Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Created August 29, 2015 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guitarrapc/0ebd8c1c54aabc7e610c to your computer and use it in GitHub Desktop.
Save guitarrapc/0ebd8c1c54aabc7e610c to your computer and use it in GitHub Desktop.
function using
{
param($obj, [scriptblock]$sb)
try {
& $sb
} finally {
if ($obj -is [IDisposable]) {
$obj.Dispose()
}
}
}
using ($stream = new-object System.IO.StreamReader $PSHOME\types.ps1xml) {
foreach ($_ in 1..5) { $stream.ReadLine() }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment