button on click method

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 3 months ago.

  • Author
    Posts
  • #5180

    by veroli at 2012-10-09 05:12:30

    Hi all,
    another forms related problem i am stuggling to solve.
    I have a Datagrid that is populated with a list of services from a remote machine which takes the server name as a parameter to run get-service with.

    what i want to do now is select a line in the data grid and then click a button to stop the service.
    the service information i pull back into the datagrid is name, status and display name. I thought the code would be something like this but nothing happens when i click the button and there is no output from the shell window

    $button2_OnClick=
    {
    $selectedRow = $DataListGrid.CurrentRowIndex
    $servname1=$servs.$selectedRow.name
    Stop-Service -InputObject (get-service -Computernane $servers1 -Name $servname)

    }

    regards
    Dan

    by JeffH at 2012-10-09 06:45:19

    Hard to tell without seeing more, but is this a simple typo? You are defining $servname1 yet on the next line you are using $servname. Is this supposed to be different?

    by veroli at 2012-10-10 07:22:58

    thanks jeff sorry jumped the gun a bit and with a fresh pair of eyes sorted the problem

    Dan

You must be logged in to reply to this topic.