Add property to objecttemplate using Add()

Nov 26, 2013 at 3:46 PM
Hi,

I'm trying to update an objecttemplate via powershell smlets, but can't figure out the correct input values for the add method.

Here is the script:
Import-Module smlets

$template = Get-SCSMObjectTemplate -DisplayName "Company - Service - New Hardware with approval"

$template.PropertyCollection.Add("what is the correct parameter value here?") 
The overloaddefinition says:
void Add(Microsoft.EnterpriseManagement.Configuration.ManagementPackObjectTemplateProperty item)
void ICollection[ManagementPackObjectTemplateProperty].Add(Microsoft.EnterpriseManagement.Configuration.ManagementPackObjectTemplateProperty item)
int IList.Add(System.Object value)

How do I create a objecttemplateproperty item ?

The propertycollection on the template contains the following:
Path                                                                                            MixedValue                                                                                    
----                                                                                            ----------                                                                                    
$Context/Property[Type='CustomSystem_WorkItem_ServiceRequest_Library!System.WorkItem.Service... $MPElement[Name='CustomServiceManager_ServiceRequest_Library!ServiceRequestPriorityEnum.Low']$
$Context/Property[Type='CustomSystem_WorkItem_ServiceRequest_Library!System.WorkItem.Service... $MPElement[Name='CustomServiceManager_ServiceRequest_Library!ServiceRequestUrgencyEnum.Low']$ 
$Context/Property[Type='CustomSystem_WorkItem_ServiceRequest_Library!System.WorkItem.Service... $MPElement[Name='CustomServiceManager_ServiceRequest_Library!ServiceRequestSourceEnum.Porta...
$Context/Property[Type='CustomSystem_WorkItem_ServiceRequest_Library!System.WorkItem.Service... $MPElement[Name='CustomServiceManager_ServiceRequest_Library!ServiceRequestAreaEnum.Hardwar...
$Context/Property[Type='CustomSystem_WorkItem_Library!System.WorkItem']/Title$                  New Hardware Request with Approval                                            
An example of this would be nice, thanks :)
Nov 27, 2013 at 11:22 AM
Ok I found out how, but now the next step is to update the template within the management pack ??

#Create template property object
    $propClass = [Microsoft.EnterpriseManagement.Configuration.ManagementPackObjectTemplateProperty]
    $propObject = New-Object $propClass

    #Add new item to property object
    $propObject.Path = "`$Context/Property[Type='CustomSystem_WorkItem_Library!System.WorkItem']/Id$"
    $propObject.MixedValue = "SR{0}"
    
    #Add property to template
    $template.PropertyCollection.Add($propObject)