ConfigMgr :: PowerShell :: WMI :: Maintenance tasks across Hierarchy

WMI Powershell Query to list out all Maintenance Task details across hierarchy.

 
 
 
 
 
(0)
Add to favorites
System Center
9/10/2018
E-mail Twitter del.icio.us Digg Facebook
  • Give this a shot
    2 Posts | Last post December 21, 2018
    • This will make your list of days much more manageable :)
      
      $days = ''
      if (($task.DaysOfWeek -band 1) -eq 1) {$days += 'Sunday, '}
      if (($task.DaysOfWeek -band 2) -eq 2) {$days += 'Monday, '}
      if (($task.DaysOfWeek -band 4) -eq 4) {$days += 'Tuesday, '}
      if (($task.DaysOfWeek -band 8) -eq 8) {$days += 'Wednesday, '}
      if (($task.DaysOfWeek -band 16) -eq 16) {$days += 'Thursday, '}
      if (($task.DaysOfWeek -band 32) -eq 32) {$days += 'Friday, '}
      if (($task.DaysOfWeek -band 64) -eq 64) {$days += 'Saturday, '}
      $days -replace '..$'
      
    • Actually, this is even cleaner
      
      $days = ''
      if ($task.DaysOfWeek -band 1) {$days += 'Sunday, '}
      if ($task.DaysOfWeek -band 2) {$days += 'Monday, '}
      if ($task.DaysOfWeek -band 4) {$days += 'Tuesday, '}
      if ($task.DaysOfWeek -band 8) {$days += 'Wednesday, '}
      if ($task.DaysOfWeek -band 16) {$days += 'Thursday, '}
      if ($task.DaysOfWeek -band 32) {$days += 'Friday, '}
      if ($task.DaysOfWeek -band 64) {$days += 'Saturday, '}
      $days -replace '..$'