Hello,
How to apply the template with powershell to Service Request?
I'm trying to solve this issue - but with errors
===script 3===
clear
$sr_class = get-scsmclass -name System.WorkItem.ServiceRequest$
$sr_prior = Get-SCSMEnumeration -Name ServiceRequestPriorityEnum.Medium
$sr_urg = Get-SCSMEnumeration -Name ServiceRequestUrgencyEnum.Medium
$title = "TEST SR Title 123"
$area = get-SCSMEnumeration -Name ServiceRequestAreaEnum.Security
New-SCSMOBject -Class $sr_class -PropertyHashtable `
(@{`
Title = $title; `
Urgency = $sr_urg; `
Priority = $sr_prior; `
ID = "SR#{0}"; `
Area = $area `
})
$sr = Get-SCSMTypeProjection -name System.WorkItem.ServiceRequestProjection$ | ? { "Id -eq '$title'" }
$template = Get-SCSMObjectTemplate -DisplayName "<blah-blah>"
Set-SCSMObjectTemplate -Projection $sr -Template $template
===script 3===
===out 3===
Set-SCSMObjectTemplate : Cannot convert 'System.WorkItem.ServiceRequestProjection' to the type 'Microsoft.EnterpriseManagement.
Common.EnterpriseManagementObjectProjection[]' required by parameter 'Projection'. Object cannot be stored in an array of this
type.
At D:\work\new-sr.ps1:18 char:35
+ Set-SCSMObjectTemplate -Projection <<<< $sr -Template [Microsoft.EnterpriseManagement.Common.EnterpriseManagementObjectProje
ction]$template
+ CategoryInfo : InvalidArgument: (:) [Set-SCSMObjectTemplate], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,SMLets.SetSCSMObjectTemplateCommand
===out 3===