Creating your first script

To automate tasks, we need to create and run PowerShell scripts. To run a script, we need to follow these steps:

  1. Configure PowerShell to run scripts: Running a malicious script can harm the computer/server; the default setting for PowerShell is not to run them. We need to change the execution policy of the computer/server to be less restrictive. These steps need to be implemented once.
  2. Store the script: We need to store the script files with the .ps1 extension on the file system.
  3. Edit the script: Add the business logic using commands, cmdlets, variables, and so on.
  4. Run the script: Run the PowerShell script within the PowerShell Command Prompt or ISE.

Let's create our first PowerShell script. We will be creating ...

Get PowerShell for Office 365 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.