How to run a Powershell script via a batch file

I'm new on using Powershell and I have a fundamental question regarding running a powershell script. Basically, I wrote a file of commands as shown below.

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe - PSConsoleFile "C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\vim.psc1" - NoExit-command "C:\MyScripts\RunSpanshot.ps1".

I run the batch file and nothing seems to happen. What is the problem with trying to run the RunSpanshot.ps1 script as shown above? -any help is appreciated.

Thank you

You could do

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\vim.psc1" -NoExit -Command "& 'C:\My Scripts\RunSpanshot.ps1'"

Tags: VMware

Similar Questions

  • How to run the powershell script of command with several parameters

    Is there a way to run a powershell script from the dialog box run with several parameters? In addition, the path to the script contains spaces, for example, c:\powershell scripts\script.ps1.

    Take a look at http://www.powershell.nu/2009/12/16/running-scripts-with-arguments-in-powershell/ which explains how to pass arguments to a script.

    André

  • How to run multiple Powershell scripts in PowerCLI

    I have a large number of scripts that I would run into lots of PowerCLI. I found a way to call some Powershell scripts from a file of commands like the following (with the permission of Jan Egil Ring), which works very well except for scripts PowerCLI where a connection to a VC or ESX Server must be established before the script can be executed:

    PowerShell-command '& C:\MyScripts\script1.ps1 '.

    PowerShell-command '& C:\MyScripts\script2.ps1 '.

    PowerShell-command '& C:\MyScripts\script3.ps1 '.

    If a VC connection is on using Connect-VIServer PowerCLI, then scripts can each be run from the prompt without connection information and credentials, however, if scripts are placed in a file of DOS commands, it is necessary to place an order Connect-VIServer in each script, which will prompt you for credentials every time , so if I have 10 scripts, I will have to enter the credentials of 10 times. Is it possible to establish the connection and then run a set of Powershell scripts, or is there a way to integrate the identification information in the script so that it will connect to the VI server without asking confirmation?

    Thank you

    Ed Z

    2 options 1 persist credentials on disk, you can find the code on poshcode.org to do.

    Option 2 is to use - Session when using Connect-VIServer. The session is stored in the variable $defaultVIServer. If write you it to a file you can load this file and re-use this same session, assuming that it is still valid (i.e. it has not expired.)

  • Call calculation Scripts in a Batch file

    Dear all,

    Can I know how to call calculation Scripts in a Batch file?

    Explain to me in detail

    Concerning
    Vijay

    If you need run three Calc calc1, calc2, and calc3.

    Reel to '> ';

    connection > > about >;

    Set timestamp

    the value of message level.

    run the calculation >. > .calc1;
    run the calculation >. > .calc2;
    run the calculation >. > .calc3;

    disconnection;

    spool off;

    "exit";

    -type the script above into Notepad and save it as calc.mxl
    -You can call this file maxl cmd Windows or in a shellscript as ESSMSH > calc.mxl

    Note:
    It is hardcoded in the script vb script or shell script, we can effectively automate the same.

  • Run the powershell script in Workflow VCO

    Hi guys,.

    I'm pretty new to VCO and I am facing difficulties to get what I want. For you, this will be a Basic... but here's my question:

    I have a WF that I use in the WFStubmachineprovisionning that can generate me a name of virtual machine based on the selection of the user while he asked for a virtual computer in the VRA.

    The VM provisionned name looks like this: W203PKLXXX and I need to replace the XXX with a number that is available on the network.

    To do this, I need to query the DNS to see if there is, if not, 002 001... And so on... until an available and I send the full name of the virtual machine to the WF Stubprovisionning.

    This my first try to interact between VCO and a Powershell script. I can run script PS on my host configured, but do not know how to send variables to the custom WF that generates the name of the script of PS and send the name of VM from the script of the PS to the next step.

    Can someone give me a sample of variable to manage? I can't find anything on the net

    Just to tell you that I managed.

    the PS has returned an XML object, not a string. I had to use the method getxml() javascript property, and parse the string to get the value I need

    I also had to blind correctly (getxml) entry and exit (PS)

    If needed I can send you a few screenshoot

  • a way to run a powershell script?

    Y at - it another way to configure a script to be able to run by either double clicking on it or other means other than having opened powercli and goes the script and it works.

    It is not the best way to do it, but to help people not use powercli it will help running. The script that I know is very well to run... we are running win2k8 if it matters

    You can create a shortcut and under properties make it a race of PowerShell.exe.

    You pass as an argument to the PowerShell script runs.

    In the script, you ensure that the pssnapin PowerCLI is loaded.

    For example, the target of the shortcut can be

    %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe-fichier 'MyScript.ps1.

    You add in MyScript.ps1

    Add-PSSnapin VMware.VimAutomation.Core

    before that the script uses a PowerCLI cmdlet.

  • Autorun script or a Batch file to launch the cd w / Autorun is disabled.

    We shot some Autorun at the AD level.   Does anyone know of a batch file or a script that I could use to launch the CD for a small population of employees?

    Hi LeonardCarrier,

    The issue of Windows XP, you have posted is related to Windows XP in a domain environment. It is better suited for the IT Pro TechNet public. Please ask your question in the TechNet forums for assistance.

    Hope the helps of information.

  • How to write the sql command in the batch file

    Jin
    I m using oracle 9i on windows. I want to know how I can write the sql on the command file command. I want to use a batch file to use the sql like shutdowm command & start command and any select command too.
    so please tell how can I do?


    thxs

    Tried looking for what he superdba.

    Can't connect to sqlplus using sys using a batch file

    HTH
    Aman...

  • Run the PowerShell script?

    flash.filesystem import. *;

    import flash.desktop.NativeProcess;

    import flash.desktop.NativeProcessStartupInfo;

    var file:File = new File("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe");

    var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();

    nativeProcessStartupInfo.executable = file;

    var args:Vector. < String > = new Vector. < String > ();

    args.push("c:\\test\\sendTest.ps1");

    nativeProcessStartupInfo.arguments = args;

    process: NativeProcess var = new NativeProcess();

    Process.Start (nativeProcessStartupInfo);

    Try to get Powershell to run sendTest.ps1 in the c:\test folder. I get no error or anything else.

    If I have this number at the command prompt:

    c:\test\sendTest.ps1 PowerShell

    It works very well. But I can't get the correct syntax to run it from the AIR.

    Someone tell me what I am doing wrong?

    You must set ExecutionPolicy argument:

    var args:Vector. = new Vector.();
    args.push("-ExecutionPolicy");
    args.push("Unrestricted");
    args.push("c:\\test\\sendTest.ps1");
    

    Without correct ExecutionPolicy, you get PowerShell PSSecurityException error. You can listen for events from native process of ProgressEvent.STANDARD_ERROR_DATA to see.

  • OpenScript / chaining script / how to run all the scripts if we fail?

    Hello

    I have a problem using openscript and please I would like to know if there is a work around.

    Here's what I do:

    with script open:

    1 / I record many different scripts for an application: a script = a feature

    2 / then I create a script and I run all these previous script.


    The problem is:

    I get an error 'Timeout occurred waiting for the page to load.' which is a normal mistake (the link is broken, the page is missing, etc.).

    I can't get back, and stops the main script. Although I also want other scripts to be read.


    I tried to put the ERR_RESPONSE_TIME_ERROR Warn option (instead of failure). But no way! It breaks down!



    Please could you tell me what I'm missing?


    Thank you.




    Michael

    Published by: user12252276 on 24 nov. 2009 01:38

    Michael

    You can put a try catch around the control that you want to manage and then save the error so reported ex:

    try {}
    Web.Window (6, "/ web: window [@title ='Oracles Test Manager for Applications Web - Login']") .waitForPage (null);
    {
    Think (0);
    }
    } catch (Exception e) {}
    getStepResult () .setError (e.getMessage ());
    }

    hope this helps

    Alex

  • How to run the Xbox 360 via the port monitor on Qosmio G20

    I just bought an Xbox 360 on eBay with a VGA cable which must connect the console directly to the port external monitor on my Qosmio, theoretically allowing me to use the screen on my laptop as screen for my video games.

    I'm just a little worried that this port at the back of my Qosmio is technically to connect another monitor, not an input device, so it will work? And if so, how do I do?

    I intend to spend a little time DIY autour with it when the console gets, but I guess it should be as simple hanging everything and then do it through media library or even simply initialize the TV itself rather than with the laptop everything?

    Ideas, ideas, tips or advice (especially if you did before or know someone who has) would be appreciated.

    A similar topic has already been discussed here in the forum. I recommend you research a bit.

    XBOX
    http://forums.computers.Toshiba-Europe.com/forums/thread.jspa?threadID=11183&MessageID=40470
    http://forums.computers.Toshiba-Europe.com/forums/thread.jspa?threadID=15102&MessageID=55091

    XBOX 360
    http://forums.computers.Toshiba-Europe.com/forums/thread.jspa?threadID=9575&MessageID=33794

  • How to run a Unix script on a remote Unix server to Windows 7?

    Are what Windows has still provides remote shell tools to allow the launch of the scripts on remote Unix servers?

    I used to do this on Windows XP with the "rsh" command But this command does not exist on my Windows 7 Pro.

    I tried the new 'winrm' and 'winrs' orders, but I'm not able to connect to my Unix account. I wonder if the winrs command is designed only for Windows connections to Windows?

    Thank you.

    Hello

    Your question of Windows 7 is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the IT Pro TechNet public. Please post your question in the TechNet Windows 7 networking forum.

    http://social.technet.Microsoft.com/forums/en-us/w7itpronetworking/threads

  • How to run the ODI scenario via a command prompt

    Hi experts

    Please let me know if we can launch ODI scenario using the prompt command or any means other than the operator.

    Concerning
    Frank

    Go to /oracledi/bin in the command prompt and call the command startscen with the parameters below.

    Published by: Elite Sexyno on February 28, 2011 16:19

  • How to run and pass parameters to the exe file in the txt file.

    Hello

    I am facing problem with passing parameters in the .exe file, which is run by labview.firstly that I have script .txt with the settings that I have to go to the .exe file. This .exe file is also a software, and this script is written for her. And now I have to create program in labview which should satisfy the following points.

    1. I have to use a button named "Run script". If I pressed the button, it should open the browser where I can choose the script .txt file.

    2 .exe application is expected open(Path already chossen).

    3. After passing the .exe application settings should be closed.

    4 and labview should now update its parameter

    I just open using Exce.vi .exe file, but I didn't get any idea to do more than this.can someone please help me?

    Thanks norbert. CAN I love it? What should I change now? VI attached below...

  • Why not be able to run MRT.exe using the batch file?

    When I run the following script using the batch file, MRT cannot be run.

    Does anyone have any suggestions?

    Thanks in advance for your suggestions

    off @echo
    C:\WINDOWS\system32\Mrt.exe/q/f

    Hello

    ·         The computer is connected to a domain network?

    ·         What is the error you get when trying to execute the batch file?

    If the computer is connected to a domain network, I suggest you to report this issue in Windows XP IT Pro Forums: http://social.technet.microsoft.com/Forums/en-US/category/windowsxpitpro

    Thank you.

Maybe you are looking for

  • iTunes Store, prompting the old Apple ID

    Today, I went to a new device, the previous iTunes backup restore local. While restoring the apps, I asked Apple several times one ID old, I no longer use for almost 1 year. I read several threads on the same subject, I have followed the steps in the

  • How do reset you a windows xp to its default settings?

    problems to get on the internet because it says that we need restore the default settings. It's a laptop and wifi works and connects, but internet explore does not work

  • I need my password.

    I need my password. Thank you.

  • SmartWatch 2 compatible with CRA S

    I would like to know if my s Xperia Arc will be compatible with the new Smartwatch 2? My Arc S has already been updated for android 4.1.2. It's only the bluetooth 3.0, which is troubling me. I think that my phone bluetooth 2.1. It will be compatible

  • "HP printer Assistant" for HP Officejet 6600 WON 'T run.

    Windows 7 64 bit NO error message NO changes to the system until after it started then improved then just put update HP firmware It worked yesterday.  When you have selected the "HP OfficeJet 6600" desktop on the desktop shortcut, he ran a sreen whic