I'm trying to find if the FS-Resource-Manager feature is installed on a group of servers (for continued server management and automation.
I need to execute a script on servers that don't have the feature yet turned on.
If it is already installed I want the script to end.
To find out if it is installed or not, i put the output of the command "get-windowsfeature *FS-Resource-Manager" in a variable.
Then I want the yes or no captured by putting this answer in a variable. It is either True or False when I ask "$suboutput=$srv.Installed"
I get a False returned. It looks like text, but when i then use it in an "If" statement and write-host text if its equal to the next variable, then the line exits with no results.
PS C:\tmp> $srv=get-windowsfeature *FS-Resource-Manager
PS C:\tmp> $srv
Display Name Name Install State
[ ] File Server Resource Manager FS-Resource-Manager Available
PS C:\tmp> $suboutput=$srv.Installed
PS C:\tmp> $suboutput
False
PS C:\tmp> $boolean=out-string -InputObject $suboutput
PS C:\tmp> $boolean
False
PS C:\tmp> if ($suboutput -eq "False") {Write-Host "Yes, it is reading the string"}
PS C:\tmp>
Now compare this to if I substitute the $boolean variable for a test.
$test="Dog"
It works fine.
PS C:\tmp> $test="Dog"
PS C:\tmp> $test
Dog
PS C:\tmp> if ($test -eq "Dog") {write-host "This is a Dog!"}
This is a Dog!
PS C:\tmp>
Question. What do i need to do to the output to make it readable to the rest of the script?
thanks!
-Josh