I got some trouble working with Get-SCSMObject and multiple conditions in the -Filter parameter, but got it working using the Criteria parameter. Hope this help!
# Import Smlets Module
Import-module -name Smlets
# Get the Manual Activity Class
$MAClass = Get-SCSMClass -Name System.WorkItem.Activity.ManualActivity$
# Get the Manual Activity Completed Status Enumeration
$MAStatusCompleted = Get-SCSMEnumeration -Name ActivityStatusEnum.Completed$
# Get the starting date from where we are searching
$MAModifiedDay = (Get-date).Adddays(-30)
# Get the Criteria Class
$CriteriaClass = "Microsoft.EnterpriseManagement.Common.EnterpriseManagementObjectCriteria"
# Define the Filter
$Filter = "Status = '$($MAStatusCompleted.Id)' AND LastModified > '$MAModifiedDay'"
# Create de Criteria Object
$CriteriaObject = new-object $CriteriaClass $Filter, $MAClass
# Search for Manual Activities
Get-SCSMObject -criteria $CriteriaObject
Thanks for reading! If you have any questions, leave a comment or send me an email at fxcat@lazywinadmin.com. I invite you to follow me on Twitter @lazywinadm / Google+ / LinkedIn. You can also follow the LazyWinAdmin Blog on Facebook Page and Google+ Page.
No comments:
Post a Comment