Monday, April 30, 2012

2012 Scripting Games : Beginner Event #2

The second problem for the SG 2012 can be found here

In this Event there was a little confusion as to what I had to do.....But going through comments on this problem and Scripting Wife's hint the picture became clear that I had to only find the Stoppable running services (complicated eh !).

Scripting Guy's design point can be a bit confusing at times but the key to solve is to think how to encompass all the design points.


The Script I wrote worked fine..what I did was queried the services running on the system ,then filtered one running with the status "Running", then finally filtered those with canstop property set to $true........but when read the comments on my script I learned a few things

Things learned:

1.  How to write compound Where clause.Read this article here . After reading this learned how to handle Boolean values and write compound where clause.

2. Read previous Scripting Games problem and solutions :)



param (
        $commputername = $env:computername
)

Get-Service -ComputerName $computername |
    where {$_.status -eq "running"} |
    where {$_.canstop -eq $true } 

No comments:

Post a Comment