Parseing the output from a "Microsoft.Dism.Commands.AdvancedFeatureObject"

Robert Merritt 1 Reputation point

I an trying to get information on a bunch of machines as to whether they have smb1 enabled

$x=Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
$y=$x.ToString()|select-string -Pattern "State"
write-host $x.ToString()
write-host $y

$y should be what I want but instead I get Microsoft.Dism.Commands.AdvancedFeatureObject
I tried to .ToString(0 it but no luck how do I extract the 5th line of this output?

FeatureName : SMB1Protocol
DisplayName : SMB 1.0/CIFS File Sharing Support
Description : Support for the SMB 1.0/CIFS file sharing protocol, and the Computer Browser protocol.
RestartRequired : Possible
State : Disabled
CustomProperties :
ServerComponent\Description : Support for the SMB 1.0/CIFS file sharing protocol, and the Computer Browser protocol.
ServerComponent\DisplayName : SMB 1.0/CIFS File Sharing Support
ServerComponent\Id : 487
ServerComponent\Type : Feature
ServerComponent\UniqueName : FS-SMB1
ServerComponent\Deploys\Update\Name : SMB1Protocol

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,352 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Stephen Gardiner 0 Reputation points

    Sorry this is old but as came up in my search for state outputs

    $x=(Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol).State


    $x=Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol | Select -ExpandProperty State


    If you want multiple selections

    $x = Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol



    If you wanted to return more functions

    I like to use two possible ways when checking what a variable holds

    $x | GM

    $x | Select *

    Both outputs will show information on what the variable holds.


    0 comments No comments