30
Harold Wong Harold Wong Senior Technology Senior Technology Specialist Specialist Microsoft Corporation Microsoft Corporation 24 Hours of Exchange Server 24 Hours of Exchange Server 2007 (Part 09 of 24): Using 2007 (Part 09 of 24): Using PowerShell for Exchange PowerShell for Exchange Management Management

24 Hours Of Exchange Server 2007 ( Part 9 Of 24)

  • View
    2.748

  • Download
    2

Embed Size (px)

DESCRIPTION

Using PowerShell for Exchange Mangement

Citation preview

Page 1: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Harold WongHarold WongSenior Technology SpecialistSenior Technology SpecialistMicrosoft CorporationMicrosoft Corporation

24 Hours of Exchange Server 2007 24 Hours of Exchange Server 2007 (Part 09 of 24): Using PowerShell (Part 09 of 24): Using PowerShell for Exchange Managementfor Exchange Management

Page 2: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

What We Will CoverWhat We Will Cover

• Exchange Server Management modelExchange Server Management model

• Common management tasksCommon management tasks

• Scripting Exchange Server tasksScripting Exchange Server tasks

Page 3: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Level 200

Helpful ExperienceHelpful Experience

• Experience with Windows ServerExperience with Windows Server®® 2003 2003

• Experience with MicrosoftExperience with Microsoft®® Exchange Server Exchange Server

• Familiarity with scriptingFamiliarity with scripting

Page 4: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

AgendaAgenda

• ReviewReview

• Managing Exchange Server with Windows Managing Exchange Server with Windows PowerShell™PowerShell™

• Windows PowerShell ScriptingWindows PowerShell Scripting

Page 5: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Review: Introduction to Windows Review: Introduction to Windows PowerShellPowerShell

• New command line and scripting utilityNew command line and scripting utility

• Manage all aspects of Exchange ServerManage all aspects of Exchange Server

• Automate management tasksAutomate management tasks

Page 6: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Review: Introduction to Windows Review: Introduction to Windows PowerShellPowerShell

What is the purpose of the pipeline?What is the purpose of the pipeline?

1.1. Redirect output to text filesRedirect output to text files

2.2. Use the output of one command as the input for Use the output of one command as the input for anotheranother

3.3. Read input from the keyboardRead input from the keyboard

4.4. Temporarily pause the scriptTemporarily pause the script

Page 7: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Review: Introduction to Windows Review: Introduction to Windows PowerShellPowerShell

Which CMDLET retrieves information about Which CMDLET retrieves information about

a user’s Exchange Server mailbox?a user’s Exchange Server mailbox?

1.1. Get-MailboxGet-Mailbox

2.2. Read-MailboxRead-Mailbox

3.3. Get-UserGet-User

4.4. Get-MailuserGet-Mailuser

Page 8: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Review: Introduction to Windows Review: Introduction to Windows PowerShellPowerShell

Which CMDLET sorts rows of output from a Which CMDLET sorts rows of output from a

PowerShell command?PowerShell command?

1.1. Sort-ObjectsSort-Objects

2.2. Sort-ObjectSort-Object

3.3. Sort-BySort-By

4.4. Sort-RowSort-Row

Page 9: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Review: Introduction to Windows Review: Introduction to Windows PowerShellPowerShell

What is the default execution policy for the What is the default execution policy for the

Exchange Server Administration Shell?Exchange Server Administration Shell?

1.1. RestrictedRestricted

2.2. RemoteSignedRemoteSigned

3.3. UnrestrictedUnrestricted

4.4. AllSignedAllSigned

Page 10: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Review: Introduction to Windows Review: Introduction to Windows PowerShellPowerShell

What character indicates a user-defined What character indicates a user-defined

variable in Windows PowerShell?variable in Windows PowerShell?

1.1. $$

2.2. ##

3.3. @@

4.4. %%

Page 11: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Review: Introduction to Windows Review: Introduction to Windows PowerShellPowerShell

Which CMDLET changes the execution Which CMDLET changes the execution

policy in PowerShell?policy in PowerShell?

1.1. Get-ExecutionPolicyGet-ExecutionPolicy

2.2. Alter-ExecutionPolicyAlter-ExecutionPolicy

3.3. Set-ExecutionPolicySet-ExecutionPolicy

4.4. New-ExecutionPolicyNew-ExecutionPolicy

Page 12: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

AgendaAgenda

• ReviewReview

• Managing Exchange Server with Windows Managing Exchange Server with Windows PowerShellPowerShell

• Windows PowerShell ScriptingWindows PowerShell Scripting

Page 13: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Exchange Server Management Exchange Server Management ModelModel

Monad Engine

Exchange cmdlets

Configuration Data Access

Early-bound objs

Windows Forms

ADO.Net

Monad Data Provider

Windows Forms

CLI

Setup

MAPI Registry Active Directory® Metabase

Page 14: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Programmatic Bulk ChangesProgrammatic Bulk Changes

• Results of a task can be Results of a task can be used as a parameter to used as a parameter to another taskanother task

Get-user | enable-mailboxGet-user | enable-mailbox

• Looping can result in bulk Looping can result in bulk creation of objectscreation of objects

$users = get-user | $users = get-user | foreach ($user in $users)foreach ($user in $users)

{ Enable-mailbox –{ Enable-mailbox –database: “EXBE01\database: “EXBE01\

Mailbox Store”}Mailbox Store”}

Page 15: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

WhatifWhatif

get-mailbox |

