Podchaser Logo
Home
Learn About the PowerShell 5.0 Using Statement

Learn About the PowerShell 5.0 Using Statement

Released Wednesday, 15th June 2016
Good episode? Give it some love!
Learn About the PowerShell 5.0 Using Statement

Learn About the PowerShell 5.0 Using Statement

Learn About the PowerShell 5.0 Using Statement

Learn About the PowerShell 5.0 Using Statement

Wednesday, 15th June 2016
Good episode? Give it some love!
Rate Episode

Check out the cloud & automation training courses that are developed by Art of Shell, who sponsored this video!

In PowerShell 5.0, the using statement enables two new, exciting scenarios! If you're using Windows 10, you already have PowerShell 5.0 available to you! Support for PowerShell 5.0 is also offered via the Windows Management Framework (WMF) package, for down-level operating systems including Windows 7, Windows 8, and Windows Server 2012 R2.

First of all, you can "import" .NET namespaces, similar to the C# language, so you don't have to type the full path to a .NET type. For example, instead of typing [System.Data.SqlClient.SqlConnection] every time you want to reference the SqlConnection .NET class, you can add a using statement for the System.Data.SqlClient .NET namespace. Once you've done this, you can simply reference the class like so: [SqlConnection].

The second scenario that the using statement enables in PowerShell is the ability to import PowerShell Classes from PowerShell modules! If you've created a module that defines one or more PowerShell Classes, you can import those classes from the module by adding a using statement to your PowerShell scripts. The proper syntax for this is: using module <moduleName>. Once you've "used" the module, you can then access the class definitions inside of it!

Watch this video for a demonstration about both techniques!

Cheers,
Trevor Sullivan
Microsoft MVP: Cloud & Data Center Management
Founder, Art of Shell
E-mail: trevor@artofshell.com

mp3&WT.dl=0&WT.entryid=Entry:RSSView:96afc9302ae7414a8011a62600f27810

Show More

Unlock more with Podchaser Pro

  • Audience Insights
  • Contact Information
  • Demographics
  • Charts
  • Sponsor History
  • and More!
Pro Features