Table of Contents
SMS/SCCM Command-line actions
Disable Software-Distribution:
WMIC /namespace:\\root\ccm\policy\machine\requestedconfig path ccm_SoftwareDistributionClientConfig CREATE ComponentName="Disable SWDist",Enabled="false",LockSettings="TRUE",PolicySource="local",PolicyVersion="1.0" ,SiteSettingsKey="1" /NOINTERACTIVE
Re-Activate Software-Distribution:
WMIC /namespace:\\root\ccm\policy\machine\requestedconfig path ccm_SoftwareDistributionClientConfig WHERE ComponentName="Disable SWDist" delete /NOINTERACTIVE
Trigger Hardware Inventory:
WMIC /namespace:\\root\ccm path sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000001}" /NOINTERACTIVE
Trigger Software Inventory:
WMIC /namespace:\\root\ccm path sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000002}" /NOINTERACTIVE
Trigger DataDiscoverRecord (DDR) update:
WMIC /namespace:\\root\ccm path sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000003}" /NOINTERACTIVE
Force a FULL HW Inventory on next HW-Inv Schedule:
WMIC /namespace:\\root\ccm\invagt path inventoryActionStatus where InventoryActionID="{00000000-0000-0000-0000-000000000001}" DELETE /NOINTERACTIVE
Repair SMS/SCCM Agent on a remote client:
WMIC /node:%MACHINE% /namespace:\\root\ccm path sms_client CALL RepairClient
Repair a list (all clients listed in clients.txt) of remote SMS/SCCM Agents:
WMIC /node:@clients.txt /namespace:\\root\ccm path sms_client CALL RepairClient
Source:Roger Zander at myITforum.com - SMS/SCCM Command-line Actions
DCM with VBScript as check
To actively check SCCM managed systems for missing software/settings/files and react by installing said software/settings/files you can use Desired Configuration Management. You can implement a DCM check on a collection of systems and then create another collection that contains the resources that fail said DCM check. This lets you set an advertisement on that collection.
How to do this is described below.
First make sure that you have a collection with the resources that should be checked as members.
Create a Configuration Item:
- Create a VBScript that on succesfull check uses WScript.Echo to spit out something, doesn't have to be any meaningfull text. Make sure it doesn't return anything when the check fails. Note: objShell.Run doesn't work here!
- Within the SCCM console, go to the site → Computer Management → Desired Configuration Management and select Configuration Items.
- Click on Actions → New → Application Configuration Item in the righthand side of the console. The Create Application Configuration Item Wizard opens.
- Enter a name for the Configuration Item and click Next.
- Select “Use custom script” at “Specify how to determine whether this application is installed on a client.”.
- Select VBScript in the dropdown box.
- Copy and paste the contents of the script you created in step 1 into the field and then click Next.
- Don't change anything on the Objects page. Click Next.
- Don't change anything on the Settings page. Click Next.
- Select “All Windows platforms” on the Applicability page.
- Check the settings on the Summary page and click Next.
- Click Close on the Wizard Completed page.
Next create a Configuration Baseline:
- Within the SCCM console, go to the site → Computer Management → Desired Configuration Management and select Configuration Baselines.
- Click on Actions → New → Configuration Baseline in the righthand side of the console. The Create Configuration Baseline Wizard opens.
- Enter a name for the Configuration Baseline and click Next.
- Click on “applications and general” below Rules on the Set Configuration Baseline Rules page. The Choose Configuration Items screen apears.
- Place a checkmark next to each desired configuration item and click OK.
- Click Next on the Set Configuration Baseline Rules page.
- Check the settings on the Summary page and click Next.
- Click Close on the Wizard Completed page.
Apply the Configuration Baseline to a collection of resources:
- Within the SCCM console, go to the site → Computer Management → Desired Configuration Management and select Configuration Baselines.
- Rightclick on the desired Configuration Baseline and click “Assign to a Collection”. The Assign Configuration Baseline Wizard opens.
- Click Next on the Choose Configuration Baselines page.
- Click Browse… on the Choose Collection page, select the collection with the resources that should be checked as members and click Next.
- Set the desired frequency for the check(s) on the Set Schedule page and click Next.
- Check the settings on the Summary page and click Next.
- Click Close on the Wizard Completed page.
Now a collection can be created of which the resources that don't comply with the Configuration Baseline become a member.
One or more advertisements can then be assigned to this collection.
The collection can be created with the following query as a copy, paste and modify example:
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_CI_ComplianceState on SMS_G_System_CI_ComplianceState.ResourceID = SMS_R_System.ResourceID Where SMS_G_System_CI_ComplianceState.ComplianceStateName = "Non-Compliant" and SMS_G_System_CI_ComplianceState.LocalizedDisplayName = "KB958830 Installed"
Force re-registration for clients that have been inactive for too long
When the SCCM site has the task to clean inactive clients set to enabled any client that is offline for too long a period is deleted from SCCM.
To speed up the re-registration of this client when it is online again, force a full hardware inventory.
Source:Coretech - Ups I deleted 1.000 computers in Config. Mgr console