Script

suggest change

A script is a text file with the file extension .ps1 that contains PowerShell commands that will be executed when the script is called. Because scripts are saved files, they are easy to transfer between computers.

Scripts are often written to solve a specific problem, ex.:

Demo

MyFirstScript.ps1:

Write-Host "Hello World!"
2+2

You can run a script by entering the path to the file using an:

Usage:

> .\MyFirstScript.ps1
Hello World!
4

A script can also import modules, define it’s own functions etc.

MySecondScript.ps1:

function HelloWorld {
    Write-Host "Greetings from PowerShell!"
}

HelloWorld
Write-Host "Let's get started!"
2+2
HelloWorld

Usage:

> .\MySecondScript.ps1
Greetings from PowerShell!
Let's get started!
4
Greetings from PowerShell!

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Modules scripts and functions:
* Script
* Module

Table Of Contents
1 Loops
19 XML
22 Strings
25 Aliases
37 Modules scripts and functions
47 MongoDB
65 AWS S3