How to execute power shell script file inside DSC script resource

Hi,
How to execute /call powershell scirpt file inside DSC script resource , some thing like below and capture the status of execution.
Node $AllNodes.NodeName
Script ExecuteSQLDeploy
#SetScript = {powershell.exe .\SQLDeploy.ps1  "param1" "param2" "param3" "param4" "param5" }
#TestScript= {powershell.exe .\SQLDeploy.ps1  "param1" "param2" "param3" "param4" "param5 }
#GetScript= { return $true;}
Basawaraj

Thanks for reply. 
 Now i am able to execute the power shell script with DSC. I  am getting no error when i run , but the script logic wrote inside  ( deploying sql incremental changes ) not working . I am using SQLCMD in the powershell script to deploy sql
changes . Can you please elaborate on "script is compatible with DSC" , the script
should not contain write-host cmdlet.... etc something like that.
Copying recursively from ****************************** to ************************** succeeded.
Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
An LCM method call arrived from computer ************ with user sid **********************************************
[V-BAKANT]: LCM:  [ Start  Set      ]
[V-BAKANT]: LCM:  [ Start  Resource ]  [[Script]ExecuteSQLDeploy]
[V-BAKANT]: LCM:  [ Start  Test     ]  [[Script]ExecuteSQLDeploy]
[V-BAKANT]: LCM:  [ End    Test     ]  [[Script]ExecuteSQLDeploy]  in 0.1110 seconds.
[V-BAKANT]: LCM:  [ Start  Set      ]  [[Script]ExecuteSQLDeploy]
[V-BAKANT]: LCM:  [ End    Set      ]  [[Script]ExecuteSQLDeploy]  in 0.3010 seconds.
[V-BAKANT]: LCM:  [ End    Resource ]  [[Script]ExecuteSQLDeploy]
[V-BAKANT]: LCM:  [ End    Set      ]
[V-BAKANT]: LCM:  [ End    Set      ]    in  0.8810 seconds.
Operation 'Invoke CimMethod' complete.
Time taken for configuration job to complete is 0.923 seconds
Basawaraj

