tommy24a Posted January 7, 2016 Report post Posted January 7, 2016 Hello, I am trying to create a CI to check if a certain service is running, and if not start that service. I have 2 powershell scripts that work. One to discover and one to remediate. The scripts run fine when I run them manually. But will not work when I try to use them in a baseline. See scripts below. Discovery Script: $services = 'sccommservice'Get-Service sccommservice Remediate Script: $services = 'sccommservice'Get-Service | ? {$services -contains $_.Name -and $_.Status -eq 'Stopped'} | Start-Service Any help? Quote Share this post Link to post Share on other sites More sharing options...
GarthMJ Posted January 7, 2016 Report post Posted January 7, 2016 What do you mean by you run them manfully? How did you run them manually? Did you test the scripts as the local system account? Quote Share this post Link to post Share on other sites More sharing options...
tommy24a Posted January 7, 2016 Report post Posted January 7, 2016 What do you mean by you run them manfully? How did you run them manually? Did you test the scripts as the local system account? yes I started PS as local admin and ran the discovery script, and then the remediate script. While having the service stopped it starts the service up without issue. I just can figure out why its not working in sccm CI baseline. Quote Share this post Link to post Share on other sites More sharing options...
GarthMJ Posted January 7, 2016 Report post Posted January 7, 2016 Have you run your scripts using the local system account? This is the account CM12 will use to run them, so..... Quote Share this post Link to post Share on other sites More sharing options...
tommy24a Posted January 7, 2016 Report post Posted January 7, 2016 Have you run your scripts using the local system account? This is the account CM12 will use to run them, so..... Whatever account that sccm runs them with when I create the CI. Let me check. Quote Share this post Link to post Share on other sites More sharing options...
tommy24a Posted January 7, 2016 Report post Posted January 7, 2016 Whatever account that sccm runs them with when I create the CI. Let me check. The account that I use to work in the sccm console has local admin rights on the PC. Quote Share this post Link to post Share on other sites More sharing options...
GarthMJ Posted January 7, 2016 Report post Posted January 7, 2016 Whatever account that sccm runs them with when I create the CI. Let me check. When you manually test the PowerShell scripts, what account are you testing them as? How exactly are you testing them when you test them manually? Quote Share this post Link to post Share on other sites More sharing options...
tommy24a Posted January 7, 2016 Report post Posted January 7, 2016 When you manually test the PowerShell scripts, what account are you testing them as? How exactly are you testing them when you test them manually? I right click powershell program and select "run as Different user", I get the logon window and I put an account that has local admin on the PC and password. So now I just run the script inside there .\myscript.psi ie Quote Share this post Link to post Share on other sites More sharing options...
GarthMJ Posted January 7, 2016 Report post Posted January 7, 2016 ok that does NOT use the local system account. Here is how to run as the local system account. http://verbalprocessor.com/2007/12/05/running-a-cmd-prompt-as-local-system/ Quote Share this post Link to post Share on other sites More sharing options...
tommy24a Posted January 7, 2016 Report post Posted January 7, 2016 ok that does NOT use the local system account. Here is how to run as the local system account. http://verbalprocessor.com/2007/12/05/running-a-cmd-prompt-as-local-system/ I logged into the local pc as a local admin, not sure what I should be testing. The script does run manually, but when I create a CI for sccm it will not remediate when in the control panel I go to configuration manager and click evaluate button. Quote Share this post Link to post Share on other sites More sharing options...