- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2018 02:27 AM
HI All,
I have integrated ServiceNow - SCCM to Install and Un-Install Application. For any installation i will add Device Name to Installation collection in SCCM and SCCM will take 5 - 6 hours to install Software.
To trigger the installation immediately from SCCM to target computer i can execute below powershell command.
Invoke-WmiMethod -ComputerName NND40508 -Namespace root\ccm -Class sms_client -Name TriggerSchedule -ArgumentList '{00000000-0000-0000-0000-000000000021}' -ErrorAction Stop
Now, i m trying to execute the command from ServiceNow powershell activity on SCCM Server but ServiceNow is executing on MID Server instead of SCCM and failing with errors. Any idea please.
I executed simple command "New-Item -Name EmptyFile.txt -ItemType File" to create empty file its getting created in MID Server instead of SCCM Server.
Also, is there any other option available to trigger Application from SCCM - Target device immediately through SeviceNow.
Regards,
Manoj Nagarajan.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2018 12:14 PM
Manoj,
- 'use_mid_service_account' - If mid server service account credentials should be used to execute this activity. You usually set this on the activity definition itself.
- useCred - As the name suggests, whether to use credentials or not
- ismid - Is mid server the target server?
- isDiscovery - sets if the application is orchestration or not. Some write-host commands rely on this parameter
-debug - enable debug or not
Can you modify HSSPAS881 in your command with $computer and execute with target host as: HSSPAS881?
See if that resolves the issue. If not follow a standard OOB activity to build your custom activity.
Refer 'Query AD' - it's easy to understand.
Thanks,
Saketh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2018 10:46 AM
Hi Manoj,
On my instance(version - KP6), I created a custom activity and see that it's running the command on the target host.
From agent log:
06/23/18 10:38:50 (397) Worker-Standard:PowershellProbe DEBUG: Executing command: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy unrestricted -noninteractive -nologo -noprofile -command "& {& 'scripts\PowerShell\PSScript.ps1' -computer '10.0.0.1' -script 'C:\WINDOWS\TEMP\script7098286742809392522.PS1' 'use_mid_service_account' $false -useCred $true -ismid $false -isDiscovery $false -debug $true -logInfo $false; exit $LASTEXITCODE}"
If you're still seeing this issue, let me know your instance version.
Thanks,
Saketh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2018 09:33 AM
Hi Saketh,
Thanks a lot for your response. I see below line in your log. Can you let me know if the same wil Bypass MID Server and execute the command in Target HOST Machine.
'use_mid_service_account' $false -useCred $true -ismid $false -isDiscovery $false -debug $true
Can you please provide some details about above command please.
Below is the command that i want to execute the in Target Host Machine.
Invoke-WmiMethod -ComputerName HSSPAS881 -Namespace root\ccm -Class sms_client -Name TriggerSchedule -ArgumentList '{00000000-0000-0000-0000-000000000021}' -ErrorAction Stop
Where -ComputerName HSSPAS881 will change dynamically and i want to execute the command on Target Host Machine say "Test_2" machine.
Can you advise how i do the same. Please are some details about my scenario.
MID Server name : test_1
Targer Host Name : test_2
Regards,
Manoj Nagarajan
manojn.cse@gmail.com
Ph: +91 9444 940 215

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2018 12:14 PM
Manoj,
- 'use_mid_service_account' - If mid server service account credentials should be used to execute this activity. You usually set this on the activity definition itself.
- useCred - As the name suggests, whether to use credentials or not
- ismid - Is mid server the target server?
- isDiscovery - sets if the application is orchestration or not. Some write-host commands rely on this parameter
-debug - enable debug or not
Can you modify HSSPAS881 in your command with $computer and execute with target host as: HSSPAS881?
See if that resolves the issue. If not follow a standard OOB activity to build your custom activity.
Refer 'Query AD' - it's easy to understand.
Thanks,
Saketh