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

    If your script is named with the .ps1 extension and you're in a PowerShell window, you just run ./myscript.ps1 (assuming the file is in your working directory). This is true for me anyway on Windows 10 with PowerShell version 5.1 anyway, and …

  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. How to enable execution of PowerShell scripts? - Super User

    Type the following command to run the script and press Enter: & "C:\PATH\TO\SCRIPT\first_script.ps1" In the above command, make sure to change "PATH\TO\SCRIPT" to the location of your script. After you complete the steps, the script will run, and if it was crafted correctly, you should see its output without issues.

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

    Dec 5, 2012 · The term '.\Foo.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

  5. How to execute a .ps1 from another .ps1 file? - Super User

    Feb 24, 2015 · I have two PowerShell files. a.ps1 and b.ps1. At a center point in a.ps1 I want to start executing code in b.ps1 and terminate a.ps1 script. How to do it considering that both files are located i...

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

    To convert a single PowerShell script, simply run this: Get-ChildItem -Path <FILE-PATH> | Convert-PowerShellToBatch Where is the path to the desired file. The converted files are located in the source directory. i.e., <FILE-PATH> or <DIR-PATH>. Putting it all together: create a .ps1 file (PowerShell script) with the following code in it:

  7. how to run a powershell script as administrator - Super User

    A shortcut to script.ps1 works, as does a shortcut to powershell.exe -f script.ps1, but the latter can be set to run as administrator (see powershell.exe /? for the explanation of the -f or -File switch) –

  8. How do I run a PowerShell script when the computer starts?

    I finally got my PowerShell script to run automatically on every startup. You will need to create two files: the first is the Powershell script (e.g. script.ps1) and the second is a .cmd file that will contain commands that will run on the command prompt (e.g. startup.cmd).

  9. How to run Powershell script in DockerFile? - Stack Overflow

    Nov 6, 2017 · @shad - please accept this as the answer - it is the answer to the question you raised about how to run a powershell script from your docker file. It might not have solved your problem about running a service in a container, but that was not your question!

  10. How to pass command-line arguments to a PowerShell ps1 file

    Aug 18, 2009 · 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. i.e. powershell.exe -File "C:\myfile.ps1" arg1 arg2 arg3 means run the file myfile.ps1 and arg1 arg2 & arg3 are the parameters for the PowerShell script.

Refresh