Similar Messages

  • How to Execute Power Shell Command From Windows Application.

    Hi All Experts,
    I want to execute power shell commands from my windows application.
    Is it possible ?
    Please let me know your comments..
    Thanks.

    I have not tried this, but apprently it is easy as in the sample pasted below. please see this article for more details
    http://geekswithblogs.net/Norgean/archive/2012/09/19/running-powershell-from-within-sharepoint.aspx.
    Let me know how it goes...
    public string RunPowershell(string powershellText, SPWeb web, string param1, string param2) {
    // Powershell ~= RunspaceFactory - i.e. Create a powershell context
    var runspace = RunspaceFactory.CreateRunspace();
    var resultString = new StringBuilder();
    try
    // load the SharePoint snapin - Note: you cannot do this in the script itself (i.e. add-pssnapin etc does not work)
    PSSnapInException snapInError;
    runspace.RunspaceConfiguration.AddPSSnapIn("Microsoft.SharePoint.PowerShell", out snapInError);
    runspace.Open();
    // set a web variable.
    runspace.SessionStateProxy.SetVariable("webContext", web);
    // and some user defined parameters
    runspace.SessionStateProxy.SetVariable("param1", param1);
    runspace.SessionStateProxy.SetVariable("param2", param2);
    var pipeline = runspace.CreatePipeline();
    pipeline.Commands.AddScript(powershellText);
    // add a "return" variable
    pipeline.Commands.Add("Out-String");
    // execute!
    var results = pipeline.Invoke();
    // convert the script result into a single string
    foreach (PSObject obj in results)
    resultString.AppendLine(obj.ToString());
    finally
    // close the runspace
    runspace.Close();
    // consider logging the result. Or something.
    return resultString.ToString();
    Ok. We've written some code. Let us test it.
    var runner = new PowershellRunner();
    runner.RunPowershellScript(@"
    $web = Get-SPWeb 'http://server/web' # or $webContext
    $web.Title = $param1
    $web.Update()
    $web.Dispose()
    ", null, "New title", "not used");
    -Sangeetha

  • How to execute unix shell script from Java ...

    Hi,
    Anyone know how to execute unix shell script from Java?
    Suppose I have several shell scripts written in perl or tcl or bash.
    I just want to catch the output of that script.
    Is there any ready to use module/object for this?
    Please let me know, this is quite urgent for my study assigment.
    Thanks in advance,
    Regards,
    me

    Look up Runtime.exec()

  • How to execute unix shell script in webdynpro?

    hi all,
      We have some iquirement of executing script in unix.If anyone know How to execute unix shell script in webdynpro?
    best regard
    reefish

    Ree,
    1. Find SSH client for windows, then execute SSH with Runtime.exec() on local host with arguments like remote host, auth, command to execute etc.
    2. Get SSH client in Java and execute SSH commands on remote host using pure Java API.
    Don't ask me for links, Google works today, I checked this
    Valery Silaev
    SaM Solutions
    http://www.sam-solutions.net

  • How do I convert PDF/JPEG file in "Brush Script MT" font to Word Document

    How do I convert PDF/JPEG file in "Brush Script MT" font to Word Document? (I checked with Acrobat XI pro but no use

    You cannot in Adobe Reader. You can try in Acrobat, but first you must try to run OCR (Text Recognition). I have never tried OCR on a script font.

  • How to create power shell script to upload all termset csv files into the SharePoint2013 local taxonomy ?

    Hi Everyone,
    I want to create a powershell script file
    1) Check a directory and upload all termset csv files into the SharePoint local taxonomy.
    2) Input paramaters - directory that containss termset csv files, Local Termstore to import to,
    3) Prior to updating get a backup of the existing termstore (for rollback/recovery purposes)
    4) Parameters should be passed in via XML file.
    Please let me know how to do it.
    Regards,
    Srinivas

    Hi,
    Please check this link
    http://termsetimporter.codeplex.com/
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • HOW TO RUN POWER SHELL SCRIPT UNDER SAFE MODE

    hi
    is is possible to run the power shell script (with Management instrument code ) in safe mode
    if so then how to do it, please explain the procedure 

    Hi CHELLAPPA,
    Based on my research, we can use powershell in safe mode, and I also tested on server 2012 R2:
    You can also open cmd and type "powershell" to use powershell script.
    If there is anything else, please feel free to post back.
    Best Regards,
    Anna Wang

  • How to execute a shell script?

    Hi,
    could someone please tell me the correct way to execute a shell script? For example run.sh located in my resources?
    Thanx in advance!

    Odds are good that Apple doesn't want you running shell scripts on an iPhone, but somebody else might have information to the contrary.

  • How to execute linux sh command from inside CF

    I am using CFMX 7,0,0,91690 Enterprise on Redhat Enterprise Linux 4.9 with Apache webserver 2.0.52.  I have a coldfusion template that queries from a Postgresql 8.0 database, copies the data from the queries into a set of files in one folder on the linux server, and then has a CFEXECUTE tag at the very end that calls a bash shell script on the same server. The shell script takes the files from the one folder, merges some of their content together, moves them to another folder, adds header and footer, and sets ownership and permissions.  These 2 scripts have been in place and working perfectly for several years now. No changes were made to content, permissions, or ownershop of scripts.  Suddenly last Friday the coldfusion script seems to have lost its ability to execute the shell script properly.  It does execute it and the shell script attempts to do some of the steps, but the resulting files are missing the content and have the linux environmental variables and their values displayed instead.  Clearly its getting an error but that is not being reported back to me. After the CF script ends, if I manually execute the shell script from the linux command line, it works perfectly. I tried giving it more permissions but that did not help.  Redhat support suggests I run the script with "sh -x" to get more detailed output for debugging, but I would need to do that from inside the CF script since that is where the problem is.  Is it possible to execute a shell script from inside a CF script using a linux "sh" command in some way (instead of the cfexecute, just so I can see debugging info)? Thanks in advance for any suggestions. Julie

    Thanks for the suggestion, tried that too:
    <cfexecute name="/bin/sh" arguments="-x /bin/siscopy" outputfile="/home/coldfusion/sh_output.txt" timeout="600" />
    still didn't work.  Script ends with this coldfusion error:  Timeout period expired without completion of /bin/sh
    It does not complete the task of making the files, and the sh_output.txt file which is supposed to capture the -x output, is empty.
    Thanks,
    Julie

  • How to execute a shell command in java?

    here, my environment is redhat 7, jdk 1.5.
    i don't know how to use the shell command in java.
    i want to use this function:
    #include <stdlib.h>
    int system(const char * string);
    please give me some ideas. and Thank you so much if coming with a little demo.

    i know i should use JNI. because i have to use C lib.
    but i have already use JNI to wrapper the original code the cpp code and java code is :
    //: appendixb:UseObjImpl.cpp
    //# Tested with VC++ & BC++. Include path must
    //# be adjusted to find the JNI headers. See
    //# the makefile for this chapter (in the
    //# downloadable source code) for an example.
    #include <jni.h>
    #include <stdlib.h>
    extern "C" JNIEXPORT void JNICALL
    Java_UseObjects_changeObject(
    JNIEnv* env, jobject, jobject obj) {
    jclass cls = env->GetObjectClass(obj);
    jfieldID fid = env->GetFieldID(
    cls, "aValue", "I");
    jmethodID mid = env->GetMethodID(
    cls, "divByTwo", "()V");
    int value = env->GetIntField(obj, fid);
    printf("Native: %d\n", value);
    env->SetIntField(obj, fid, 6);
    env->CallVoidMethod(obj, mid);
    value = env->GetIntField(obj, fid);
    system("preprocess -path sha.c");
    printf("Native: %d\n", value);
    } ///:~
    //: appendixb:UseObjects.java
    // From 'Thinking in Java, 2nd ed.' by Bruce Eckel
    // www.BruceEckel.com. See copyright notice in CopyRight.txt.
    class MyJavaClass {
    public int aValue;
    public void divByTwo() { aValue /= 2; }
    public class UseObjects {
    private native void
    changeObject(MyJavaClass obj);
    static {
    // System.loadLibrary("UseObjImpl");
    // Linux hack, if you can't get your library
    // path set in your environment:
    System.load(
    "/root/jproj/UseObjImpl.so");
    public static void main(String[] args) {
    UseObjects app = new UseObjects();
    MyJavaClass anObj = new MyJavaClass();
    anObj.aValue = 2;
    app.changeObject(anObj);
    System.out.println("Java: " + anObj.aValue);
    } ///:~
    i modify this two file which is from TIJ-2edition.
    the output is
    Native: 2
    Native: 3
    Java: 3
    but what i want to be executed "preprocess -path sha.c" does not work.
    i have change the command to, such as "df", "ls" etc. but none of them works
    please help me.

  • How to execute a shell command?

    What class and method should I use to set an environment variable on a local system? And how do I execute a shell command in Java?
    Thanks!

    I don't know about setting environment variables from java, but I do know how to execute system commands (and from there you could modify environment variables).
    Use Runtime.getRuntime().exec()
    There are quite a few pitfalls with using this though...
    1. It's platform dependent
    2. Doing this creates a Process. If this process has output, you need to read this, otherwise the output buffer will overflow, and that would be bad... Input is not so bad (either supplying it or not ;)
    3. If you use Win for example, and want to do a "dir", there are complications, as there is no dir.exe file, and hence it can't be executed... Do a search for this topic, there's plenty on how to get around it.
    Anyway, there's plenty more info on Runtime.getRuntime().exec(), have a look around.
    Cheers,
    Radish21

  • Accessing shell environment variables inside OMBPlus script

    Hi,
    I have a problem accessing an environment variable inside OMBPlus script. I can 'see' the env. var values when using tclsh, but when I use OMBPlus.sh it doesn't work?
    Anybody has an example of how to do this?
    For example: puts $::env(MYVAR)
    Thanks,
    Ed

    Hello!
    Issue the command:
    puts [array names env];
    this will print you the content of the env array which is definitely not the environment variables.
    If you want your environment variable appear in the env tcl variable then you must edit the ombplus.bat file and pass it through a java option like this:
    -DMYENV="%MYENV%" (on windows assuming you declared MYENV).
    Now puts $env(MYENV) will work.
    Regards,
    Robert

  • How to execute ( merge ) a .reg file?

    I tried to execute the .reg file from the below program.
    But there is error when i run it
         Error opening : java.io.IOException: CreateProcess: registry.reg error=0
    Is there other way I can do to execute (merge) this .reg file?
    Runtime r=Runtime.getRuntime();
                        Process p=null;
                        p=r.exec("registry.reg");

    Try using the windows "Start" command.

  • How to execute a shell script which is present in remote machine using ODI

    I have requirement of executing a batch (shell script) which is present in the remote machine.
    i have an ODI agent in remote machine as well. I have created agent locally by using the remote machine IP and port.
    I am able to test the agent successfully. But when i am executing the package using that agent it is failing with the following error
    errorODI-1226: Step Execution of the Scenario REMOTE_DEMO version 001 fails after 1 attempt(s).
    ODI-1241: Oracle Data Integrator tool execution fails.
    Caused By: oracle.odi.runtime.agent.invocation.InvocationException: HTTP/1.1 500 ODI-1423: Warning connecting to Agent localagent: work repository WORKREP1 is not bound to the master
    My Work Repository Name is : WORKREP1
    Remote Work Repository Name is:WORKREP_LOCAL.
    Could anyone please help me regarding this.
    I can't download shell script and run it locally this needs to be run on that remote machine only.
    Thanks
    senthilkumar

    This is the code.
    1. we can declare types dynamically
    2. Internal table dynamically
    3. Select querry dynamically
    just copy paste this code
    Here is the code for your question
    DATA:v_fieldname
    TYPE fieldname,
    l_PROG TYPE string,
    v_mess TYPE string,
    l_sid TYPE string,
    wa_ddfields TYPE dntab.
    DATA i_tab TYPE STANDARD TABLE OF string.
    DATA:l_str TYPE string,
    l_str1 TYPE string.
    PARAMETERS matnr type marc-matnr.
    end-of-SELECTION.
    *build the subroutine pool
    APPEND 'PROGRAM subpool.' TO i_tab.
    APPEND `LOAD-OF-PROGRAM.` TO i_tab.
    APPEND `DATA i_tab1 TYPE TABLE OF vbak.`      TO i_tab.
    APPEND `DATA l_rows TYPE i.`      TO i_tab.
    APPEND `select * into table i_tab1 from vbak.` To i_tab.
    append 'DESCRIBE TABLE i_tab1 LINES l_rows.' to i_tab.
    append 'Write :  l_rows .' to i_tab.
    GENERATE SUBROUTINE POOL i_tab NAME l_PROG
    MESSAGE v_mess
    SHORTDUMP-ID l_sid.
    IF sy-subrc = 0.
    PERFORM ('LOOP_AT_TAB') IN PROGRAM (l_PROG) IF FOUND.
    ELSEIF sy-subrc = 4.
    MESSAGE v_mess TYPE 'I'.
    ELSEIF sy-subrc = 8.
    MESSAGE l_sid TYPE 'I'.
    ENDIF.
    Edited by: vijay wankhade on Jan 1, 2009 5:34 PM
    Edited by: vijay wankhade on Jan 1, 2009 5:34 PM

  • How to execute a a terminal file ?

    I need to execute a file with terminal commands without open the terminal.
    I just want to double click the file and get the terminal open and the commands executed like when you run a CMD file in Windows.
    I created a file.command but it did not work.
    Thanks !

    For running scripts in the shell you don't even need a .command extension.  For example, here's a line,
    echo "hello world"
    Save it in a file, call the file "hello", with whatever you are using as a text editor, and not a .rtf (rich text file).  Then in terminal do,
    chmod +x "hello"
    and then type,
    hello
    You will see "hello world " on your terminal.  I'm assuming file "hello" is in the current directory.
    Just in case you missed the lines I added to the above post I repeat what I added here:
    I recommend you use a better test editor, for example BBEdit, TextWrangler, and a whole host of other text editors better suited for the purpose.

Maybe you are looking for