locked
Get-Services Property Data Display help. RRS feed

  • Question

  • Hello, 

    I am very new to PowerShell, and have been trying to write this script to display certain information about share drive troubleshooting. It is working how it want it to, BUT I am having a simple problem. My problem is this: When I run my $FPSenable variable it will display the DisplayName,Enabled,Profile Properties (as it should), then when I go to run my $WinServices Varible, it will ONLY display the same Properties as $FPSenable (which are DisplayName,Enabled,Profile) , not the Properties associated with $WinServices (which are Status,Name,DisplayName). I think the solution would be to STOP what ever variable I ran first, and then start a new Instance of the next variable I want to run next. I have no idea how to do that though. Any sort of guidance would be fantastic! 

    Code: 

    $FPSenable = Get-NetFirewallRule -DisplayGroup 'File and Printer Sharing'|Where Profile -eq Public | select DisplayName,Enabled,Profile
    $WinServices = get-Service -name Browser,LanmanServer,Lanmanworkstation,NetTcpPortSharing | select Status,Name,Displayname

    Clear-host 

    $msgToPerson ={ 

    "##################################################################"
    "##############  Share Drive Troubleshooter   #####################"  
    "##################################################################"

    "Press 'a' to check if 'File and Printer Sharing' is Enabled"

    "Press 'b' to check if the Correct services for Sharing are Running"

    "Press 'q' to quit "
    }

    Do { #'Do' Start

    $response = Read-host -Prompt $msgToPerson
        if($response -eq 'a') {$FPSenable}
        if($response -eq 'b') {$WinServices}
    } until ($response -eq 'q') # 'Do' end

    Monday, January 29, 2018 10:47 PM

All replies

  • You output is only going to the pipeline and needs to go to the console:

    $msgToPerson = @'
    	"##################################################################"
    	"##############  Share Drive Troubleshooter   #####################"
    	"##################################################################"
    	
    	"Press 'a' to check if 'File and Printer Sharing' is Enabled"
    	
    	"Press 'b' to check if the Correct services for Sharing are Running"
    	
    	"Press 'q' to quit "
    '@
    
    while(1){
    	$response = Read-host -Prompt $msgToPerson
    	if ($response -eq 'a') { $FPSenable | ft }
    	if ($response -eq 'b') { $WinServices | ft }
    	if ($response -eq 'q') { break }
    }
    


    \_(ツ)_/

    Monday, January 29, 2018 11:30 PM
  • YES! Thank you so much for the assistance! That is exactly what I wanted it to do. 

    I have follow up questions: 

    1. "You output is only going to the pipeline and needs to go to the console" I don't know what this means. What is the pipeline? What is the Console? 

    2. "while(1)" Why did we have to put "(1)" after the while? 

    3. "{$FPSenable | ft}" What does "ft" short for/stand for? What is it doing? 


    Monday, January 29, 2018 11:41 PM
  • Start with:

    help help

    Then go here: Learn PowerShell  


    \_(ツ)_/

    Tuesday, January 30, 2018 1:11 AM