Create Request Offering with PowerShell in Service Manager 2012

This is an step by step example on how to create a Service Offering with PowerShell. Before running the PowerShell commands install SMLets and import the module into the PowerShell prompt.

# Some variables
$OfferingOwner = “User01”
$PublishedBy = “User01”
$MPName = “Example”
$TemplateDisplayName = “Example”
$ROName = “Example”
$RONotes = “Created by PowerShell”
$RODescription = “Example”

# Get the MP where the Request Offering will be placed
$MP = Get-SCSMManagementPack -Name $MPName

# Get the Template that should be added to the Request Offering
$ObjTemplate = Get-SCSMObjectTemplate -DisplayName $TemplateDisplayName

# Create questions for the Request Offering.
# The Prompt is the User Prompts or Information.
# The TargetPath is the Map Prompts.
# The Type is the Configure Prompts.
$QU = @()
$QU += @{Prompt = “Question One”; TargetPath = “Title”; Type = “String”}
$QU += @{Prompt = “Question Two”; TargetPath = “Notes”; Type = “String”}
$QU += @{Prompt = “Question Three”; TargetPath = “UserInput”; Type = “InlineList”; ListElements = “one”}
$QU += @{Prompt = “Question Four”; TargetPath = “RequiredBy”; Type = “DateTime”}
$enum = Get-SCSMEnumeration ServiceRequestAreaEnum$
$QU += @{Prompt = “Question Five”; TargetPath = “Area”; Type = “List”; EnumerationList = $enum}

# Prepare the questions for adding them to the Request Offering
$Qlist = @()
foreach ($Q in $QU)
{
$Qlist += New-SCSMRequestOfferingQuestion @Q -ea Stop
}

# Get the publisher user from SCSM
$ROPublishedBy = get-scsmuser.ps1 | where {$_.DisplayName -eq $PublishedBy}

# Get the offering owner from SCSM
$ROUser = get-scsmuser.ps1 | where {$_.DisplayName -eq $OfferingOwner}

# Create the input for the new Request Offering
$RO = @{
ManagementPack = $MP
Questions = $Qlist
DisplayName = $ROName
Title = $ROName
TargetTemplate = $ObjTemplate
Notes = $RONotes
BriefDescription = $RODescription
Owner = $ROUser
PublishedBy = $ROPublishedBy
Status = $published
PublishDate = (get-date)
# Image = Get-IconStream $ICON
# NoCommit = $true
}

# Create Request Offering
New-SCSMRequestOffering @RO

4 Responses to Create Request Offering with PowerShell in Service Manager 2012

  1. Gow December 6, 2013 at 11:04 #

    The created SR is not shown in the console but available in the database.How to make it appear in the console

  2. Paul Willy January 23, 2014 at 19:44 #

    SMLets are awesome, but Microsoft has a way to use the authoring tool CSVs and powershell to create the thousands of requests found in the typical service catalog of a large organization.
    http://blogs.technet.com/b/wincat/archive/2013/03/04/automating-service-manager-service-request-catalog-deployment-through-powershell-and-csv-files.aspx

  3. Roberto February 10, 2014 at 15:31 #

    Hi. Always get this error at the end. The management pack and the template are alredy create ans associated each one

    PS C:\Users\administrator.GDF> C:\Users\administrator.GDF\Documents\RequestOff.ps1
    New-SCSMRequestOffering : Cannot bind argument to parameter ‘ManagementPack’ because it is null.
    At C:\Users\administrator.GDF\Documents\RequestOff.ps1:62 char:26
    + New-SCSMRequestOffering @RO
    + ~~~
    + CategoryInfo : InvalidData: (:) [New-SCSMRequestOffering], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,SMLets.NewSCSMRequestOfferingCommand

  4. Joe Popich February 10, 2017 at 23:46 #

    Thank you very much! Worked like a champ and provided a great foundation on my org automating the automation. Tested on SCSM 2016 using SCSM PowerShell Cmdlets BETA 5 – Joe Popich

Leave a Reply