Datasheet

UNDERSTAND THE BASICS OF POWERSHELL 35
Administering
Service Delivery
PART I
Run a Script Outside of PowerShell
When you write a
.ps1
script, you can run that script anytime you’re in a
PowerShell session. But you can also run scripts without opening PowerShell manu-
ally. e process is similar to running a batch  le outside of the command prompt.
You can double-click the script, and PowerShell will be automatically opened, your
script will run, and then PowerShell will close.
By default, when you double-click a PowerShell
.ps1
script le, the  le opens in
Notepad. You can use the following procedures to launch the  le in PowerShell:
1. Browse to the PowerShell
.ps1
script le that you want to launch.
2. Right-click the  le, and select Run With PowerShell from the drop-down
menu as shown in Figure 1.11.
FIGURE 1.11 Launching a PowerShell script outside of PowerShell
e PowerShell script will launch and run in PowerShell. PowerShell will be closed
when the script completes.
You can also change the  le association to PowerShell instead of Notepad.  is will
ensure that when you double-click the script, it opens in PowerShell automatically.
c01.indd 35c01.indd 35 5/12/2011 1:07:52 PM5/12/2011 1:07:52 PM