The “Using” Statement In Powershell

When we do code in c#, we have using statement to dispose our objects. so we don’t have to. :).  What about PowerShell? Can we do that?

Here is a PowerShell function which behaves as using statement. 🙂

https://gist.github.com/jeevan90/02c61775391b5f33f5b04c80f9408dc0

So whenever we are dealing with an object that should be disposed we can use this function as below.

https://gist.github.com/jeevan90/97daf6e014162bc7e110e189f3c9b1ed

Isn’t that cool? 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s