where-object {$_.servername -eq “sea-exc-01"} |

move-mailbox –targetdatabase

“sea-exc-01\Mailbox Database" -whatif

Page 16: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Using Windows PowerShell to Manage Using Windows PowerShell to Manage MicrosoftMicrosoft®® Exchange Server 2007 Exchange Server 2007

Manage mailboxesManage mailboxes Manage distribution groupsManage distribution groups Manage public foldersManage public folders

demonstrationdemonstration

Page 17: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Managing Exchange Server with Managing Exchange Server with Windows PowerShellWindows PowerShell

Which command will create a new Which command will create a new

distribution group?distribution group?

1.1. Create-DistributionGroupCreate-DistributionGroup

2.2. Add-DistributionGroupAdd-DistributionGroup

3.3. New-DistributionGroupNew-DistributionGroup

4.4. New-ExDistributionGroupNew-ExDistributionGroup

Page 18: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Managing Exchange Server with Managing Exchange Server with Windows PowerShellWindows PowerShell

Which bulk operations can be performed inWhich bulk operations can be performed in

Windows PowerShell?Windows PowerShell?

1.1. Mail-enable mailboxesMail-enable mailboxes

2.2. Set mailbox quotasSet mailbox quotas

3.3. Get mailbox permissionsGet mailbox permissions

4.4. All of the aboveAll of the above

Page 19: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Managing Exchange Server with Managing Exchange Server with Windows PowerShellWindows PowerShell

How do you get information about a public How do you get information about a public

folder?folder?

1.1. Read-PublicFolderRead-PublicFolder

2.2. Get-FolderInfoGet-FolderInfo

3.3. Set-PublicFolderSet-PublicFolder

4.4. Get-PublicFolderGet-PublicFolder

Page 20: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

AgendaAgenda

• ReviewReview

• Managing Exchange Server with Windows Managing Exchange Server with Windows PowerShellPowerShell

• Windows PowerShell ScriptingWindows PowerShell Scripting

Page 21: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Formatting OutputFormatting Output

Sort ObjectsSort Objectssort-object name, aliassort-object name, alias

Format TableFormat Tableformat-table name, aliasformat-table name, alias

Format ListFormat Listformat-list name, aliasformat-list name, alias

Page 22: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Reporting in the ShellReporting in the Shell

• All managed objects in Exchange Server can be exported to .CSV file

• Task results can be viewed in multiple formats

• Robust test harness for service health, system health, rules

.CSV

Page 23: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Community ResourcesCommunity Resources

• Newsgroup: Microsoft.Public.Windows.PowerShell• Channel 9 tag:

– http://channel9.msdn.com/tags/Monad

• Team blog: – http://blogs.msdn.com/PowerShell/

• OMark van Orsouw’s blog: – http://mow001.blogspot.com

• Wiki:– http://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellWiki

• Script Center:– www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

• O’Reilly book – Monad: Introducing the MSH Command Shell and Language – www.oreilly.com/catalog/msh/

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

• Sapien Press book by Don Jones: PowerShell– www.sapienpress.com/

• MshAnalyzer tool– www.karlprosser.com/coder/?cat=8

Page 24: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Using Windows PowerShell Scripts to Manage Exchange Server

Use scripts for reporting logonsUse scripts for reporting logons Use scripts for mailbox reportingUse scripts for mailbox reporting Use scripts to create mailboxesUse scripts to create mailboxes

demonstrationdemonstration

Page 25: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Windows PowerShell ScriptingWindows PowerShell Scripting

Which Windows PowerShell command getsWhich Windows PowerShell command gets

keyboard input?keyboard input?

1.1. Read-HostRead-Host

2.2. Read-InputRead-Input

3.3. Get-InputGet-Input

4.4. Get-KeyboardGet-Keyboard

Page 26: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

PowerShell ScriptingPowerShell Scripting

To include a password as part of a script, To include a password as part of a script,

which data type must be used?which data type must be used?

1.1. StringString

2.2. Password Password

3.3. CryptedStringCryptedString

4.4. SecureStringSecureString

Page 27: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

PowerShell ScriptingPowerShell Scripting

Which of the following output formatsWhich of the following output formatscan Windows PowerShell produce?can Windows PowerShell produce?

1.1. HTMLHTML2.2. XMLXML3.3. CSVCSV4.4. All of the aboveAll of the above

Page 28: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Session SummarySession Summary

• Manage all aspects of Exchange ServerManage all aspects of Exchange Server

• Fast, reusable automationFast, reusable automation

• Flexible reportingFlexible reporting

Page 29: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)

Questions and AnswersQuestions and Answers

• Submit text questions using the “Ask” button. Submit text questions using the “Ask” button. • Don’t forget to fill out the survey.Don’t forget to fill out the survey.• For upcoming and previously live webcasts: For upcoming and previously live webcasts:

www.microsoft.com/webcastswww.microsoft.com/webcasts

• Got webcast content ideas? Contact us at: Got webcast content ideas? Contact us at: http://go.microsoft.com/fwlink/?LinkId=41781http://go.microsoft.com/fwlink/?LinkId=41781

• Today's webcast was presented using MicrosoftToday's webcast was presented using Microsoft®® Office Live Meeting. Get a free 14-day trial by Office Live Meeting. Get a free 14-day trial by visiting: visiting: www.microsoft.com/presentlivewww.microsoft.com/presentlive  

Page 30: 24  Hours Of  Exchange  Server 2007 ( Part 9 Of 24)