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

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

$
0
0
I am trying to use set-scsmobjecttemplate

$CMN11 = Get-SCSMObjectTemplate -DisplayName "CMN11 - Request for Results Notification"
$CRClassProjection = get-SCSMTypeProjection System.WorkItem.ChangeRequestProjection$
$CRP = Get-SCSMObjectProjection -Projection $CRClassProjection -Filter "Id -eq $CR_ID"
Set-SCSMObjectTemplate -Projection $CRP -Template $CMN11

PS C:\>>> Set-SCSMObjectTemplate -Projection $CRP -Template $CMN11
Set-SCSMObjectTemplate : The template cannot be applied to the instance because the instance is not of t
he template targets type.
At line:1 char:23
+ Set-SCSMObjectTemplate <<<< -Projection $CRP -Template $CMN11
+ CategoryInfo : InvalidOperation: (Template_ae893e...2e7f27753abdbe3:ManagementPackObject
Template) [Set-SCSMObjectTemplate], InvalidOperationException
+ FullyQualifiedErrorId : ApplyTemplate,SMLets.SetSCSMObjectTemplateCommand
And I think this is the cause,
PS C:\>>> $CRP = Get-SCSMObjectProjection -Projection $CRClassProjection -Filter "Id -eq $CR
_ID"
PS C:\>>> $CRP.GetType()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False PSCustomObject System.Object


PS C:\>>> $CRClassProjection.GetType()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False PSCustomObject System.Object

And according to the cmdlet help, we are looking for a specific type of object,
PS C:\>>> help Set-SCSMObjectTemplate

NAME
Set-SCSMObjectTemplate

SYNTAX
Set-SCSMObjectTemplate [-Projection] [-Name ] [-Tem
plate ] [-ComputerName ] [-Credential ] [-SCSMSe
ssion ] [-Verbose] [-Debug] [-ErrorAction ] [-WarningAc
tion ] [-ErrorVariable ] [-WarningVariable ] [-OutVariable ] [-OutBuffer ] [-WhatIf] [-Confirm]
Set-SCSMObjectTemplate [-Object] [-Name ] [-Template ] [-ComputerName ] [-Credential ] [-SCSMSession ] [-Verbose] [-Debug] [-ErrorAction ] [-WarningAction ] [-ErrorVariable ] [-WarningVariable ] [-OutVariable ] [-OutBuffer
] [-WhatIf] [-Confirm]

Viewing all articles
Browse latest Browse all 306

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>