{"id":2628,"date":"2013-11-03T00:01:00","date_gmt":"2013-11-03T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/11\/03\/weekend-scripter-use-powershell-to-discover-switch-extensions\/"},"modified":"2013-11-03T00:01:00","modified_gmt":"2013-11-03T00:01:00","slug":"weekend-scripter-use-powershell-to-discover-switch-extensions","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/weekend-scripter-use-powershell-to-discover-switch-extensions\/","title":{"rendered":"Weekend Scripter: Use PowerShell to Discover Switch Extensions"},"content":{"rendered":"<p><strong>Summary<\/strong>: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to discover virtual switch extensions in Hyper-V.<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. I have been playing around with Windows PowerShell and with Hyper-V. One of the cool things about Hyper-V networking is that the virtual switches are extensible. This provides a great space for third-party networking features. But there are a couple of virtual switch extensions that ship with the product that are pretty cool. These extensions are shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4454.HSG-10-11-13-01.png\"><img decoding=\"async\" title=\"Image of menu\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4454.HSG-10-11-13-01.png\" alt=\"Image of menu\" \/><\/a><\/p>\n<p>I can use Windows PowerShell to discover these switch extensions by using the <strong>Get-VMSwitchExtension<\/strong> cmdlet. Because I enable switch extensions on a per virtual switch basis, I need to supply the name of the virtual switch to the cmdlet as shown here:<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; Get-VMSwitchExtension -VMSwitchName externalswitch<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">Id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : EA24CD6C-D17A-4348-9190-09F0D5BE83DD<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Microsoft NDIS Capture<\/p>\n<p style=\"padding-left: 30px\">Vendor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Microsoft<\/p>\n<p style=\"padding-left: 30px\">Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 6.3.9600.16384<\/p>\n<p style=\"padding-left: 30px\">ExtensionType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Monitoring<\/p>\n<p style=\"padding-left: 30px\">ParentExtensionId&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">ParentExtensionName :<\/p>\n<p style=\"padding-left: 30px\">SwitchId&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 3341a008-4cab-460d-ae95-5acc640d9598<\/p>\n<p style=\"padding-left: 30px\">SwitchName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : externalSwitch<\/p>\n<p style=\"padding-left: 30px\">Enabled&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False<\/p>\n<p style=\"padding-left: 30px\">Running&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False<\/p>\n<p style=\"padding-left: 30px\">ComputerName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : EDLT<\/p>\n<p style=\"padding-left: 30px\">Key&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:<\/p>\n<p style=\"padding-left: 30px\">IsDeleted&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">Id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : E7C3B2F0-F3C5-48DF-AF2B-10FED6D72E7A<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Microsoft Windows Filtering Platform<\/p>\n<p style=\"padding-left: 30px\">Vendor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Microsoft<\/p>\n<p style=\"padding-left: 30px\">Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 6.3.9600.16384<\/p>\n<p style=\"padding-left: 30px\">ExtensionType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Filter<\/p>\n<p style=\"padding-left: 30px\">ParentExtensionId&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">ParentExtensionName :<\/p>\n<p style=\"padding-left: 30px\">SwitchId&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 3341a008-4cab-460d-ae95-5acc640d9598<\/p>\n<p style=\"padding-left: 30px\">SwitchName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : externalSwitch<\/p>\n<p style=\"padding-left: 30px\">Enabled&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : True<\/p>\n<p style=\"padding-left: 30px\">Running&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : True<\/p>\n<p style=\"padding-left: 30px\">ComputerName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : EDLT<\/p>\n<p style=\"padding-left: 30px\">Key&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">IsDeleted&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: False<\/p>\n<p>Because this is Windows PowerShell, it means that the cmdlets behave in the same manner. This means that I can use the <strong>Get-VMSwitchExtension&nbsp;<\/strong>cmdlet to retrieve the names of all the virtual switches on the host machine. I can feed those results to the <strong>&ndash;VMSwitchName<\/strong> parameter to retrieve the extension information. I then decide to choose the name of the extension, the switch name and whether the extension is enabled and running. I then sort the results. The command is shown here:<\/p>\n<p style=\"padding-left: 30px\">Get-VMSwitchExtension -VMSwitchName (get-vmswitch).name |<\/p>\n<p style=\"padding-left: 30px\">select name, switchname, enabled, running | sort enabled, running<\/p>\n<p>The command and the output are shown in the image that follows:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4403.HSG-10-11-13-02.png\"><img decoding=\"async\" title=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4403.HSG-10-11-13-02.png\" alt=\"Image of command output\" \/><\/a><\/p>\n<p>Suppose I need to perform a network trace on one of my virtual machines for diagnostic purposes. I can enable the Microsoft NDIS capture extension. First I need to check to see the status of the extension. I use wildcard characters to reduce typing, and I achieve the following command.<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; Get-VMSwitchExtension -VMSwitchName externalswitch -Name *ndis*<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">Id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : EA24CD6C-D17A-4348-9190-09F0D5BE83DD<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Microsoft NDIS Capture<\/p>\n<p style=\"padding-left: 30px\">Vendor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Microsoft<\/p>\n<p style=\"padding-left: 30px\">Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 6.3.9600.16384<\/p>\n<p style=\"padding-left: 30px\">ExtensionType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Monitoring<\/p>\n<p style=\"padding-left: 30px\">ParentExtensionId&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">ParentExtensionName :<\/p>\n<p style=\"padding-left: 30px\">SwitchId&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 3341a008-4cab-460d-ae95-5acc640d9598<\/p>\n<p style=\"padding-left: 30px\">SwitchName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : externalSwitch<\/p>\n<p style=\"padding-left: 30px\">Enabled&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False<\/p>\n<p style=\"padding-left: 30px\">Running&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False<\/p>\n<p style=\"padding-left: 30px\">ComputerName&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: EDLT<\/p>\n<p style=\"padding-left: 30px\">Key&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">IsDeleted&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False<\/p>\n<p>Now I need to enable the extension. To do this, I simply pipel the previous command to the <strong>Enable-VMSwitchExtension<\/strong>. This is shown here:<\/p>\n<p style=\"padding-left: 30px\">PS C:\\&gt; Get-VMSwitchExtension -VMSwitchName externalswitch -Name *ndis* | Enable-VMSw<\/p>\n<p style=\"padding-left: 30px\">itchExtension<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">Id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : EA24CD6C-D17A-4348-9190-09F0D5BE83DD<\/p>\n<p style=\"padding-left: 30px\">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Microsoft NDIS Capture<\/p>\n<p style=\"padding-left: 30px\">Vendor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Microsoft<\/p>\n<p style=\"padding-left: 30px\">Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 6.3.9600.16384<\/p>\n<p style=\"padding-left: 30px\">ExtensionType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Monitoring<\/p>\n<p style=\"padding-left: 30px\">ParentExtensionId&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">ParentExtensionName :<\/p>\n<p style=\"padding-left: 30px\">SwitchId&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 3341a008-4cab-460d-ae95-5acc640d9598<\/p>\n<p style=\"padding-left: 30px\">SwitchName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : externalSwitch<\/p>\n<p style=\"padding-left: 30px\">Enabled&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : True<\/p>\n<p style=\"padding-left: 30px\">Running&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False<\/p>\n<p style=\"padding-left: 30px\">ComputerName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : EDLT<\/p>\n<p style=\"padding-left: 30px\">Key&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<\/p>\n<p style=\"padding-left: 30px\">IsDeleted&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : False<\/p>\n<p>Join me tomorrow when I will talk about more cool Windows PowerShell stuff.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><strong>Ed Wilson, Microsoft Scripting Guy<\/strong>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to discover virtual switch extensions in Hyper-V. Microsoft Scripting Guy, Ed Wilson, is here. I have been playing around with Windows PowerShell and with Hyper-V. One of the cool things about Hyper-V networking is that the virtual switches are extensible. This provides a great [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[373,37,3,45],"class_list":["post-2628","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-hyperv","tag-networking","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to discover virtual switch extensions in Hyper-V. Microsoft Scripting Guy, Ed Wilson, is here. I have been playing around with Windows PowerShell and with Hyper-V. One of the cool things about Hyper-V networking is that the virtual switches are extensible. This provides a great [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2628","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=2628"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2628\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=2628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=2628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=2628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}