To automate tasks, we need to create and run PowerShell scripts. To run a script, we need to follow these steps:
- 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.
- Store the script: We need to store the script files with the .ps1 extension on the file system.
- Edit the script: Add the business logic using commands, cmdlets, variables, and so on.
- 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 ...