Quantcast
Channel: SCSM PowerShell Cmdlets
Viewing all articles
Browse latest Browse all 306

Commented Issue: Trouble with object types returned using SMlets [10670]

$
0
0
I am trying to use set-scsmobjecttemplate<br><br>$CMN11 = Get-SCSMObjectTemplate -DisplayName &quot;CMN11 - Request for Results Notification&quot;<br>$CRClassProjection = get-SCSMTypeProjection System.WorkItem.ChangeRequestProjection$<br>$CRP = Get-SCSMObjectProjection -Projection $CRClassProjection -Filter &quot;Id -eq $CR_ID&quot;<br>Set-SCSMObjectTemplate -Projection $CRP -Template $CMN11<br><br>PS C:\&gt;&gt;&gt; Set-SCSMObjectTemplate -Projection $CRP -Template $CMN11<br>Set-SCSMObjectTemplate : The template cannot be applied to the instance because the instance is not of t<br>he template targets type.<br>At line:1 char:23<br>+ Set-SCSMObjectTemplate &lt;&lt;&lt;&lt; -Projection $CRP -Template $CMN11<br> + CategoryInfo : InvalidOperation: (Template_ae893e...2e7f27753abdbe3:ManagementPackObject<br> Template) [Set-SCSMObjectTemplate], InvalidOperationException<br> + FullyQualifiedErrorId : ApplyTemplate,SMLets.SetSCSMObjectTemplateCommand <br>And I think this is the cause, <br>PS C:\&gt;&gt;&gt; $CRP = Get-SCSMObjectProjection -Projection $CRClassProjection -Filter &quot;Id -eq $CR<br>_ID&quot;<br>PS C:\&gt;&gt;&gt; $CRP.GetType()<br><br>IsPublic IsSerial Name BaseType<br>-------- -------- ---- --------<br>True False PSCustomObject System.Object <br><br><br>PS C:\&gt;&gt;&gt; $CRClassProjection.GetType()<br><br>IsPublic IsSerial Name BaseType<br>-------- -------- ---- --------<br>True False PSCustomObject System.Object<br><br>And according to the cmdlet help, we are looking for a specific type of object, <br>PS C:\&gt;&gt;&gt; help Set-SCSMObjectTemplate<br><br>NAME<br> Set-SCSMObjectTemplate<br><br>SYNTAX<br> Set-SCSMObjectTemplate [-Projection] [-Name ] [-Tem<br> plate ] [-ComputerName ] [-Credential ] [-SCSMSe<br> ssion ] [-Verbose] [-Debug] [-ErrorAction ] [-WarningAc<br> tion ] [-ErrorVariable ] [-WarningVariable ] [-OutVariable ] [-OutBuffer ] [-WhatIf] [-Confirm]<br> Set-SCSMObjectTemplate [-Object] [-Name ] [-Template ] [-ComputerName ] [-Credential ] [-SCSMSession ] [-Verbose] [-Debug] [-ErrorAction ] [-WarningAction ] [-ErrorVariable ] [-WarningVariable ] [-OutVariable ] [-OutBuffer<br> ] [-WhatIf] [-Confirm]
Comments: ** Comment from web user: JFadmin **

I found that I was attempting to use this cmdlet incorrectly. I was trying to apply an email notification template.


Viewing all articles
Browse latest Browse all 306

Trending Articles