button on click method

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

$selectedRow = $DataListGrid.CurrentRowIndex
Stop-Service -InputObject (get-service -Computernane $servers1 -Name $servname)


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