Skip to content

Configuration Item to start script

Featured Replies

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?

 

 

 

 

  • Author

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.

  • Author

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.

  • Author

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.

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?

  • Author

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

  • Author

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.

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...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.