Jump to content


tommy24a

Configuration Item to start script

Recommended Posts

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?

 

 

 

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.