powershell for dummies

Post on 23-Feb-2016

51 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

PowerShell for Dummies. Kurt Callemin. WHO AM I ?. Kurt Callemin Final year student at KHBO: Master of Science Electronics- ICT Microsoft Student Partner since 2009 Developer Blog: http://www.ckurt.net Yelper: http://www.yelper.be/C_Kurt Twitter: C_Kurt. AGENDA. - PowerPoint PPT Presentation

TRANSCRIPT

PowerShell for DummiesKurt Callemin

WHO AM I ?

• Kurt Callemin• Final year student at KHBO: Master of Science Electronics- ICT• Microsoft Student Partner since 2009• Developer

• Blog: http://www.ckurt.net • Yelper: http://www.yelper.be/C_Kurt• Twitter: C_Kurt

2

AGENDA

• Introduction to PowerShell• Learn to investigate and explore PowerShell• Drill into utilities cmdlets

3

WINDOWS POWERSHELL

4

• New command line and scripting language

• Interactive and Composable• Programmatic• Production Oriented

PRODUCTIVITY

5

Exchange 2003 (VBScript) Exchange 2007

Mailbox Statistics

Set listExchange_Mailboxs = GetObject("winmgmts:{impersonationLevel=impersonate}!\\COMPUTERNAME\ROOT\MicrosoftExchangeV2").InstancesOf("Exchange_Mailbox")

For Each objExchange_Mailbox in listExchange_MailboxsWScript.echo "AssocContentCount =” + objExchange_Mailbox.AssocContentCountWScript.echo " DateDiscoveredAbsentInDS =” + objExchange_Mailbox.DateDiscoveredAbsentInDSWScript.echo " DeletedMessageSizeExtended =” + objExchange_Mailbox. DeletedMessageSizeExtendedWScript.echo " LastLoggedOnUserAccount =” + objExchange_Mailbox. LastLoggedOnUserAccountWScript.echo " LastLogoffTime =” + objExchange_Mailbox. LastLogoffTimeWScript.echo " LastLogonTime =” + objExchange_Mailbox. LastLogonTime WScript.echo " LegacyDN =” + objExchange_Mailbox. LegacyDNWScript.echo " MailboxDisplayName =” + objExchange_Mailbox. MailboxDisplayNameWScript.echo " MailboxGUID =” + objExchange_Mailbox. MailboxGUID WScript.echo " ServerName =” + objExchange_Mailbox. ServerName WScript.echo " Size =” + objExchange_Mailbox. SizeWScript.echo " StorageGroupName =” + objExchange_Mailbox. StorageGroupName WScript.echo " StorageLimitInfo =” + objExchange_Mailbox. StorageLimitInfo WScript.echo " StoreName =” + objExchange_Mailbox. StoreName WScript.echo " TotalItems =” + objExchange_Mailbox. TotalItems Next

get-mailboxstatistics –server $servername

Recipient Mgmt

Dim objMailbox As CDOEXM.IMailboxStore

Set objMailbox = GetObject("LDAP://" + DCServer + "CN=FOO,CN=users," + DomainName)

objMailbox.CreateMailbox "LDAP://" + DCServer + "/CN=Private MDB,CN=First Storage Group,CN=InformationStore,CN=" + Server + ",CN=Servers,CN=First Administrative Group, CN=Administrative Groups,CN=First Organization, CN=Microsoft Exchange,CN=Services, CN=Configuration," + DomainName

enable-mailbox -identity domain\FOO –database “First Storage Group\Private MDB”

DEMO 1Short Introduction

6

OBJECTS

PartsProperties

Front Wheel

Back Wheel

Pedals

Saddle

Frame

How to useMethods

Pedal

Steer Left

Steer Right

Apply Front Brake

Apply Rear Brake

Parts How to use

“An object is a collection of parts and how to use them”

7

OBJECTS

DisplayName

PartsProperties

Status

RequiredServices

Stop()

How to useMethods

Start()

Pause()

WindowsService

8

ARRAYS

• Data structure that holds other objects• Each object in its own compartment• Access compartments using []

$Processes = Get-Process

$Processes[0].name $Processes[4].name

ObjectObject Object Object Object

9

THE KIND OF OBJECTS

Get-Process | Where { $_.handles –gt 500 } | Sort handles | Format-Table

Get-ProcessCm

dlet

Common Windows PowerShell Parser

Windows PowerShell Pipeline ProcessorW

here Cmdlet

Sort Cm

dlet

Format

Cmdlet

10

DEMO 2Working with Objects

11

LEARN AND LEVERAGE

• In the box documents• PowerShell_ISE Help• Getting Started• User’s Guide• About Help• Cmdlet Help • Provider Help

• Discovery utilities• Books• Community• Practice ad hoc development

12

UTILITIES - DISCOVERY

Command Function

Get-Help Help about PowerShell commands and topics

Get-Command Get information about anything that can be invoked

Get-Member Show what can be done with an object

Get-PSDrive Shows what object stores are available

Get-Module Shows packages of commands

13

DEMO 3Discovery Utilities

14

Utilities – Object Manipulation

Command ActionCompare Compare 2 sets of objectsForeach Act on each element of a setGroup Split a set of objects into groupsMeasure Measure some property of a set of objectsSelect Select a set of properties from a set of objectsSort Sort objectsTee Make a copy of a set of objectsWhere Select a subset of objects

15

DEMO 4Object Manipulation Utilities

16

TRANSFORMATION and OUTPUTCommands Functions

Format -Custom -List -Table -Wide

Convert objects into formatting records

Out -File -GridView -Host -Printer -String

Convert formatting records into output-specific directives.

Export/Import -CliXML -CSV

Converts objects into and out of file formats

ConvertTo -CSV -HTML -XML

Converts object into other objects

17

DEMO 5Transformation and Output Utilities

18

Summary

• Now available at: www.microsoft.com/downloads• Search for PowerShell

• Try it, Deploy it, Use it, Share

• More Sessions: Scripting• http://www.msteched.com/2010/NorthAmerica/WSV401• http://www.msteched.com/2010/NorthAmerica/OSP402

19

POWERSHELL COMMUNITY

• Newsgroup: Microsoft.Public.Windows.PowerShell• Team blog: http://blogs.msdn.com/PowerShell/• PowerShellCommunity.Org: http://www.PowershellCommunity.Org• Channel 9 http://channel9.msdn.com/tags/PowerShell• Wiki

• http://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellWiki• Script Center: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx• CodePlex:

• http://codeplex.com/Project/ProjectDirectory.aspx?TagName=powershell• Many excellent books

• Manning Press book by PowerShell Dev Lead Bruce Payette: PowerShell in Action http://manning.com/powershell/

• O’Reilly book by PowerShell Dev Lee Holmes – Windows PowerShell Cookbook• http://www.oreilly.com/catalog/9780596528492/index.html

20

Thank you!Please fill out session evaluations

21

top related