About 284,000 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. 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 ...

  4. 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:

  5. 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.

  6. Set up PowerShell Script for Automatic Execution

    Aug 27, 2008 · Run Script Automatically From Another Script (e.g. Batch File) As Matt Hamilton suggested, simply create your PowerShell .ps1 script and call it using: PowerShell C:\Path\To\YourPowerShellScript.ps1 or if your batch file's working directory is the same directory that the PowerShell script is in, you can use a relative path:

  7. scripting - How to redirect the output of a PowerShell to a file …

    Jul 11, 2015 · I have a PowerShell script for which I would like to redirect the output to a file. The problem is that I cannot change the way this script is called. So I cannot do: .\\MyScript.ps1 &gt; output.t...

  8. dot source - In PowerShell, how do I define a function in a file and ...

    May 16, 2011 · In that folder, create a folder named MyFunctions, and place the MyFunctions.psm1 file into it (the module file must reside in a folder with exactly the same name as the PSM1 file). Once that is done, open PowerShell, and run this command: Get-Module …

  9. How do I execute a PowerShell script automatically using …

    May 30, 2014 · To further illustrate @user4317867's point, my powershell script to send an email would hang indefinitely in the running state when I set it to run as the domain admin. That is, domain\Administrator could not run the script, even if I left "run with the highest privileges" unchecked. However, my personal domain admin account could run the ...

  10. Run a PowerShell script from a cmd batch as admin

    Jan 17, 2022 · I have a PowerShell setup which I want to execute on a computer where perhaps the execution policy is restricted and requires admin rights. Ideally, I could wrap it in a cmd batch like follows: powershell -Command "Start-Process powershell -Verb runAs -ArgumentList '-noexit','-ExecutionPolicy','bypass','-File','C:\path\setup.ps1'"