Calling Powershell Script from a vRA Blueprint

Hi all,
Need your help! I have a use case where I need to provide user a dropdown list in the Blueprint so that they can select a project number. The project numbers are dynamic and can be exported to a .csv file and I can then write a PS script to capture that.  I’m just not sure on how to present that data in the vRA Blueprint as the list is always changing?  Is there a way to create a custom Control Type in Property Dictionary say “DropDownListFromPowerShell” OR any other solution to address this use case? Any advice will be greatly appreciated.
Thank you,
Tony

you cant do that in IaaS. you would need to use ASD to do those custom server side look ups in your forms.

Similar Messages

  • Calling powershell script from a batch file

    Hello All,
    I have a batch script that calls a powershell script. Before calling the script I set the execution policy to unrestricted, but when it gets to the line that calls the batch script i still get the confirmation in the command window: "Do you want to
    perform this operation" I then have to press Y for the PS script to run and then my batch script finishes.
    Does anyone know the setting I need to change in order to suppress the confirmation?
    Note: this is Windows 8, see code below
    set THIS_DIR=%~dp0
    powershell Set-ExecutionPolicy unrestricted
    powershell %THIS_DIR%MyScript.ps1 "param1"

    I may sound like a jerk but you really want to look at PowerShell.exe /?
    PowerShell[.exe] [-PSConsoleFile <file> | -Version <version>]
        [-NoLogo] [-NoExit] [-Sta] [-Mta] [-NoProfile] [-NonInteractive]
        [-InputFormat {Text | XML}] [-OutputFormat {Text | XML}]
        [-WindowStyle <style>] [-EncodedCommand <Base64EncodedCommand>]
        [-File <filePath> <args>] [-ExecutionPolicy <ExecutionPolicy>]
        [-Command { - | <script-block> [-args <arg-array>]
                      | <string> [<CommandParameters>] } ]
    PowerShell[.exe] -Help | -? | /?
    -PSConsoleFile
        Loads the specified Windows PowerShell console file. To create a console
        file, use Export-Console in Windows PowerShell.
    -Version
        Starts the specified version of Windows PowerShell.
        Enter a version number with the parameter, such as "-version 2.0".
    -NoLogo
        Hides the copyright banner at startup.
    -NoExit
        Does not exit after running startup commands.
    -Sta
        Starts the shell using a single-threaded apartment.
        Single-threaded apartment (STA) is the default.
    -Mta
        Start the shell using a multithreaded apartment.
    -NoProfile
        Does not load the Windows PowerShell profile.
    -NonInteractive
        Does not present an interactive prompt to the user.
    -InputFormat
        Describes the format of data sent to Windows PowerShell. Valid values are
        "Text" (text strings) or "XML" (serialized CLIXML format).
    -OutputFormat
        Determines how output from Windows PowerShell is formatted. Valid values
        are "Text" (text strings) or "XML" (serialized CLIXML format).
    -WindowStyle
        Sets the window style to Normal, Minimized, Maximized or Hidden.
    -EncodedCommand
        Accepts a base-64-encoded string version of a command. Use this parameter
        to submit commands to Windows PowerShell that require complex quotation
        marks or curly braces.
    -File
        Runs the specified script in the local scope ("dot-sourced"), so that the
        functions and variables that the script creates are available in the
        current session. Enter the script file path and any parameters.
        File must be the last parameter in the command, because all characters
        typed after the File parameter name are interpreted
        as the script file path followed by the script parameters.
    -ExecutionPolicy
        Sets the default execution policy for the current session and saves it
        in the $env:PSExecutionPolicyPreference environment variable.
        This parameter does not change the Windows PowerShell execution policy
        that is set in the registry.
    -Command
        Executes the specified commands (and any parameters) as though they were
        typed at the Windows PowerShell command prompt, and then exits, unless
        NoExit is specified. The value of Command can be "-", a string. or a
        script block.
        If the value of Command is "-", the command text is read from standard
        input.
        If the value of Command is a script block, the script block must be enclosed
        in braces ({}). You can specify a script block only when running PowerShell.exe
        in Windows PowerShell. The results of the script block are returned to the
        parent shell as deserialized XML objects, not live objects.
        If the value of Command is a string, Command must be the last parameter
        in the command , because any characters typed after the command are
        interpreted as the command arguments.
        To write a string that runs a Windows PowerShell command, use the format:
            "& {<command>}"
        where the quotation marks indicate a string and the invoke operator (&)
        causes the command to be executed.
    -Help, -?, /?
        Shows this message. If you are typing a PowerShell.exe command in Windows
        PowerShell, prepend the command parameters with a hyphen (-), not a forward
        slash (/). You can use either a hyphen or forward slash in Cmd.exe.
    Hope that helps! Jason

  • Can we execute a Powershell script from the Javascript?

    Hi,
    I have a certain requirement to add a Custom ribbon button in document library and there was a powershell script to be run for the selected item in the library.
    I have struck with executing a Powershell script from the javascript function.
    Can anyone please suggest me if this was achievable
    Thanks, Swaroop Vuppala

    Hi Swaroop,
    To execute server side code in a custom ribbon button script, using application page is a common way to do this, besides, you can also use a page dialog, which is similar with application page but display as model dialog, another way is javascript
    _dopostback and delegate control, the following article contains detailed information about this, please refer to it for more information:
    Invoke server side code on SharePoint ribbon click:
    http://sharepointnadeem.blogspot.in/2012/07/invoke-server-side-code-on-sharepoint.html
    Thanks,
    Qiao Wei
    TechNet Community Support

  • Calling SAP scripts from WEBDYNPRO

    Hi
    We need to call SAP scripts from WebDynpro application.  As per my understanding we need to do following steps
    Create a new RFC function module and create sap script output in PDF format.For this
        - use OPEN_FORM , by assigning TDGETOTF='X' in the Options(Structure
          ITCPO). 
        - call function module CLOSE_FORM with option OTFDATA
        - convert OTF data to PDF by using function module CONVERT_OTF_2_PDF
    Now I would like to know how to display the PDF string from WebDynpro.
    Please help....
    Regards
    Sujith

    Hi,
    You can call by creating external window method.
    create LINK to URL or LINK TO ACTION according to requirement, for this. write code in onaction of that.
    data: iv_url type string value 'http://<server>:<port>/sap/bc/gui/sap/its/webgui?~transaction=*se38 RS38M-PROGRAMM=rsparam;DYNP_OKCODE=SHOP'.
      data: api_component  type ref to if_wd_component,
              window_manager type ref to if_wd_window_manager,
              window type ref to if_wd_window.
      api_component = wd_comp_controller->wd_get_api( ).
      window_manager = api_component->get_window_manager( ).
      window = window_manager->create_external_window(
                     url = iv_url
                     modal = abap_false ).
      window->open( ).
    Cheers,
    Kris.

  • Calling GUI Scripting from ABAP program

    Is it possible to call GUI Scripting from ABAP and thus to use GUI Scripting as an alternative to CALL TRANSACTION?
    Is the class CL_JAVA_SCRIPT suitable to access GUI Scripting engine? Accessing ABAP data object would work as well in this case as i think. What SAP Logon and WAS releases are required? Is the 6.20 release sufficient for this case?
    I would appreciate if somebody could post an example.

    Hi,
    CL_JAVA_SCRIPT has nothing to do with SAPGUI Scripting.
    Calling SAPGUI Scripting API from ABAP could be possible for programmes experienced with OLE automation calls from ABAP coding.
    The hardest thing will be, to access the scripting engine handle as an entry point. Once you have a handle in your abap session, any api function can be invoked.
    Best regards
    Jens
    BTW: SAP testtool eCATT does call SAPGUI-Scripting from ABAP.

  • Execute powershell script from ssis?

    Hi,
    I was trying to use the execute process task to kick off a powershell script.  However, nothing happens when I run in debug (the component turns yellow and stays yellow).  Any idea if what I am trying to do is possible and the proper way to configure
    it?
    btw, I am using powershell for the remoting capabilites.  I need to execute a bat file on a remote server which runs a process in a legacy program. 
    Update:  When I name the ps1 script file in the executable window, it opens it in notepad.  This would be like the default if you double clicked the file.
    Mark

    To run a PowerShell Script from SSIS package. Add a "Execute Process Task" in SSIS and use the following command text.
    This works just great, plus the "-ExecutionPolicy ByPass" switch will take care of any server script policies.
    C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe
    -ExecutionPolicy ByPass -command ". 'L:\Powershell_Script\Script1.ps1' 'param1' 'param2'"
    Regards
    Deepak

  • Does Forefront Endpoint Protection 2010 block powershell scripts from running?

    Hi all,
    I have a task that runs a Powershell script on a set schedule on a particular machine.  It has failed to run and I thought 1 of the potential reasons would be that FEP 2010 blocks the Powershell script from being run.  Does FEP 2010 do that?  If so, where can I find the setting to allow Powershell scripts (or VB scripts or Java scripts) to be run by my task?
    Thanks for your help in advance.
    Howard Lee - Microsoft

    If the script detect as malicious , FEP will block it, otherwise it won't block normal and safe PowerShell scripts. You may take a look at event viewer and see whether it being blocked or detect as malicious code by FEP or not.

  • Calling Python Script from LabVIEW

    Hello Everyone,
    I want to call the Python script from LabVIEW.
    I tried with using at the command line but i am unable to run that script file..
    i have gone through LabPython but i am unable to call the scripts from there also..
    If someone has an example of a VI which invokes a python script, it will be very helpful...
    Thanks a lot in advance
    Regards
    Avni

    avni wrote:
    I have to invoke the Script file at command prompt.
    Can you descriobe your restriction(s) concerning "invoke the script at the command prompt"?  There may be ways around that.

  • Calling Ant script from Jdeveloper

    Hello Gurus,
    I am trying to call Ant script from Jdeveloper.
    I am able to call it when i don't use any javac in ant script.
    But as soon as i include a javac command
       <javac srcdir="${src}" destdir="${build}"/>
    I get below error
    C:\ant\windows\svn\AntJava\Project1\build.xml:20: Unable to find a javac compiler;
    com.sun.tools.javac.Main is not on the classpath.
    Perhaps JAVA_HOME does not point to the JDK.
    It is currently set to "C:\Oracle\jdk160_24\jre"
    Needless to say i already have implemented all the steps mentioned in the internet.
    I have my JAVA_HOME correctly set in my PATH environment variable.
    I have tools.jar in the CLASSPATH
    Please give a solution from JDeveloper perspective and not a generic one as i am done with all the steps provided in internet.

    any one?????

  • Call TCL script from TestStend or CVI

    Hi
    I would like to call TCL script from TestStand or CVI.
    It’s possible ? and what do I need for it ?
    T.U

    Hi,
    here is a link to an example
    http://zone.ni.com/devzone/explprog.nsf/6c163603265406328625682a006ed37d/e1d9dbb13c6119f786256a3000696642?OpenDocument
    Hope this helps
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • Not able to call sql script from shell program

    Hi Gurus,
    I am facing issue while calling sqlplus script from my shell program. Please find below my shell script. This program I've written and registered as for one of concurrent program
    in oracle applications.
    p_userid_passwd=$1
    p_appl_login=$2
    p_user_name=$3
    p_request_id=$4
    v_conc_request_id=${5}
    p_to_role=${6}
    p_from_role=${7}
    p_subject=${8}
    p_body=${9}
    p_dist_list=${10}
    v_request=${11}
    v_file_path_name=/u01/oraspt/REQUEST
    cd $APPLCSF/$APPLOUT
    echo "v_conc_request_id" $v_conc_request_id
    echo "p_to_role" $p_to_role
    echo "p_from_role" $p_from_role
    echo "p_subject" $p_subject
    echo "p_body" $p_body
    echo "p_dist_list" $p_dist_list
    echo "v_request" $v_request
    ls -l $v_request
    if [ $? -ne 0 ]
    then
       echo "No output request generated"
    else
       echo "Output request generated" 
    fi
    echo "connecting to ftp for placing out file to DB server"
    echo FTP to 99.60.17.11
    echo username: "oraspt"
    echo pw:        
    ftp -i -n 99.60.17.11 << EOF2
    user "oraspt" orakdk
    cd $v_file_path_name
    put $v_request
    bye
    EOF2
    output=`sqlplus -s /nolog <<EOT
    whenever sqlerror exit failure;
    connect  apps/apps
    set verify off;
    set serveroutput on size 120000;
           DECLARE
             l_errbuf      varchar2(300);
             l_retcode     varchar2(300);
           BEGIN      
            XXFND_SEND_MAIL.SEND_NOTIFICATIONS(  errbuf        => l_errbuf
                                               , retcode       => l_retcode
                                               , p_request_id  => $v_conc_request_id
                                               , p_to_role     => $p_to_role
                                               , p_from_role   => $p_from_role
                                               , p_subject     => $p_subject
                                               , p_body        => $p_body
                                               , p_dist_list   => $p_dist_list);
         EXCEPTION
            when others then
               dbms_output.put_line('Error encountered :'||SQLERRM);
         END;    
    EOT
    `
    echo "connecting to ftp for deleting output file"     
    echo FTP to 99.60.17.11
    echo username: "oraspt"
    echo pw:        
    ftp -i -n 99.60.17.11 << EOF2
    user "oraspt" orakdk
    cd $v_file_path_name
    delete $v_request
    bye
    EOF2
    echo "Deleted successfully"Output for script is as below
    v_conc_request_id 451906
    p_to_role DC.DKHOO
    p_from_role DC.DKHOO
    p_subject Receivable audit report10
    p_body Please find Audit Report Attachment.
    p_dist_list
    v_request o451906.out
    -rw-r--r-- 1 applspt dba 2368 Dec 28 15:06 o451906.out
    Output request generated
    connecting to ftp for placing out file to DB server
    FTP to 10.60.17.11
    username: oraspt
    pw:
    connecting to ftp for deleting output file
    FTP to 10.60.17.11
    username: oraspt
    pw:
    Deleted successfullyPlease let me know how to trigger pl/sql script.
    Thanks in advance for your help.
    Regards
    Nagendra
    Edited by: 838961 on Dec 27, 2011 11:25 PM

    Please find output as suggested, I've placed set -x in script.
    + p_userid_passwd=APPS/APPS
    + p_appl_login=1110
    + p_user_name=DC.DKHOO
    + p_request_id=451949
    + v_conc_request_id=451945
    + p_to_role=DC.DKHOO
    + p_from_role=DC.DKHOO
    + p_subject=Receivabless
    + p_body=report
    + p_dist_list=
    + v_request=o451945.out
    + v_file_path_name=/u01/oraspt/REQUEST
    + cd /u01/applspt/inst/apps/SPT_nfs-stg-app1/logs/appl/conc/out
    + echo v_conc_request_id 451945
    v_conc_request_id 451945
    + echo p_to_role DC.DKHOO
    p_to_role DC.DKHOO
    + echo p_from_role DC.DKHOO
    p_from_role DC.DKHOO
    + echo p_subject Receivabless
    p_subject Receivabless
    + echo p_body report
    p_body report
    + echo p_dist_list
    p_dist_list
    + echo v_request o451945.out
    v_request o451945.out
    + ls -l o451945.out
    -rw-r--r-- 1 applspt dba 2368 Dec 28 15:54 o451945.out
    + '[' 0 -ne 0 ']'
    + echo 'Output request generated'
    Output request generated
    + echo 'connecting to ftp for placing out file to DB server'
    connecting to ftp for placing out file to DB server
    + echo FTP to 10.60.17.11
    FTP to 10.60.17.11
    + echo username: oraspt
    username: oraspt
    + echo pw:
    pw:
    + ftp -i -n 10.60.17.11
    ++ sqlplus -s /nolog
    + output=Connected.
    + echo 'connecting to ftp for deleting output file'
    connecting to ftp for deleting output file
    + echo FTP to 10.60.17.11
    FTP to 10.60.17.11
    + echo username: oraspt
    username: oraspt
    + echo pw:
    pw:
    + ftp -i -n 10.60.17.11
    + echo 'Deleted successfully'
    Deleted successfully

  • Execute a powershell script from a windows store apps

    Hello Everybody !
    I'd like to launch a powershell script from a windows store apps.
    In fact the purpose is install a windows store apps from an other windows store apps.
    Any ideas?
    Thanks

    If it's a sideloaded LOB application, you can do this using a brokered component:
    http://blogs.msdn.com/b/wsdevsol/archive/2014/04/14/cheat-sheet-for-using-brokered-windows-runtime-components-for-side-loaded-windows-store-apps.aspx
    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined
    objects and unknown namespaces.

  • Can I query to PowerShell scripts from Power Query ?

    Can I query to PowerShell scripts from Power Query ?
    I want to use PowerShell result for Data Visualization in Excel.
    Like importing from web, odata, hdinsight, etc,
    I want to import result of PowerShell script.
    PowerShell can do a lot of system management.
    Regards,
    Yoshihiro Kawabata 

    This is not possible today and is not something that's likely to be implemented. The combination of being able to easily share queries and being able to easily launch external scripts that can do anything supported by the current user's permissions is
    something of a security nightmare.

  • Run Powershell script from Scheduled Task as "NT Authority \ SYSTEM"

    Hello, dear Colleagues.
    Cannot make Powershell script from Scheduled Task as "NT Authority \ System"
    Action: Start a program - 
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command "C:\script.ps1"
    The matter is that script is working, moreover if to run Task with Domain Account it works too.
    Checked Run with highest privileges, changed "Configure for" field, tried different arguments (-noprofile, -noexit, -executionpolicy bypass, -command, -file,") - no luck.
    Didn't you try to make it work with SYSTEM account?
    Thanks.

    Hi fapq,
    Try this link task schedulers
    Note
    To identify tasks that run with system permissions, use a verbose query (/query/v). In a verbose query display of a system-run task, the Run As User field has a value of NT AUTHORITY\SYSTEM and
    the Logon Mode field has a value of Background only.
    Naveen Basati

  • Run PowerShell script from C# writing to input pipe

    Hello,
    I am trying to run a PowerShell script from C# (I have no control over what's in the script). The script may have a prompt like "Press enter to continue". So my goal is:
    1. Get text output from the script (easy, many examples available)
    3. If output contains "Press enter to continue", write a blank line to the running script's pipe to make it finish its job and quit
    4. If output does contain that prompt, just let it exit by itself without sending any input
    Note that commands in this PS script also try to get at script's file path, so I can't read script from file and pass it as text. It has to be executed as a script so it knows where it's located.
    I have done this with .exes and batch files before. All you do in that case is process.StandardInput.WriteLine() which "types" enter into the input stream of script you are trying to control. But this does not work with Power Shell. How do I do this?
    I have tried using PS object model like so:
    using (Pipeline pipeline = runspace.CreatePipeline())
    Command command = new Command(scriptPS, true, true);
       pipeline.Commands.Add(command);
       pipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output);
       pipeline.Input.Write("\n");
       Collection<PSObject> psresults = pipeline.Invoke();   //...
    But I get an error because the script prompts:
    "A command that prompts the user failed because the host program or the command type does not support user interaction. Try a host program that supports user interaction, such as the Windows PowerShell Console or Windows PowerShell ISE, and remove prompt-related
    commands from command types that do not support user interaction, such as Windows PowerShell workflows."
    I also tried using Process, and running PowerShell with -File switch to execute the script, then write to StandardInput with C#. I get no errors then, but the input is ignored and doesn't make it to PowerShell.
    Please help!

    No man, what kind of answer is that? You should have left it unanswered rather than waste people's time like this. I already seen those links before I posted my question. They address the issue of specifying script parameters, but not
    writing to the input pipe.
    Fortunately I did figure this out by writing a custom script host for PowerShell. Anyone interested can read about this in detail on MSDN (fortunately simple material with samples you can copy paste as I did, so this solution takes little time to implement).
    Implement PSHost interface. Nothing special here, just paste directly from MSDN sample and modify their SetShouldExit function definition to contain just a "return;". Here's the relevant link:
    http://msdn.microsoft.com/en-us/library/windows/desktop/ee706559(v=vs.85).aspx
    Implement PSHostUserInterface interface. This is the ticket to solving this problem
    (see below). Here's the MSDN link:
    http://msdn.microsoft.com/en-us/library/windows/desktop/ee706584(v=vs.85).aspx
    Implement PSHostRawUserInterface. This may not be required (not sure) but I did anyway. Nearly a direct paste from MSDN:
    http://msdn.microsoft.com/en-us/library/windows/desktop/ee706601(v=vs.85).aspx
    So, there are two PSHostUserInterface function implementations that are of particular interest. First is Prompt (read header comment to see why):
    /// <summary>
    /// When script attempts to get user input, we override it and give it input programmatically,
    /// by looking up within promptInput's dictionary<string,string> or lineInput array.
    /// PromptInput dictionary is mapped by input prompt (for example, return "" in response to "Press ENTER to continue")
    /// LineInput is a regular array, and each time the script wants to prompt for input we return the next line in that array;
    /// this works much like piping inputs from a regular text file in DOS command line.
    /// </summary>
    /// <param name="caption">The caption or title of the prompt.</param>
    /// <param name="message">The text of the prompt.</param>
    /// <param name="descriptions">A collection of FieldDescription objects that
    /// describe each field of the prompt.</param>
    /// <returns>Throws a NotImplementedException exception.</returns>
    public override Dictionary<string, PSObject> Prompt(string caption, string message, System.Collections.ObjectModel.Collection<FieldDescription> descriptions)
    Dictionary<string, PSObject> ret = new Dictionary<string, PSObject>();
    foreach (FieldDescription desc in descriptions)
    if (this.promptInput.Count != 0)
    ret[desc.Name] = new PSObject(this.promptInput[desc.Name] + "\r\n");
    else if (this.lineInput != null && this.currentLineInput >= 0 && this.currentLineInput < this.lineInput.Length)
    ret[desc.Name] = new PSObject(this.lineInput[this.currentLineInput++] + "\r\n");
    else
    if (desc.DefaultValue == null)
    ret[desc.Name] = new PSObject("\r\n");
    else
    ret[desc.Name] = new PSObject(desc.DefaultValue);
    return ret;
    Next is PromptForChoice. Here I opted to always return the default choice, but you could rewrite it to read from somewhere to "simulate" reading from input pipe just like the function above:
    public override int PromptForChoice(string caption, string message, System.Collections.ObjectModel.Collection<ChoiceDescription> choices, int defaultChoice)
            return defaultChoice;
    Last but not least, here's a ReadLine implementation (again read header comment):
    /// <summary>
    /// If the LineInput is set, "read" the next line from line input string array, incrementing line pointer/// </summary>
    /// <returns>The characters that are entered by the user.</returns>
    public override string ReadLine()
    if (this.lineInput != null && this.currentLineInput >= 0 && this.currentLineInput < this.lineInput.Length)
    return this.lineInput[this.currentLineInput++];
    else
    return Console.ReadLine();
    Both are exposed as properties:
    /// <summary>
    /// Gets or sets the input pipe override
    /// </summary>
    public string Input
    get
    return string.Join("\n", this.lineInput);
    set
    if (value != null)
    this.lineInput = value.Split('\n');
    this.currentLineInput = 0;
    else
    this.lineInput = null;
    /// <summary>
    /// Gets or sets input pipe override for named prompts
    /// </summary>
    public Dictionary<string, string> PromptInput
    get
    return this.promptInput;
    set
    this.promptInput = value;
    And finally, here's how the whole shebang is used:
    /// <summary>
    /// Runs a powershell script, with input pipe arguments
    /// </summary>
    /// <param name="script">Path of the script to execute, or script text</param>
    /// <param name="inline">Whether or not to execute script text directly, or execute script from path</param>
    /// <param name="unrestricted">Whether or not to set unrestricted execution policy</param>
    /// <param name="parameters">Parameters to pass to the script command line</param>
    /// <param name="inputOverride">Input to pass into the script's input pipe</param>
    /// <param name="inputOverrideName">Input to pass into the script's input pipe, to each prompt by label</param>
    /// <returns>Output lines</returns>
    public static string PowerShell(string script, bool inline, bool unrestricted = false, Dictionary<string, string> parameters = null, string inputOverride = null, Dictionary<string, string> inputOverrideByName = null)
    string output = null;
    ScriptHost host = new ScriptHost();
    (host.UI as ScriptHostUserInterface).Input = inputOverride;
    (host.UI as ScriptHostUserInterface).PromptInput = inputOverrideByName;
    using (Runspace runspace = RunspaceFactory.CreateRunspace(host))
    runspace.Open();
    if (unrestricted)
    RunspaceInvoke runSpaceInvoker = new RunspaceInvoke(runspace);
    runSpaceInvoker.Invoke("Set-ExecutionPolicy Unrestricted");
    using (Pipeline pipeline = runspace.CreatePipeline())
    if (inline)
    pipeline.Commands.AddScript(script);
    else
    Command command = new Command(script, true, true);
    foreach (KeyValuePair<string, string> param in parameters)
    command.Parameters.Add(param.Key, param.Value);
    pipeline.Commands.Add(command);
    pipeline.Commands.Add("Out-String");
    pipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output);
    Collection<PSObject> psresults = pipeline.Invoke();
    var sb = new StringBuilder();
    foreach (PSObject obj in psresults)
    sb.AppendLine(obj.ToString());
    output = sb.ToString();
    pipeline.Dispose();
    runspace.Close();
    return (host.UI as ScriptHostUserInterface).Output + "\r\n" + output;
    As you can see, I also did some magic with the .Output property. That just accumulates lines of text output by the script in every WriteXXX function implemented in your custom PSHostUserInterface. The end result of all this, is that if you have a script
    that has prompts, choices or reads from standard input, you can execute the script within the context of your custom script host written as above, to control precisely what strings are passed to it in response to prompts.
     

Maybe you are looking for

  • Attaching .scc files in PP -- not working

    Okay... I'm almost at my wits end. I've been doing closed captioning and subtitling for 10 years, I use the industry-standard software, I follow the workflows... and yet I cannot get any captions to display in PP CS 5.5 I've looked through the forums

  • Strange problem in applet application

    Hello Everybody, I hava an applet whit an image. This image has to changed by color, and text has to be added to the image. The text color is also changable. Here is where it goes wrong. When I change the background color of the applet, the transpara

  • Material Cost display on Order

    I have created a value category Z1 - Material and assigned a cost element. Then In the maintenance order I have selected a material in component tab. The material has same cost element that is assigned to value category Z1. But cost of material is st

  • What exactly does accounts in restrictions do?

    As far as the ipod touch manual has mentioned (yes the latest), accounts in restrictions only blocks changes, additions and subtractions to the calendar, contacts and mail. But some of my friends have said that it also stops you from activating and l

  • Change the Iview Size

    Hi Experts, I would Like To set iviews At Various Sizes in my Potal Page. Plz Help Me Out. Thanks.