About 54,800 results
Open links in new tab
  1. windows - How to run a PowerShell script - Stack Overflow

    Or: you can run the PowerShell script from the Command Prompt (cmd.exe) like this: powershell -noexit "& ""C:\my_path\yada_yada\run_import_script.ps1""" (enter) according to Invoking a PowerShell script from cmd.exe (or Start | Run) by Kirk Munro. Or you could even run your PowerShell script asynchronously from your C# application.

  2. How to run powershell script from .ps1 file? - Stack Overflow

    Oct 23, 2019 · There are several ways to run a .ps1 file. The simplest way is to right-click the file and choose 'Run with PowerShell'. As others have suggested, you can also run your .ps1 file using powershell.exe either in command prompt or from a BATCH or CMD file. As follows: powershell.exe -File C:\Script.ps1

  3. Running CMD command in PowerShell - Stack Overflow

    One solution would be to pipe your command from PowerShell to CMD. Running the following command will pipe the notepad.exe command over to CMD, which will then open the Notepad application. PS C:\> "notepad.exe" | cmd. Once the command has run in CMD, you will be returned to a PowerShell prompt, and can continue running your PowerShell script.

  4. How to run a Powershell script from the command line and pass a ...

    Dec 5, 2012 · Using the flag -Command you can execute your entire powershell line as if it was a command in the PowerShell prompt: powershell -Command "& '<PATH_TO_PS1_FILE>' '<ARG_1>' '<ARG_2>' ... '<ARG_N>'" This solved my issue with running PowerShell commands in Visual Studio Post-Build and Pre-Build events.

  5. Call PowerShell script PS1 from another PS1 script inside …

    Mar 28, 2018 · Similarly, I can run my custom scripts by just putting the name of the script in the script-block ::sid.ps1 is a PS script I made to find the SID of any user ::it takes one argument, that argument would be the username echo $(sid.ps1 jowers) (returns something like)> S-X-X-XXXXXXXX-XXXXXXXXXX-XXX-XXXX $(sid.ps1 jowers).Replace("S","X") (returns ...

  6. How to run a PowerShell script from a batch file

    PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""C:\Users\SE\Desktop\ps.ps1""' -Verb RunAs}" Rather than hard-coding the entire path to the PowerShell script though, I recommend placing the batch file and PowerShell script file in the same directory, as ...

  7. windows - How to run PowerShell in CMD - Stack Overflow

    I'm trying to run a PowerShell script inside cmd command line. Someone gave me an example and it worked: powershell.exe -noexit "& 'c:\Data\ScheduledScripts\ShutdownVM.ps1'" But the problem is my PowerShell script has input parameters, so I tried, but it doesn't work: powershell.exe -noexit "& 'D:\Work\SQLExecutor.ps1 -gettedServerName "MY-PC" ' "

  8. Running a command as Administrator using PowerShell?

    Sep 12, 2016 · Elevated PowerShell from Start>Run. You cannot run elevated powershell from the "run" command, in 2012R2 or 2016, without shelling twice: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -Command "saps PowerShell …

  9. How to run a PowerShell script without displaying a window?

    Jan 28, 2015 · In other words, the script should run quietly in the background without any sign to the user. Extra credit for an answer that does not use third party components :) I found a way to do this by compiling a PowerShell script to a Windows executable. Third party modules are required to build the executable but not to run it.

  10. How to run an EXE file in PowerShell with parameters with spaces …

    Nov 4, 2009 · PowerShell.exe -Command "& ""C:\Some Script\Path With Spaces.ps1""" The key seems to be that the whole command is enclosed in outer quotes, the "&" ampersand is used to specify another child command file is being executed, then finally escaped (doubled-double-) quotes around the path/file name with spaces in you wanted to execute in the first ...

Refresh