windows powershell basics for it professionals

13
Windows PowerShell Basics for IT Professionals Peter Lammers Lead Developer Aeshen Microsoft Confidential 1

Upload: others

Post on 03-Feb-2022

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Windows PowerShell Basics for IT Professionals

Windows PowerShell Basics for IT

Professionals

Peter Lammers

Lead Developer

Aeshen

Microsoft Confidential 1

Page 2: Windows PowerShell Basics for IT Professionals

What Is PowerShell?

Microsoft Confidential 2

Windows PowerShell™ includes an interactive prompt and a scripting environment

Commands are object-based

Large set of built-in commands

All shell commands use the same parser

Windows PowerShell 2.0 is installed by default on Windows Server® 2008 R2 and Windows® 7

Page 3: Windows PowerShell Basics for IT Professionals

PowerShell Syntax

Microsoft Confidential 3

Name Alias Server StorageQuota

---- ---- ------ ------------

Bob Kelly bobk smbex01 unlimited

Kim Akers kima smbex01 unlimited

PS> get-mailbox –server “smbex01”

Verb NounName

ArgumentString

Command Parameter

Property Names

Property Values

Page 4: Windows PowerShell Basics for IT Professionals

Demonstration: Getting Started with PowerShell

Microsoft Confidential 4

• PowerShell basics

• Getting help

• Windows PowerShell snap-in

• Getting cmdlet information

Page 5: Windows PowerShell Basics for IT Professionals

Piping and the Pipeline

Microsoft Confidential 5

Scenario 1Get-Service| Where-Object {$_.Status –eq “Running”}| Sort-Object Name

Cmdlet Filter Sort

Scenario 2Get-item –path HKLM:\Software\MyCompany | new-Itemproperty –name NoOfEmployees –value 8124

Page 6: Windows PowerShell Basics for IT Professionals

Demonstration: Piping, Outputting, and Formatting

Microsoft Confidential 6

• Piping and the pipeline

• Output and formatting

Page 7: Windows PowerShell Basics for IT Professionals

Data Types

Microsoft Confidential 7

Shortcut Data Type

[datetime] Date or time

[string] String of characters

[char] Single character

[double] Double-precision floating number

[single] Single-precision floating number

[int] 32-bit integer

[wmi] Windows® Management Instrumentation (WMI) instance or collection

[adsi] Active Directory® Services object

[wmiclass] WMI class

[Boolean] True or false value

Page 8: Windows PowerShell Basics for IT Professionals

Demonstration: Variables and Types

Microsoft Confidential 8

• Creating variables

• Using types

• Creating arrays

Page 9: Windows PowerShell Basics for IT Professionals

PowerShell Scripts have the .ps1 extension

PowerShell Scripts

Microsoft Confidential 9

Sample Script# This script will get files and folder stored in# C:\Scripts.$a = Get-ChildItem C:\Scripts$a

Run a ScriptC:\Scripts\MyScript.ps1& “C:\My Scripts\Test.ps1”

Page 10: Windows PowerShell Basics for IT Professionals

Demonstration: Working with Scripts

Microsoft Confidential 10

• Creating PowerShell scripts

• Running scripts

Page 11: Windows PowerShell Basics for IT Professionals

Demonstration: Automating Administrative Tasks

Microsoft Confidential 11

• Work with the Event Log

Page 12: Windows PowerShell Basics for IT Professionals

Questions and Answers

• Submit text questions using the “Ask” button

• Don’t forget to fill out the survey

• For upcoming and previously live webcasts:

www.microsoft.com/webcast

• Got webcast content ideas? Contact us at:

http://go.microsoft.com/fwlink/?LinkId=41781

Page 13: Windows PowerShell Basics for IT Professionals

© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market

conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.

MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.13