Publish Service Offerings with powershell
Import-Module SMLets
$RequestOffering = (Get-SCSMObject -Class (Get-SCSMClass -Name System.RequestOffering)| Where DisplayName -eq "Test Offering")
$RequestOffering | Set-SCSMObject -Property Status -Value Published
Above is the what I have so far, but I am getting this error:
Set-SCSMObject : Cannot process extension elements as
EnterpriseManagementObject. User EnterpriseManagementObjectProjection for all
extension element CRUD operations.
At line:1 char:20
+ $RequestOffering | Set-SCSMObject -Property Status -Value Published
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-SCSMObject], InvalidOpera
tionException
+ FullyQualifiedErrorId : System.InvalidOperationException,SMLets.SetSMObj
ectCommand
I've been searching the web, but I havent found anything useful so far. I do have a service offering called Test Offering and I am running this off my SCSM management server with smlets loaded on it.
I think I am missing something in the set-scsmobject, but not sure what.
Matt
February 20th, 2015 8:59am
Hi bro.
Can you try with
$RequestOffering = (Get-SCSMObject -Class (Get-SCSMClass -Name System.RequestOffering$) -Filter "DisplayName -eq YOURDISPLAYNAME" )
Set-SCSMObject $RequestOffering -Property Status -Value Published
Set-SCSMObject $RequestOffering -Property Status -Value Draft
Regards
February 20th, 2015 9:02am
I end up getting this:
Get-SCSMObject : Cannot bind argument to parameter 'Class' because it is null.
At line:1 char:43
+ $RequestOffering = (Get-SCSMObject -Class (Get-SCSMClass -Name
System.RequestOff ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-SCSMObject], ParameterBind
ingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,S
MLets.GetSMObjectCommand
February 20th, 2015 9:07am
OK, then
$RequestOffering = (Get-SCSMObject -Class (Get-SCSMClass -Name System.RequestOffering$) -Filter "DisplayName -eq
Test Offering" )
Set-SCSMObject $RequestOffering -Property Status -Value Published
Regards
-
Edited by
DANIELVIVAS92
21 hours 33 minutes ago
February 20th, 2015 9:09am
I get the same error, if I remove the $ on System.RequestOffering$, I dont get the same
error. I end up getting the error I originally posted.
I've just tried this:
$RequestOffering = (Get-SCSMObject -Class (Get-SCSMClass -Name System.RequestOffering) -Filter "DisplayName -like Test Offering" )
Set-SCSMObject $RequestOffering -Property Status -Value Published
Set-SCSMObject : Cannot process extension elements as
EnterpriseManagementObject. User EnterpriseManagementObjectProjection for all
extension element CRUD operations.
At line:1 char:20
+ $RequestOffering | Set-SCSMObject -Property Status -Value Published
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-SCSMObject], InvalidOpera
tionException
+ FullyQualifiedErrorId : System.InvalidOperationException,SMLets.SetSMObj
ectCommand
February 20th, 2015 9:14am
Do you have only one object in $RequestOffering. Have you checked that the obejct isnt null?
February 20th, 2015 9:33am
Try this:
$RequestOffering | Set-SCSMObjetProjection -Property
Status -Value Published -Verbose
-
Edited by
DANIELVIVAS92
20 hours 55 minutes ago
February 20th, 2015 9:38am
I get this error now
Set-SCSMObjetProjection : The term 'Set-SCSMObjetProjection' is not recognized
as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:20
+ $RequestOffering | Set-SCSMObjetProjection -Property Status -Value Published
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-SCSMObjetProjection:String)
[], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
February 20th, 2015 9:48am
Try with:
Import-Module SMLets
$status = Get-SCSMEnumeration -Name System.Offering.StatusEnum | Get-SCSMChildEnumeration | Where-Object {$_.DisplayName -eq "Published"}
$typeproj = Get-SCSMTypeProjection -name System.RequestOffering.RequestOfferingViewProjection
$RequestOffering = Get-SCSMObjectProjection -ProjectionObject $typeproj -Filter "DisplayName -eq
Test Offering"
$prop = @{"Status" =
$status}
$RequestOffering | Set-SCSMObjectProjection -PropertyValues $prop -Verbose
-
Marked as answer by
Matt Novitsch
19 hours 16 minutes ago
February 20th, 2015 11:17am
VERBOSE: Want to set Status(enum) to Published
VERBOSE: Looking Enum via string Published in System.Offering.StatusEnum
VERBOSE: found enum: System.Offering.StatusEnum.Published
VERBOSE: set the value
VERBOSE: Performing the operation "Set-SCSMObjectProjection" on target "Save changes to projection".
Thats the result, I dont see the change in console though.
February 20th, 2015 11:22am
I take that back, it is set to published in request offering not service offering. I looked in the wrong spot.
February 20th, 2015 11:24am
It works for changing it to Draft also. Thanks Daniel!
February 20th, 2015 11:27am
OK, then
$RequestOffering = (Get-SCSMObject -Class (Get-SCSMClass -Name System.RequestOffering$) -Filter "DisplayName -eq
Test Offering" )
Set-SCSMObject $RequestOffering -Property Status -Value Published
Regards
-
Edited by
DANIELVIVAS92
Friday, February 20, 2015 2:03 PM
February 20th, 2015 5:02pm
OK, then
$RequestOffering = (Get-SCSMObject -Class (Get-SCSMClass -Name System.RequestOffering$) -Filter "DisplayName -eq
Test Offering" )
Set-SCSMObject $RequestOffering -Property Status -Value Published
Regards
-
Edited by
DANIELVIVAS92
Friday, February 20, 2015 2:03 PM
February 20th, 2015 5:02pm
Try this:
$RequestOffering | Set-SCSMObjetProjection -Property
Status -Value Published -Verbose
-
Edited by
DANIELVIVAS92
Friday, February 20, 2015 2:41 PM
February 20th, 2015 5:32pm
Try this:
$RequestOffering | Set-SCSMObjetProjection -Property
Status -Value Published -Verbose
-
Edited by
DANIELVIVAS92
Friday, February 20, 2015 2:41 PM
February 20th, 2015 5:32pm
Try with:
Import-Module SMLets
$status = Get-SCSMEnumeration -Name System.Offering.StatusEnum | Get-SCSMChildEnumeration | Where-Object {$_.DisplayName -eq "Published"}
$typeproj = Get-SCSMTypeProjection -name System.RequestOffering.RequestOfferingViewProjection
$RequestOffering = Get-SCSMObjectProjection -ProjectionObject $typeproj -Filter "DisplayName -eq
Test Offering"
$prop = @{"Status" =
$status}
$RequestOffering | Set-SCSMObjectProjection -PropertyValues $prop -Verbose
-
Marked as answer by
Matt Novitsch
Friday, February 20, 2015 4:20 PM
February 20th, 2015 7:10pm
Try with:
Import-Module SMLets
$status = Get-SCSMEnumeration -Name System.Offering.StatusEnum | Get-SCSMChildEnumeration | Where-Object {$_.DisplayName -eq "Published"}
$typeproj = Get-SCSMTypeProjection -name System.RequestOffering.RequestOfferingViewProjection
$RequestOffering = Get-SCSMObjectProjection -ProjectionObject $typeproj -Filter "DisplayName -eq
Test Offering"
$prop = @{"Status" =
$status}
$RequestOffering | Set-SCSMObjectProjection -PropertyValues $prop -Verbose
-
Marked as answer by
Matt Novitsch
Friday, February 20, 2015 4:20 PM
February 20th, 2015 7:10pm