As you automate your Windows operating system with PowerShell 2, it helps to know how to create scripts that you may be able to loop and use more than once. The steps to create a script follow:
Create the script in a plain text editor such as Notepad and save with a .PS1 file extension (for example, myscript.ps1).
Run the script by entering the full path to the script (c:\scripts\myscript.ps1), or if it’s in the current directory, prefix it with a period followed by a backslash (.\myscript.ps1).
If the path to the script contains a space, enclose the full path in quotation marks and prefix the entire thing with an ampersand (for example: &"C:\my scripts\myscript.ps1").
Unless you’re running a signed script, make sure you to set the correct execution policy using Set-ExecutionPolicy. To allow local scripts to run unsigned, run:
Set-ExecutionPolicy RemoteSigned
dummies
Source:http://www.dummies.com/how-to/content/how-to-create-and-run-a-powershell-script.html
No comments:
Post a Comment