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

Running Your First Script

Deslize para mostrar o menu

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?

Selecione a resposta correta

question mark

What is the purpose of script execution policies in PowerShell?

Selecione a resposta correta

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 1

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Seção 1. Capítulo 1
some-alt