search cancel

Run script tasks fail to create schedule run.

book

Article ID: 162543

calendar_today

Updated On:

Products

IT Management Suite Task Server

Issue/Introduction

Run script tasks have "Windows Computers" filter attached to them by force, causing fail to schedule it to run, or setting the correct target.

After scoping and filtering no computers are left

Cause

Unknown

Resolution

Remove "Windows Computers" filter reference for all Run script items with the below SQL query.

1) Remove script tasks (parent & child) reference to "windows Computers" filter from [ItemFilter] table
DELETE FROM ItemFilter WHERE ItemGuid IN
(
    SELECT ir.ParentItemGuid FROM ItemReference ir
    WHERE ir.ChildItemGuid = 'C6C14A32-2DD0-458C-9300-AB24E8D016FD'
    OR ir.ChildItemGuid = 'ED6E3086-8918-4A4A-92B7-DC0772780DF3'
    AND ir.Hint = 'tasktotype'
)
OR ItemGuid = 'C6C14A32-2DD0-458C-9300-AB24E8D016FD' --Run Script
OR ItemGuid = 'ED6E3086-8918-4A4A-92B7-DC0772780DF3' --Command Script
OR ItemGuid = 'C788E602-79A7-43B3-9EF7-A9CA2E72209C' --PowerShell
OR ItemGuid = '082BDA75-7514-400F-9590-A414B8B23B42' -- JavaScript
OR ItemGuid = 'DE2893DC-E9D6-4551-9B9D-2A8FCA5513FA' -- VBscript
print 'Cleaned [ItemFilter]'
-- 2) update [item] for future affected command tasks scripts creation
Update Item set State =
'<item>
  <scriptExtension>cmd</scriptExtension>
  <scriptCommandLine>cmd.exe /c "!s"</scriptCommandLine>
  <filterCollections />
</item>' where Guid = 'ED6E3086-8918-4A4A-92B7-DC0772780DF3' -- Command Script
Update Item set State =
'<item>
  <scriptExtension>ps1</scriptExtension>
  <scriptCommandLine>cmd.exe ?/c powershell "&amp; ''!s''; exit $LastExitCode"</scriptCommandLine>
  <filterCollections />
</item>' where Guid = 'C788E602-79A7-43B3-9EF7-A9CA2E72209C' -- PowerShell
Update Item set State =
'<item>
  <scriptExtension>js</scriptExtension>
  <scriptCommandLine>cmd.exe /c cscript "!s"</scriptCommandLine>
  <filterCollections />
</item>' where Guid = '082BDA75-7514-400F-9590-A414B8B23B42' -- JavaScript
Update Item set State =
'<item>
  <scriptExtension>vbs</scriptExtension>
  <scriptCommandLine>cmd.exe /c cscript "!s"</scriptCommandLine>
  <filterCollections />
</item>' where Guid = 'DE2893DC-E9D6-4551-9B9D-2A8FCA5513FA' -- VBscript
print 'Reset script items to default state Done!'

3) After executing the above script we need to restart the Altiris Service as well as w3wp (IIS) service to implement the changes from the above executed SQL query.