Is it possible to pass a multi line PowerShell code block to the Invoke-Command ScriptBlock option?

Hello,
In my code I am trying to start a windows service on an Azure VM via Azure Automation.  My code fragment is:
$vm = Get-AzureVM -Name $VMName -ServiceName $VMServiceName
$uri = Get-AzureWinRMUri -ServiceName $vm.ServiceName -Name $vm.Name
# Run a command on the Azure VM
$PSCommandResult = InlineScript {
$options = New-PSSessionOption -SkipCACheck
$output = Invoke-Command -ConnectionUri $Using:uri `
-Credential $Using:Credential `
-SessionOption $options `
-ScriptBlock { stop-service -DisplayName <ServiceName> -Force }
My issue is: Is it possible to pass in a multiple line PS block as the ScriptBlock option?
After looking around online, there appeared to be two options:
$psblock = {
line1
line2
line3
Or
$PSCommand = @"
Line1
Line2
Line3
But I have not been able to get either of these to work. (I was trying to end up with something like below)
$output = Invoke-Command -ConnectionUri $Using:uri `
-Credential $Using:Credential `
-SessionOption $options `
-ScriptBlock { $psCommand }
Can someone offer a suggestion? Putting a few lines of PS code directly into the ScriptBlock parameter does work but it looks ugly!
Thanks!

Thanks for getting back to me!
I have tried as you suggested but when I attempt to publish the runbook I get this error:
Runbook definition is invalid. Cannot store the results of this type of expression into a variable. Only the results of commands, pipelines, constant expressions, foreach statements, parallel and sequence statements can be stored in variables.
 However if I just cut and paste the same code inside the ScriptBlock { CODE HERE } it works.
Perhaps I am breaking the rule as listed above in bold? Would variable declarations in the code block not be allowed?

Similar Messages

  • How to pass multiple words as a search argument on the Acrobat Command Line?

    I am trying to launch Acrobat using a multi-word search parameter on a Windows XP box. However, Acrobat is stripping the spaces between words. For example, I am trying to load Acrobat and have it search for the phrase "vision changes" using a Command Line like this:
    C:\>"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe" /A search="vision changes" c:\temp\theDocument.pdf
    When Acrobat loads, it shows the search panel with the phrase "visionchanges" in it. The space between the two words is gone and naturally it can't find the phrase.
    I have read both the PDF Command Line parameter documents I could find. This format works fine for URLs, but for Shelling Acrobat on the local system, it doesn't work because of the space stripping problem. I have tried lots of different variants of quote characters, escape characters, even HTML characters like "&nbps;", but nothing works.
    Does anyone have an answer?
    For the curious here are links to the two PDF documents I found that cover the command line arguments:
    http://www.adobe.com/devnet/acrobat/pdfs/PDFOpenParameters.pdf
    http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf
    Thanks,
    Robert

    Hey Robert,
    Did you note that in the "pdf_open_parameters.pdf" document, it says that the value of the Search parameter is treated as a list of (single) words, not as a string of words (phrase)?
    It says it explicitly: "You can search only for single words. You cannot search for a string of words."
    PS: I'm replying to your query as a sort of thank you for posting the links to those documents. It helped me to find the way of conditioning how to open a pdf.

  • Is it possible to make a multi-line form that text flows through?

    When a line is full, I'm looking for a way for it to jump to the next line down, flowing the text to the next line. is there a way to do this?

    There are no really seamless ways to implement this, unfortunately.

  • Is it possible to pass Presentation Variable into SQL code?

    Is it possible to create a Prompts that can pass data inputted in the Prompt to a SQL statement?
    Example
    User inputs
    Dashboard Prompt: Date Between today date AND yesterday's date
    Which pass information to a measure and labels the the information:
    CASE WHEN "Date.Datetable" = {@}DATE1 THEN 'Today' Else 'Yesterday' END FROM "TABLE_Example"

    You can pass a selected value from prompt to filter a measure or display it as a dynamic label/column header.
    To set the label like a dynamic column header:
    http://total-bi.com/2011/03/obiee-dynamic-column-headings/
    If that is for the measure value then use presentation variable and use them in the formula of the column.
    If that is to pass value to the physical layer or bmm layer then use session variable, set it using request variable in prompt and use the session variable in bmm or physical layer view.
    Let me know if this helped.
    Regards,
    Jay

  • Is it possible to pass some data from a successful test to the next one?

    For example, after testing the login system in one test, we can test all other features using an authentication token obtained in the first test.
    Is that possible in the new FlexUnit ?
    Many thanks,
    Adnan

    No.
    Tests are completely independent of each other. If you needed to do something like this, you could either use the before to login each time, or you could use the BeforeClass to login once and keep your token as a static property of the class.

  • Not possible to print a SWF in a PDF document using the Print command in Ad

    Have a PDF with 3 pages, page 1 and 3 contains text and the 2nd page contains a SWF animation made with Xcelsius 2008. When printing the document using the Print function in Adobe the 2nd page is always empty, the SWF is never printed.  To be able to print the 2nd page containing the SWF animation I must use the print function in the Flash player (right click on the SWF animation).
    This problem should, according to Business Objects, be solved with the new version of Adobe Reader 9, but the problem still appear.

    I have seen this.  Adobe 9 cannot print embedded flash objects.  Xcelsius Engage/2008 includes a print button you can include on your dashboards to allow you to print them from your pdf files.

  • Multi-line tableview row?

    Hello all,
    Does anyone know if it's possible to have a multi-line tableview row?  My situation is that there is a lot of information to show in my tableview row, and I'd like to split up the information in to to lines...but I want the two lines with the same color (I'm utilizing the alternating now), and want just one checkbox.
    Here's and example ( __ used to show spacing):
    []__material___description__price____quantity____total price  -->start of material 1
    ___plant______g/l account__del date
    []__material___description__price____quantity____total price  -->start of material 2
    ___plant______g/l account__del date
    Is there a way to do this?
    Thanks in advance,
    Lisa

    Hi Lisa,
    yes you can do what you want outside the MVC programming model.
    Firstly, your current code inserts two <input> tags in each table row that look like this.
    Input 1<input name="text" id="text" title="inputfield" value="value"><BR>
    Input 2<input name="text" id="text" title="inputfield" value="value"><BR>
    When the form is submitted back to the server the input fields are passed as name value pairs. Therefore you need to ensure the name and/or id of each input tag is unique. It is also important that you include the rowid of the table row in the name of the tag so you know to which row it refers.
    So your RENDER_CELL_START method might look more like this...
          DATA: input_id_1 TYPE string,
                input_id_2 TYPE string,
                text       TYPE string,
                bee_html   TYPE REF TO cl_bsp_bee_html.
          text = 'value'.
          input_id_1 = input_id_2 = p_row_index.
          CONCATENATE:
            'input_' input_id_1 '_1' INTO input_id_1,
            'input_' input_id_2 '_2' INTO input_id_2.
          CONDENSE input_id_1 NO-GAPS.
          CONDENSE input_id_2 NO-GAPS.
          CONCATENATE:
            '<input name="' input_id_1 '" id="' input_id_1 '" value="' text '">' INTO input_id_1,
            '<input name="' input_id_2 '" id="' input_id_2 '" value="' text '">' INTO input_id_2.
          CREATE OBJECT bee_html.
          bee_html->add(
                html1 = 'Input 1'
                html2 = input_id_1
                html3 = '<br/ >Input 2'
                html4 = input_id_2 ).
          p_replacement_bee ?= bee_html.
    This code inserts <input> tags that look like this...
    Input 1<input name="input_xx_1" id="input_xx_1" value="value"><br/ >
    Input 2<input name="input_xx_2" id="input_xx_2" value="value">
    ...where 'xx' is the row index.
    Now we need to be able to read these name value pairs when the form is submitted. You can most easily do this in the onInputProcessing event of the page like this...
      DATA: ffields TYPE TIHTTPNVP.
      request->get_form_fields( CHANGING fields = ffields ).
    Now the ffields itab contains the name value pairs - you just need to parse them to obtain the rowid for each value.
    Enjoy!
    Cheers
    Graham Robbo

  • How do I center a text field when input can be single or multi-line?

    I'm creating a form in Adobe Acrobat Pro XI and have almost everything the way I want it.  One of my last problems is trying to get a text in a text field centered.  The input is sometimes a single line and sometimes multi-line.  If I set it up so the multi-line entries are centered, then the single line looks off ... and vice versa.  Is there any way to have the text automatically centered in the text field regardless of whether it's single or multi-line?

    Unfortunately, there's no way to set up a field so that the text is guaranteed to be vertically centered in both cases. If you set it up so that rich text formatting is enabled, it's possible for a user to vertically center, but it's not something you can preconfigure so that it will remain in effect when the field is cleared. For a user to do this, with the focus set to the field they'd have to display the Properties toolbar (Ctrl+E), click the "More..." > Paragraph > Alignment > Text Middle [button]

  • Multi line tool tip in ABAP Web Dynpro

    Hello experts,
    do you know a possibility to apply a multi-line tool tip to a ui element in abap web dynpro ?
    The OTR compresses multiple lines to one long line...
    Thanks in advance.

    This is not a forum for application specific questions. [Web Dynpro|Web Dynpro Java; , BSP , CRM development, ... have their own forums.

  • Multi line tool tip / OTR text

    Hello experts,
    do you know a possibility to apply a multi-line tool tip to a ui element in abap web dynpro ?
    The OTR compresses multiple lines to one long line...
    Thanks in advance.

    Hi,
    I realize this is a very old thread, but in case others, like myself, finds it, here's a simple fix for this. In the OTR text add a constant for the desired linefeed - for example "\n":
    Alias ZPACKAGE/ALIAS: Line 1\nLine 2
    * Generate tooltip text
    DATA:
      lo_el_ui TYPE REF TO if_wd_context_element,
      lv_tooltip TYPE string.
    lv_tooltip = cl_wd_utilities=>get_otr_text_by_alias( 'ZPACKAGE/ALIAS' ).
    REPLACE ALL OCCURRENCES OF '\n' IN lv_tooltip WITH cl_abap_char_utilities=>newline.
    lo_el_ui->set_attribute( name = 'TOOLTIP' value = lv_tooltip ).
    The same technique can be used for tabulators (using constant
    cl_abap_char_utilities=>horizontal_tab), however, there's no guarantee how this will presented in the browser.
    Best regards,
    Jacob Laursen

  • Multi Line output using Mail Adatper?

    I'm sending email using the Mail Package Format and the Mail adapter.  Is it possible to create a multi line body to produce a readable email message?
    The <Content> tag is used for the email body and adding multiple content tags does not work.  Here is the Mail Format for reference.
    <ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">
      <Subject></Subject>
      <From></From>
      <To>[email protected]</To>
      <Content>This is the body.</Content>
    </ns:Mail>
    Thanks for the help.
    Brian

    Brian,
       I had a similar problem. I had a rfc return that could contain multiple rows. Like this...
    <return>
      <message>Line 1</message>
      <message>Line 2</message>
      <message>Line 3</message>
    <return>
    I wanted all the messages to display in the content on their own line so in the mapping I added a advanced function called AddText so my mapping looked like this...
    message>AddText>Context
    Here's the function I used.
    String b = "";
    for (int i=0;i<a.length;i++)
    b = b + a[ i ] + "\n";
    result.addValue(b);
    Hope that helps out.
               - Emmett

  • Printing all text in a multi-line text field??  Can it be done?

    I was wondering if there is a way to print out a multi-line field and have all text entered print as well.  Currently, anytime someone enters more information in a multi-line text field on our form than is set to show without scrolling, when a PDF is created for printing from the results page, only the text that fits within the specified size prints.  You can scroll within the PDF and read it all, but I can't seem to figure out how to get all of the text to show and have that field resize accordingly on the printed copy.
    Is there a way?  Thanks.

    Is there an easy way to determine the character count that is visible in a given multi-line text field when designing the form, so if I want to allow 500 characters, the text box I create is large enough for 500 characters?  Obviously I can just do a trial and error process using a cut and paste of 500 characters and testing it, but is there an easier way?

  • Multi line values in mail forms to send emails

    Hi All,
    Ours is CRM 2007 application, as part of new capability adding to the system, we need to send email to customer with few details once service tickets saved in the system. we decided to use mail forms to create the template and send email to the customer with details. as part of this we need to send multi line values as well in the mail form - email as shown below. example field here is for working hours of the customer office.
    Saturday - Sunday 10am - 4pm
    Saturday - Sunday 10am - 4pm
    (excluding public holidays)
    Can some body tell me how to send the multiline values using mail forms - emails to customers. right now we receive the last line. I dont see any help in mail form documetation as well on this.
    I appreciate any help in this if you already have some solution.
    Regards,
    Srinivas

    Hi,
    Are you using below any FM to send mail ?
    1. CRM_IM_EMAIL_CREATE_SEND_40 2. CRM_IM_EMAIL_CREATE_SEND_51
    if so, then inside this FM there will be call to BADI CRM_IM_ADD_DATA_BADI . This badi will get the data for custom/additional attribute values. Basically it will get one value ( last value ).
    What u might need to do is after this badi call u need to loop ur values and set it . For doing that u might need to make this FM tocustomer name space or look for implicit enhancements.
    We have done similarly for sending mail duringcampaign execution. That was done in different place.
    hope it might help you to analyse more.
    Regards
    Sandeep

  • REGEXP_INSTR on a multi line string

    Hello ,
    I am trying to search through a string that is stored with multi line and trying to find the first occurrence of a character.
    For example : The string is -
    "This is a sample
    text to test
    from [first string] to [second string] "
    When i try to search for the first occurrence of "[" and "]" regular instr function is returning the complete string
    This is the query i used:
    The above string is stored in a varchar2 column named - comments
    select substr(comments,instr(comments,'['),instr(comments,']')) from my_table
    This above query returns : [first string] to [second string]
    i assume instr returns the first occurence of a letter in the given string. i was looking for [first string] but it returns me both. Can this be replaced with regexp_instr function?.
    Any help on this would be much appreciated.
    Thanks

    user619203 wrote:
    Hello ,
    I am trying to search through a string that is stored with multi line and trying to find the first occurrence of a character.
    For example : The string is -
    "This is a sample
    text to test
    from [first string] to [second string] "
    When i try to search for the first occurrence of "[" and "]" regular instr function is returning the complete string
    This is the query i used:
    The above string is stored in a varchar2 column named - comments
    select substr(comments,instr(comments,'['),instr(comments,']')) from my_table
    This above query returns : [first string] to [second string]
    i assume instr returns the first occurence of a letter in the given string. i was looking for [first string] but it returns me both. Can this be replaced with regexp_instr function?.
    Any help on this would be much appreciated.
    Thankslike this?
    SQL> ed
    Wrote file afiedt.buf
      1  with tmp as
      2  (
      3  select 'This is a sample
      4  text to test
      5  from [first string] to [second string]' txt from dual)
      6  select substr(txt, instr(txt, '['), instr(txt, ']') - instr(txt, '[') + 1)
      7* from   tmp
    SQL> /
    SUBSTR(TXT,INS
    [first string]Also questions of these types are better asked in {forum:id=75} forum.

  • Chebychev Polynomial fitting results show multi lines

    I am using "nonliear curve fit.vi" with defined Chebychev Polynomial  function to fit XY data.  Strangely, if I enlarge the upturn part, I clearly see the fitting results show multi-lines (2-4) . Please the the attached snapshot.
    weitong
    LV2013
    Attachments:
    chebychev Ploynomial fit.PNG ‏48 KB
    chebychev Ploynomial fit-whole.PNG ‏19 KB

    Thanks.
     I found the reason: the data X values are not mononicaly, i. e.  there are local oscillations at some region.
    After sorting the raw data, the fitting results show single line. 
    Is the sorting of X values necessary before Chebychev Polynomial fitting?

Maybe you are looking for

  • How to retrieve the outer parameter of a stored procedure in XSQL page

    I have to call a stored procedure in the xsql page that returns a resultset (ie. oracle table/record type) through an outer paramter. Is there any built-in xsql action tag available to get the parameter and present it in xml on the page? please help,

  • Mac Plus software needed

    I have an original 128K Mac that has been upgraded to a 1MB Mac Plus that is being readied for sale. Unfortunately, somewhere in this mess I have managed to lose the OS boot floppy. I have the complete set of System 7 install diskettes, but the proFi

  • Problems loading adobe elements 6

    My i mac refuses to read new elements 6 disc. It tries to load disc, nothing happens then after 3 or 4 attempts it automatically ejects the disc. Have been told that this could be due to a case sensitive disc, unfortunately i do not know what that is

  • Since upgrade to lion on Mac pro the atv2 connection is extremely slow

    I upgraded my macro to lion and since then it takes 3 min to pull up the library and times out when trying to down load the show.  It worked fine under snow leopard. I have removed and redone the home sharing on both ATV2 and macro still have the sam

  • Adobe pdf 8.0 save locations

    When I make a pdf in AICS3 with adobe pdf 8.0, it automatically saves it to the desktop. Does anyone know how to change the save location? thanks, Jacob L.