Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 28. Creating and Running PowerSh... > Running PowerShell Scripts

Running PowerShell Scripts

Unlike normal command-prompt commands, PowerShell doesn’t look in the current path to run commands. In other words, you have to include one of two prefixes when running a PowerShell script from the PowerShell prompt (the full path, or the .\ combination). You can also run a script from the command prompt or from the Start Search text box. The following table shows the different methods of running a PowerShell script named test.ps1 located in the C:\scripts folder.

Script Execution MethodsDescription
Include the full path as a prefix
PS C:\>c:\scripts\test.ps1

You can run the script by including the full path as a prefix to the command. In this case, the full path is c:\scripts\.
Use the .\ prefix
PS C:\scripts>.\test.ps1

If the file is in the current path, you can use the full path or the .\ prefix.


There are no spaces between the dot, the backslash, or the script name.

Run from the command prompt
c:\>powershell c:\scripts\

You can run PowerShell scripts from the command prompt.


You can also access PowerShell interactively from the command prompt by just entering PowerShell. You will then have the PowerShell prompt, from which you can enter any PowerShell commands.

Run from the Start Search Programs and Files text box
powershell -noexit c:\

The -noexit switch leaves the command prompt open so that you can see the results of the script.


You are currently reading a PREVIEW of this book.


Get instant access to over $1 million worth of books and videos.


Start a Free Trial

  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint