{"id":5084,"date":"2012-08-24T00:01:00","date_gmt":"2012-08-24T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2012\/08\/24\/use-powershell-3-0-to-find-enabled-windows-8-features\/"},"modified":"2012-08-24T00:01:00","modified_gmt":"2012-08-24T00:01:00","slug":"use-powershell-3-0-to-find-enabled-windows-8-features","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-powershell-3-0-to-find-enabled-windows-8-features\/","title":{"rendered":"Use PowerShell 3.0 to Find Enabled Windows 8 Features"},"content":{"rendered":"<p><b>Summary<\/b>: Microsoft Scripting Guy, Ed Wilson, shows how to use Windows PowerShell 3.0 to find enabled Windows 8 features.<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. One of the neat things about Windows (does not matter the version) is how I can customize the installation or deployment. In fact, nearly every version of Windows I have ever worked with has had very sophisticated deployment tools. For the majority of my needs, they are a bit too sophisticated.<\/p>\n<p>All I would like to do is add or remove features from a client operating system in an easy-to-use manner. In the past, I used a tool called sysocmgr. I wrote a number of rather complicated VBScript scripts to automate the use of sysocmgr. It worked, and it was the tool that I had to use to get the job done. A few years ago, Microsoft introduced DISM. This powerful tool permits easy manipulation of images. Cool.<\/p>\n<h2>Use the DISM cmdlets to determine enabled features<\/h2>\n<p>In Windows 8 with Windows PowerShell 3.0, there are a number of cmdlets supplied as part of the DISM module. These cmdlets are listed in the following table along with a synopsis of their functionality.<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p><b>Name<\/b><\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p><b>Function<\/b><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Add-AppxProvisionedPackage<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Adds an AppX package that will install for each new user to a Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Use-WindowsUnattend<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Applies an unattended answer file to a Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Get-AppxProvisionedPackage<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Gets information about AppX packages in an image that will be installed for each new user.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Remove-AppxProvisionedPackage<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Removes an AppX packages from a Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Add-AppxProvisionedPackage<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Adds an AppX package that will install for each new user to a Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Add-WindowsDriver<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Adds a driver to an offline Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Add-WindowsPackage<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Adds a single .cab or .msu file to a Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Clear-WindowsCorruptMountPoint<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Deletes all of the resources associated with a mounted image that has been corrupted.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Disable-WindowsOptionalFeature<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Disables a feature in a Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Dismount-WindowsImage<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Dismounts a Windows image from the directory it is mapped to.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Enable-WindowsOptionalFeature<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Enables a feature in a Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Get-AppxProvisionedPackage<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Gets information about AppX packages in an image that will be installed for each new user.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Get-WindowsDriver<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Displays information about drivers in a Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Get-WindowsEdition<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Gets edition information about a Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Get-WindowsImage<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Gets information about a Windows image in a .wim or .vhd file.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Get-WindowsOptionalFeature<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Gets information about optional features in a Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Get-WindowsPackage<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Gets information about packages in a Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Mount-WindowsImage<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Mounts a Windows image in a .wim or .vhd file to a directory on the local computer.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Remove-AppxProvisionedPackage<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Removes an AppX packages from a Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Remove-WindowsDriver<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Removes a driver from an offline Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Remove-WindowsPackage<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Removes a package from a Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Repair-WindowsImage<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Repairs a Windows image in a .wim or .vhd file.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Save-WindowsImage<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Applies changes made to a mounted image to its .wim or .vhd file.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Set-WindowsEdition<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Changes a Windows image to a higher edition.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Set-WindowsProductKey<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Sets the product key for the Windows image.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"241\" valign=\"top\">\n<p>Use-WindowsUnattend<\/p>\n<\/td>\n<td width=\"397\" valign=\"top\">\n<p>Applies an unattended answer file to a Windows image.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"padding-left: 30px\"><b>Note<\/b> &nbsp;&nbsp;The <b>Get-WindowsOptionalFeature<\/b> cmdlet must run with elevated rights. Right-click the Windows PowerShell 3.0 console while holding the CTRL key, and select Run As Administrator from the action menu.<\/p>\n<p>The <b>Get-WindowsOptionalFeature<\/b> cmdlet reveals information about the status of the optional Windows features. The trick, unless you really are manipulating a Windows image, is to use the <b>online<\/b><i> <\/i>switch. When used, the <b>online<\/b><i> <\/i>switch tells the <b>Get-WindowsOptionalFeature<\/b> cmdlet to return the status of the current installation. The syntax for this command is shown here.<\/p>\n<p style=\"padding-left: 30px\">Get-WindowsOptionalFeature &ndash;Online<\/p>\n<p>By default, the <b>Get-WindowsOptionalFeature<\/b> returns about all information about all features&mdash;enabled, disabled, or otherwise. To return only enabled features, use the <b>Where-Object<\/b> to filter on the <b>state<\/b> property. The default display of information is a list that makes the information cumbersome to read. I like to pipe results to <b>Format-Table<\/b> and use the <b>autosize<\/b><i> <\/i>parameter to create a nice, tight display. This technique is shown here (<b>ft<\/b> is an alias for <b>Format-Table<\/b> and <b>&ndash;a<\/b> is the partial parameter for <b>autosize<\/b>).<\/p>\n<p style=\"padding-left: 30px\">Get-WindowsOptionalFeature -Online | where state -eq enabled | ft &ndash;a<\/p>\n<p>The command and output associated with the command are shown in the image that follows.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5238.HSG-8-24-12-01.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5238.HSG-8-24-12-01.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>The command works against remote computers in addition to local ones by using Windows PowerShell remoting. I use the same technique that I have used in the past.<\/p>\n<p>First, I import the Active Directory module. (This module does not exist unless the RSAT tools are installed on the local computer, or unless you use implicit remoting to bring them from a remote server.) Next, I use the <b>Get-ADComputer<\/b> cmdlet to find all of the Windows 8 computers, and then I use the <b>Invoke-Command<\/b> cmdlet to use the <b>Get-WindowsOptionalFeature<\/b> cmdlet to find the enabled optional features. This bit of code is shown here.<\/p>\n<p style=\"padding-left: 30px\">Get-EnabledWindowsOptionalFeatures.ps1<\/p>\n<p style=\"padding-left: 30px\">Import-Module activedirectory<\/p>\n<p style=\"padding-left: 30px\">$c = Get-ADComputer -Filter * -Properties operatingsystem |<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp; where operatingsystem -match 8<\/p>\n<p style=\"padding-left: 30px\">Invoke-Command -cn $c.name -SCRIPT {<\/p>\n<p style=\"padding-left: 30px\">&nbsp; Get-WindowsOptionalFeature -Online |<\/p>\n<p style=\"padding-left: 30px\">&nbsp; Where-Object state -eq enabled<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp; }<\/p>\n<p>Join me tomorrow when I will talk about more cool things you can do with Windows PowerShell.<\/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><b>Ed Wilson, Microsoft Scripting Guy<\/b>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, shows how to use Windows PowerShell 3.0 to find enabled Windows 8 features. Microsoft Scripting Guy, Ed Wilson, is here. One of the neat things about Windows (does not matter the version) is how I can customize the installation or deployment. In fact, nearly every version of Windows I [&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":[86,16,47,31,362,3,288,45],"class_list":["post-5084","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-basic-information","tag-desktop-management","tag-general-management-tasks","tag-operating-system","tag-powershell-3","tag-scripting-guy","tag-version-information","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, shows how to use Windows PowerShell 3.0 to find enabled Windows 8 features. Microsoft Scripting Guy, Ed Wilson, is here. One of the neat things about Windows (does not matter the version) is how I can customize the installation or deployment. In fact, nearly every version of Windows I [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/5084","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=5084"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/5084\/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=5084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=5084"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=5084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}