Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Running Your First Script | Getting Started with PowerShell
Introduction to PowerShell

Running Your First Script

Swipe um das Menü anzuzeigen

Note
Definition

A PowerShell script is a plain text file that contains one or more PowerShell commands or instructions. These scripts are typically saved with the .ps1 file extension and can be executed to automate tasks, manage systems, or perform repetitive operations.

Before you can take advantage of PowerShell's automation capabilities, it is important to understand how PowerShell scripts work and how to run them. By storing commands in a script file, you can save, reuse, and share your solutions instead of typing the same commands repeatedly.

# Simple PowerShell script that prints Hello World
Write-Output "Hello World"

This script demonstrates a basic PowerShell command stored in a script file. When you save the code as hello.ps1 and run it in PowerShell, it displays the message Hello World. To execute a script, open PowerShell, navigate to the directory containing the .ps1 file, and run:

./hello.ps1

Before running scripts, it is important to understand PowerShell's execution policies. An execution policy is a security setting that determines whether scripts are allowed to run on your system. By default, PowerShell may restrict script execution to help prevent the accidental or malicious execution of untrusted code.

Note
Note

If you receive an execution policy error when trying to run a script, you may need to modify the policy using the Set-ExecutionPolicy command. Always review the available policy options and understand the security implications before making changes.

1. Which of the following best describes a PowerShell script file?

2. What is the purpose of script execution policies in PowerShell?

question mark

Which of the following best describes a PowerShell script file?

Wählen Sie die richtige Antwort aus

question mark

What is the purpose of script execution policies in PowerShell?

Wählen Sie die richtige Antwort aus

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 1

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Abschnitt 1. Kapitel 1
some-alt