Starting SMA runbook with parameteres using powershell via REST

Hello!
I am trying to start SMA runbook using powershell via REST. I can do that normally for simple runbook without parameters using REST web service (for example
https://my.server.com:9090/00000000-0000-0000-0000-000000000000/Runbooks%28guid%27bd55d199-c261-4c50-9cef-a83d5c976ce2%27%29/Start
However, I do not understand how to start a runbook which has parameters? For example I have 2 runbooks - 1 with single parameter and second with 3 parameters, how can I pass parameters value? I would really appreciate any help!

Hello
Does this Link answer your question?
http://msdn.microsoft.com/en-us/library/hh921685.aspx
Thanks
Josh
Code from that URL in case the link ever dies:
# Details of the runbook we are going to run
$rbid = "00000000-0000-0000-00000000000000001"
$rbParameters = @{"00000000-0000-0000-00000000000000002" = "This is the value for Param1.";" 00000000-0000-0000-00000000000000003" = " This is the value for Param2."}
# Create the request object
$request = [System.Net.HttpWebRequest]::Create("http:// server01.contoso.com:81/Orchestrator2012/Orchestrator.svc/Jobs")
# Set the credentials to default or prompt for credentials
$request.UseDefaultCredentials = $true
# $request.Credentials = Get-Credential
# Build the request header
$request.Method = "POST"
$request.UserAgent = "Microsoft ADO.NET Data Services"
$request.Accept = "application/atom+xml,application/xml"
$request.ContentType = "application/atom+xml"
$request.KeepAlive = $true
$request.Headers.Add("Accept-Encoding","identity")
$request.Headers.Add("Accept-Language","en-US")
$request.Headers.Add("DataServiceVersion","1.0;NetFx")
$request.Headers.Add("MaxDataServiceVersion","2.0;NetFx")
$request.Headers.Add("Pragma","no-cache")
# If runbook servers are specified, format the string
$rbServerString = ""
if (-not [string]::IsNullOrEmpty($RunbookServers)) {
$rbServerString = -join ("<d:RunbookServers>",$RunbookServers,"</d:RunbookServers>")
# Format the Runbook parameters, if any
$rbParamString = ""
if ($rbParameters -ne $null) {
# Format the param string from the Parameters hashtable
$rbParamString = "<d:Parameters><![CDATA[<Data>"
foreach ($p in $rbParameters.GetEnumerator())
#$rbParamString = -join ($rbParamString,"&lt;Parameter&gt;&lt;ID&gt;{",$p.key,"}&lt;/ID&gt;&lt;Value&gt;",$p.value,"&lt;/Value&gt;&lt;/Parameter&gt;")
$rbParamString = -join ($rbParamString,"<Parameter><ID>{",$p.key,"}</ID><Value>",$p.value,"</Value></Parameter>")
$rbParamString += "</Data>]]></d:Parameters>"
# Build the request body
$requestBody = @"
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<content type="application/xml">
<m:properties>
<d:RunbookId m:type="Edm.Guid">$rbid</d:RunbookId>
$rbserverstring
$rbparamstring
</m:properties>
</content>
</entry>
# Create a request stream from the request
$requestStream = new-object System.IO.StreamWriter $Request.GetRequestStream()
# Sends the request to the service
$requestStream.Write($RequestBody)
$requestStream.Flush()
$requestStream.Close()
# Get the response from the request
[System.Net.HttpWebResponse] $response = [System.Net.HttpWebResponse] $Request.GetResponse()
# Write the HttpWebResponse to String
$responseStream = $Response.GetResponseStream()
$readStream = new-object System.IO.StreamReader $responseStream
$responseString = $readStream.ReadToEnd()
# Close the streams
$readStream.Close()
$responseStream.Close()
# Get the ID of the resulting job
if ($response.StatusCode -eq 'Created')
$xmlDoc = [xml]$responseString
$jobId = $xmlDoc.entry.content.properties.Id.InnerText
Write-Host "Successfully started runbook. Job ID: " $jobId
else
Write-Host "Could not start runbook. Status: " $response.StatusCode

Similar Messages

  • Calling DB2 Stored procedure(with parameters) from powershell

    Hi 
    I am trying to call a DB2 stored procedure that has parameters from Powershell scrip and I am not able to can some one help me here?
    $ServerName = 'XXXX'
    $dbalias='XXXXX'
     $conn_string = "Provider=IBMDADB2;DBALIAS=$dbalias;Uid=;Pwd=;"
     $conn = new-Object system.data.Oledb.OleDbconnection
     $conn.ConnectionString = $conn_string
     $conn.open()
     $query="CALL DBID_CONTROL.GET_TABLE_MAINT_CTL(?,?,?,'MSAS','DATABASE_CONNECTIONS_CUBE','CUBE_PARTITION');"
     $cmd = new-Object system.data.Oledb.OleDbcommand($query,$conn)
      $ds=New-Object system.Data.DataSet
     $da=New-Object System.Data.OleDb.OleDbDataAdapter($cmd)
      $da.Fill($ds) [int]$cur_utc_date_key = $ds.Tables[0].Rows[0][0]
     $cur_utc_date          = $ds.Tables[0].Rows[0][1]
     ###list current date key & current date values
     write-output "current date key value is $cur_utc_date_key"
     write-output "current date value is $cur_utc_date"
     write-output " "
    Thanks

    Hi 
    This is the error message i get when i run the script
    Exception calling "Fill" with "1" argument(s): " CLI0100E  Wrong number of parameters. SQLSTATE=07001"
    At line:45 char:10
    +  $da.Fill <<<< ($ds)
        + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : DotNetMethodException

  • Is it possible to start an application with parameters

    Hello together,
    I have written an application which is stored on a network. People from different computer start it to work with it. Now I have the problem, that I need some different configurations on each computer.
    Is it possible to start a labview application with parameters, like: application.exe -User_1
    The application should check the parametes and should switch to the needed configuration.
    Thanks a lot and best regards,
    Michael
    Solved!
    Go to Solution.

    Hi Michael,
    yes it is possible. First you have to activate the data transfer of your parameters. You can do it in the application builder. It is something like "send command line parameters to exe" which you have to activate. You will get the parameter in your program with the property "App.Args". It is an array with the exe name as the first element and one entry for each additional linked parameter.
    Hope it helps.
    Mike

  • Invoke ADF taskflow with parameters using POST

    Hi,
    Can someone give an example or point me to an example describing invoking adf taskflow with parameters?
    The requirement is to have the parameters passed using POST method and not passing the parameters in the url.
    Jdev: 11.1.1.4.0
    Thanks!

    Hi,
    a use case for the requirement would have been good to have as yet I can't tell if I am helping you with something useful (hope so) or stupid (for which there would be a better approach to use instead if only we knew the use case).
    Anyway, here's a document describing what you asked for
    http://adfpractice-fedor.blogspot.de/2013/07/url-task-flow-call-with-http-post-method.html
    Frank

  • Read Longtext with Parameters using BAPI_MESSAGE_GETDETAIL

    Hi ALL,
    I am trying to read the Longtext of a Message using FM BAPI_MESSAGE_GETDETAIL with Parameters.
    How do I have to write the Parameter in the Longtext so that the FM replaces it with the parameter message_v1 given to the FM?
    I have tried &V1 and &V1& but the FM dumps!
    Let me know!!
    THANKS, Johannes

    Hi
    Example:
    DATA:
      g_message_v1 LIKE bapiret2-message_v1 VALUE 'A',
      g_message_v2 LIKE bapiret2-message_v2 VALUE 'B',
      g_message_v3 LIKE bapiret2-message_v3 VALUE 'C',
      g_message_v4 LIKE bapiret2-message_v4 VALUE 'D',
      g_message    LIKE bapiret2-message,
      gt_text TYPE TABLE OF bapitgb.
    CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL'
      EXPORTING
        id                = '00'
        number            = '398'
      LANGUAGE          = SY-LANGU
        textformat        = 'ASC'
      LINKPATTERN       =
        message_v1        = g_message_v1
        message_v2        = g_message_v2
        message_v3        = g_message_v3
        message_v4        = g_message_v4
      IMPORTING
        message           = g_message
      RETURN            =
      TABLES
        text              = gt_text.

  • Problem to create a link with parameters using a PL/SQL function body

    Hi everybody,
    I need some help to create a link on a SELECT statement.
    I have a region report with type "PL/SQL function body return SQL query".
    I would like to use a link using HTML tag <a href>.
    I know how to do the link, but I don't know to pass a parameters in <a href> statement.
    Always I tried it doesn't work well.
    My PL/SQL anonimous block is, (just with link) :
    DECLARE
    q vARCHAR2(4000);
    BEGIN
    q:='select     "INDICADOR"."NRINDICADOR" as "NRINDICADOR",';
    q:=q||'     "INDICADOR"."DSINDICADOR" as "DSINDICADOR",';
    q:=q||'''<span style="font-weight:bold;">';
    q:=q||'''||TO_CHAR("TOTAL_INDICADOR"."VL_INDICADOR", ''999G999G999G990D00'')||''</span>''';
    q:=q||' as "VL_INDICADOR",';
    q:=q||'     "TOTAL_INDICADOR"."VL_META" as "VL_META" ';
    q:=q||' from     "TOTAL_INDICADOR" "TOTAL_INDICADOR",';
    q:=q||'     "INDICADOR" "INDICADOR" ';
    q:=q||' where "INDICADOR"."NRINDICADOR"="TOTAL_INDICADOR"."NR_INDICADOR"';
    RETURN q;
    END;
    Thanks for any help,
    Alessandra

    Your code is in a default value for an item, right?
    You need to make sure :P33_YEAR is not null and handle the error in the PL/SQL if it is.
    How is P33_YEAR populated? do you pass it in? check to see if it is making it there..
    Message was edited by:
    Bill Carlisle

  • Applescript: How to start an application with parameters

    AppleScripters,
    I am sorry if I have posted this in the inappropriate forum, I saw none with a specific regard to AppleScript.
    Let us presume that we have a regular shell script which when initiated from the Terminal has code such as what follows hereupon:
    /Applications/SeaMonkey.app/Contents/MacOS/seamonkey -editor /Users/joebuffoon/myhomepage.htm
    In order to convert this to AppleScript I was told to use:
    activate application "Seamonkey"
    This works, but seems not to support the ability to either provision the "-editor" argument (such argument would impel Seamonkey to start in "composer mode"), nor does it seem to provision the allowance of supplying a file to open in "composer mode" as the aforementioned command line in my shell script would.
    Can I ask if anyone has any idea how I can do this in AppleScript?
    I am also interested to find a good book on Apple Scripting (preferably one available in PDF format as well, if possible).
    Thanks in advance,
    Stuart

    I saw none with a specific regard to AppleScript
    http://discussions.apple.com/forum.jspa?forumID=724

  • How to start an application with parameters

    AppleScripters,
    Let us presume that we have a regular shell script which when initiated from the Terminal has code such as what follows hereupon:
    /Applications/SeaMonkey.app/Contents/MacOS/seamonkey -editor /Users/joebuffoon/myhomepage.htm
    In order to convert this to AppleScript I was told by an associate to use:
    activate application "Seamonkey"
    This works, but seems not to support the ability to either provision the "-editor" argument (such argument would impel Seamonkey to start in "composer mode"), nor does it seem to provision the allowance of supplying a file to open in "composer mode" as the aforementioned command line in my shell script would.
    Thus, my query is if anyone has any idea how I can do this in AppleScript?
    I am also interested to find a good book on Apple Scripting (preferably one available in PDF format as well, if possible).
    Thanks in advance,
    Stuart

    I've had success with the script below, tested using SeaMonkey version 2.0b1 and Mac OS 10.4.11. It may or may not work with earlier versions of SeaMonkey, however, as the new beta version features UI changes.
    No browser window will open as long as SeaMonkey > Preferences > Appearance is set to open Composer exclusively at startup.
    Be advised that the script is meant to run slowly and might appear to be hanging when such is not the case. Adjusting delay times would be key if the script does fail at any point, however. Good luck.
    +Copy the block of code below and paste it into your AppleScript Script Editor:+
    *tell application "SeaMonkey" to activate*
    *delay 4 -- four-second delay; increase if necessary*
    *tell application "System Events"*
    *tell process "SeaMonkey"*
    *if not (exists window "untitled - Composer") then*
    *key code 21 using command down -- makes new window if necessary ("Command + 4")*
    *end if*
    *delay 2 -- increase if necessary*
    *keystroke "o" using command down -- "Open File…"*
    *delay 2 -- increase if necessary*
    *keystroke tab using shift down*
    *keystroke tab using shift down -- brings focus to text field for file search*
    *keystroke "File Name" -- enters file name (you must replace text within quotes with actual file name)*
    *key code 47 -- enters "dot"*
    *keystroke "html" -- enters extension*
    *delay 10 -- ten-second delay could be MININUM; increase if necessary*
    *keystroke tab*
    *keystroke tab -- brings focus to scroll area*
    *key code 125 -- presses down arrow to highlight specified file*
    *keystroke return -- presses "Open"*
    *end tell*
    *end tell*

  • How to give readonly Permission rights to 1000 users with button using powershell script?

    $site = Get-SPSite
    -Identity "http://mysite/"
    $user = Get-SPUser
    -Identity "mydomain\myuser"
    -Web $site.RootWeb
    $assignment = New-Object
    Microsoft.SharePoint.SPRoleAssignment($user)
    $role = $site.RootWeb.RoleDefinitions[[Microsoft.SharePoint.SPRoleType]::Reader]
    $assignment.RoleDefinitionBindings.Add($role);
    foreach ($web in $site.AllWebs)
        if ($web.HasUniquePerm)
            $web.RoleAssignments.Add($assignment)
    With above script I can give Readonly permission to the users...but at a time I can give permission to only one user...Actually 1000 users requires these permissionMy requirement is I will have a textbox and a button.I will enter username in textbox
    and when i clicked button the required permission should be assigned to the user given in the textbox...can you please tell how can i achieve this........how make to run powershell script when button is clicked.

    Hello,
    Instead of applying security to user level, it'll be better to create a SharePoint group where you will add the users. and use the outof the box interface to give permissions.
    and for your button, just add the direct link to add user
    http://serverurl/_layouts/15/aclinv.aspx?GroupId=7&IsDlg=1 
    replacing the group ID by the id of your new group (you can see it in the url when your are in the group)
    Best regards, Christopher.
    Blog |
    Mail
    Please remember to click "Mark As Answer" if a post solves your problem or
    "Vote As Helpful" if it was useful.
    Why mark as answer?

  • Data Mining shared mail box using powershell via com object Performance is really bad.

    I was trying to pull a report from multiple shared mail boxes by configuring them in outlook. Everything works fine for me here but the problem is that the below script would need a minimum of 10-14 hours on weekly basis. Can you please comment me on how
    can I get more performance? My average mailbox details and my observations are as below:
    It would have about 35 sub folders recursively up to 3 levels in Inbox.
    It would have ~ 300,000 to 400,000 emails.
    I donot know if this can be easily accomplished via EMC Shell but I dont have it either.
    And these are configured in Outlook 2013.
    The biggest folder has about 60000 emails.
    Even plain export without any filter or calculated values in the output is taking the similar time.
    I have even tried to use pick folder and manually executed multiple instances (~10) for each folder but the performance was really worst.
    -------------------------Script Starts here--------------------------------------
    Filter WeeklyReport {If((($_.SentOn -ge ("12/14/2014" -as [datetime])) -and ($_.SentOn -le ("12/20/2014" -as [datetime])))){$_}}
    $ReportFileName="~\Desktop\EMail_Export_$(get-date -f yyyy-MM-dd-HH-mm).csv"
    function GetSubfolders($Parent) { 
        $folders = $Parent.Folders 
        foreach ($folder in $folders) { 
            $Subfolder = $Parent.Folders.Item($folder.Name) 
            Write-Host ("Started processing"+$folder.Name +" at "+$(Get-Date)+" which has "+$folder.items.Count + " items ") -NoNewLine
            $folder.Items | WeeklyReport | Select-Object -Property SenderEmailType,ConversationTopic,CreationTime,ReceivedTime,Importance,LastModificationTime,Size,Subject,CC,ReceivedByName,ReceivedOnBehalfOfName,SenderName,SentOn,SentOnBehalfOfName,To,SenderEmailAddress,Categories,@{N='FolderName';E={$($folder.Name)}}
    | epcsv -Path $ReportFileName -NoTypeInformation -Append
            Write-Host ($(Get-Date))
            GetSubfolders($Subfolder) 
    Add-Type -AssemblyName "Microsoft.Office.Interop.Outlook"
    $olFolders = "Microsoft.Office.Interop.Outlook.olDefaultFolders" -as [type]
    $outlook = New-Object -ComObject outlook.application
    $namespace = $outlook.GetNamespace("MAPI")
    $MailBox=$namespace.Folders | ?{$_.Name -eq "[email protected]"}
    $MailBoxInbox=$MailBox.Folders | ?{$_.Name -eq "Inbox"}
    Write-Host ("Started processing Inbox at "+$(Get-Date)+" which has "+$MailBoxInbox.items.Count + " items") -NoNewLine
    $MailBoxInbox.Items | WeeklyReport | Select-Object -Property SenderEmailType,ConversationTopic,CreationTime,ReceivedTime,Importance,LastModificationTime,Size,Subject,CC,ReceivedByName,ReceivedOnBehalfOfName,SenderName,SentOn,SentOnBehalfOfName,To,SenderEmailAddress,Categories,@{N='FolderName';E={'Inbox'}}
    | epcsv -Path $ReportFileName -NoTypeInformation -Force
    Write-Host ($(Get-Date))
    GetSubfolders($MailBoxInbox)
    $outlook.quit()
    -------------------------Script Ends here--------------------------------------
    --VenuGopal

    Aah, Sorry COM object....
    I have observed that for the execution of the below line hardly it is taking 1-2 seconds for processing 50,000 items and it is similar even if we dont apply the filter.
    $items=$Folder.Items.Restrict($sFilter)
    Just got a doubt and found that the performance issue is not while processing the data but export is taking so much of time. For Example: Execution of the below line starts giving out put on the fly.
    $items|Select-Property$props|ft-a
    Even Out-File is taking so much of time. So, I think I need to start looking out for string builder or Stream Writer rather using epcsv?
    --VenuGopal

  • Copy owners with robocopy using powershell.

    Hi Friends..
    I have created script to copy folder from one location to another location in PS. using Robocopy..
    but By this script cannot copy the owner of the source location folder to destination.. 
    below is the script..
    please help me to add some points to update this script with copy owners of the folders as well..
    Import-Csv "D:\script\file.csv" | ForEach-Object {
                    $Source = $_.Sourceserver
                    $Target = $_.Destinantionserver
                    robocopy.exe $Source $Target /b /e /copyall

    Hi Mr.Raj,
    Sorry for the delay.
    Is there any error message on the cmd prompt when separately running command " robocopy.exe $Source $Target /b /e /copyall " ?
    Also you can make a screenshot and post it here .
    Best Regards
    Elton Ji
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Starting AIR application with parameters

    Hi all
    Is it possible to pass the parameters to the AIR application?
    Something like:
    myapp.air param1 param2
    If yes, how can I get those parameters inside the
    application?

    I actually want to post this link:
    http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=4&postI d=8003
    -ted

  • Calling subtemplate with parameters in footer

    Hi,
    I have the following syntax that calls a conditional footer depending on orgid and country:
    <xsl:call-template name="Super"><xsl:with-param name="organiz"select="ORG"/>
    <xsl:with-param name="country" select="BILL_COUNTRY_DESCRIPTION"/></xsl:call-template>
    This works great if I call it from a form-field but if I paste this code into the footer it does'nt get interpreted as xsl-code.
    Is there any way to work around this?
    Rg. Daniel

    By the way - you can call subtemplates with parameters using the short <??> notation in the real header.
    Edward our local guru gave me syntax:
    HEADER:
    <?call@inlines:aaa?><?with-param:name;string(‘edward’)?><?end call?>
    BODY:
    <?template:aaa?>
    <?param:name;string(‘Default Value’)?>
    Name: <?string($name)?>
    <?end template?>

  • Start GP Process from VC using Web Service with parameters

    Hi,
    II´m trying to instantiate a GP process from a Vc iView using a Web Service; I always used Instantiation via URL but using this method I don´t have any "return" data from GP saying "Ok - The process started succesfully".
    The questions are:
    1) Is possible to start a GP process via Web Services through a VC Flash iview? If so, is posible to send input parameters to the process via the web service?
    2) Does the web service returns any message with the status of the process? ( something like: "the process started succesfully")
    Best regards,
    Marco.

    1) Is possible to start a GP process via Web Services through a VC Flash iview? If so, is posible to send input parameters to the process via the web service?
    A: Yes. You can send input parameters to the service through WS.
    2) Does the web service returns any message with the status of the process? ( something like: "the process started succesfully")
    A: Yes. The return message can be added to the WS. It depends on how do designed the WS.
    -Ashutosh

  • Use Powershell to replace text with image in Word document

    I have a powershell script that uses a Word document as a template to create signatures that I am pushing out to my organization.
    The document is populated with text formatted the way I want the signature to look, that I then do a FindText and ReplaceText on.  This works fine for replacing text with text, but I can't figure out how to properly replace some of the holder text with
    an image and a link.  I found a few posts about adding images to word documents, but none that seem to work properly in this scenario.
    Any insight would be greatly appreciated, thanks!

    Dear BOFH,
    You are correct that method I outlined is not for inserting an image into a signature block (which would be in Outlook, not Word).  The links you post do certainly deal with outlook signatures, well done... Except that the question was about how to
    use a Powershell script to replace text in a Word document with an image.  Sure it was framed in the context of creating signatures, but the poster expressed that they already had a method of generating and replacing text, and just needed to know, as
    I did, how to do the thing they actually asked.
    Please BOFH... Please forgive my audacity in hoping to find a reference (any reference) to how to replace Word text with images via Powershell in a thread titled "Use Powershell to replace text with image in Word document".
    This is certainly a scripting question, and even something as simple as "You will need to call the .NET methods for the Word find/replace functionality.  Please ask in the Word forums for the correct method to use. 
    If you need help on calling .NET methods look HTTP ://here"support you offered combined with the contempt you offer in response to my actual substantive help to the actual question asked.
    BOFH, you are not better than us, just more arrogant.
    Can you please start your own question as this one has been closed.  Please see scripting guidelines.
    We cannot guarantee you satisfaction as this is a user supported forum.  The is no SLA for community support.  Perhaps if you posted a better worded question as a new topic someone might be able to help you resolve your issue.
    The topic you are posting on is closed and answered.
    ¯\_(ツ)_/¯

Maybe you are looking for

  • Why no sound on YouTube?

    Why am I unable to get sound when viewing YouTube and demo Videos sent in e-mails? I'm also experiencing no sound with iTranslate app

  • Difference between ECC 5.0 and R/3 4.7

    Hi all, Can anyone help me in finding difference between ECC5.0 and 4.7 versions? Regards, Murali.

  • Insufficient privileges after creating new files

    I have a PowerBook G4 that I sometimes start-up off an external Firewire drive. The Internal HD is locked-down admin-wise as it's a company laptop but sometimes I need to run my own apps that aren't on the internal HD (i.e. Photo Rescue, Aperture, et

  • Direct PDFExport can not convert file with Chinese content

    hi Experts, I am using direct pdfexpert with wcc11.1.1.7 on win7 64bit(Chinese version), after converting a word to pdf, I found the content in pdf is totally unreadable, I guess the charset of word is GBK, is there special configuration for this? Be

  • Attachments causing temporary SBOD

    When I get attachments in emails coming to me, they show up fine, but if I try to drag them to the desktop or something, nothing happens for a couple seconds, then the spinning beachball appears, and it takes about 30-40 seconds for mail to come back