locked
PowerShell Menu with Submenus to Disable/Manual/Auto System Services RRS feed

  • Question

  • Hello Guys,I am new here.I need to get script for school in PowerShell, that has menu with sub menus and Disable/Manual/AutoRun system services. 

    Here I have script for Menu-Submenu. Where and how can I put Disable/Manula/Autorun commands? 

    I want it to be like,when I press button 1 For Fax,and then 1 once again for Disabled , for it,to disable Fax startup type.how to do it? Hope you understood what I want.

    Function Show-SubMenu {
        Param(
            [Parameter(Position=0,Mandatory=$True,HelpMessage='Izveleties skriptu')] 
            [ValidateNotNullOrEmpty()] 
            [string]$menu,
            [Parameter(Position=1)]
            [ValidateNotNullOrEmpty()]
            [string]$Title=':',
            [switch]$ClearScreen
        )
        if($ClearScreen){Clear-Host}
        $submenuPrompt=$Title
        $submenuprompt+="`n"
        $submenuPrompt+="-"*$title.Length 
        $submenuprompt+="`n"
        $submenuPrompt+=$menu
        return (Read-Host -Prompt $submenuPrompt )
    }
    $submenu=@'
    1. Fax
    2. Netlogon
    3. Telephony
    Q. Izslegt 
    Nospiediet ciparu vai Q, lai izlesgt 
    '@ 

    $submenu1=@'
    1. Disable {set-service sysmonlog -startuptype disabled}
    2. Manual
    3. Autorun
    Q. Atgriezties 
    Izveleties ko izdarit ar servisu 
    '@ 

    $submenu2=@'
    1. Disable
    2. Manual
    3. Autorun
    Q. Atgriezties 
    Izveleties ko izdarit ar servisu 
    '@ 
    $submenu3=@'
    1. Disable
    2. Manual
    3. Autorun
    Q. Atgriezties  
    Izveleties ko izdarit ar servisu 
    '@ 

    while($true){
        $response= Show-SubMenu $submenu 'Izveleties sistemas servisu'
        switch($response){
            1 {
                $response=Show-SubMenu $submenu1 'Fax'

                } # parse response
            2 {
                $response=Show-SubMenu $submenu2 'Netlogon'
                } # parse response
            3 { $response=Show-SubMenu $submenu2 'Telephony'
                
                } # parse response
    'Q' {
                Write-Host "Script Terminated" -ForegroundColor Red
                return
                }
             default {Write-Warning 'Invalid Choice. Try again.'}
        }
    }

    • Moved by Bill_Stewart Monday, July 13, 2015 3:34 PM This is not "do my homework for me" forum
    Monday, June 8, 2015 3:34 PM

Answers

All replies

  • This isn't the right place for homework or school questions.

    -- Bill Stewart [Bill_Stewart]

    Monday, June 8, 2015 3:40 PM
  • Ok,Then Where Can I post this question?
    Tuesday, June 9, 2015 4:42 AM
  • You need to read your materials or ask your instructor.


    -- Bill Stewart [Bill_Stewart]

    Tuesday, June 9, 2015 1:56 PM
  • He doesn't want to help me. I only want to understand,how to put {set-service sysmonlog -startuptype disabled} in that menu, so It will be working. By pressing button,that Is needed to do actions.
    Tuesday, June 9, 2015 5:33 PM
  • Sorry but homework questions are outside the scope of this forum.

    There are a lot of good learning resources, though. For example:

    https://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx


    -- Bill Stewart [Bill_Stewart]

    • Proposed as answer by Mike Laughlin Tuesday, June 30, 2015 7:52 PM
    • Marked as answer by Bill_Stewart Monday, July 13, 2015 3:34 PM
    Tuesday, June 9, 2015 6:19 PM