Scripting Exchange: The Exchange Management Shell Jim McBee

Slides:



Advertisements
Similar presentations
Microsoft ® Exchange Online Migration and Coexistence Name Title Microsoft Corporation.
Advertisements

Jason Himmelstein, MVP Senior Technical Director,
James Boother Blog: INTRODUCTION TO POWERSHELL.
James Boother Blog: AUTOMATING ADMIN TASKS WITH POWERSHELL.
INTRODUCTION TO POWERSHELL Neil Iversen. Points of Interest  Introduction  Getting Around  Basic Syntax  Making yourself at ~  Not-So-Basic Syntax.
Daniel Petri MVP, Microsoft Infrastructure Manager John Bryce Training November 2007.
Installing Windows XP Professional Using Attended Installation Slide 1 of 41Session 2 Ver. 1.0 CompTIA A+ Certification: A Comprehensive Approach for all.
Introduction to UTORexchange For IT support providers.
Compliance Archiving. ExchangeDefender Compliance Archive provides secure, long term storage, recovery and eDiscovery system that assures compliance with.
Adding a Module The Import-Module cmdlet  Can be used to load any external module into PowerShell.  Uses the following syntax to add the ActiveDirectory.
Exchange Pre-Deployment Analyzer - ExPDA 8ead-7479dab1abf2&displaylang=en.
Hosted Exchange The purpose of this Startup Guide is to familiarize you with ExchangeDefender's Exchange and SharePoint Hosting. ExchangeDefender.
Module 2 Creating Active Directory ® Domain Services User and Computer Objects.
Introduction to UNIX/Linux Exercises Dan Stanzione.
Presenters: Winfred Wangeci Jignash Reddy.  It is Microsoft's new task-based command- line shell and scripting language designed especially for system.
Module 2 Configuring Mailbox Servers. Module Overview Overview of Exchange Server 2010 Administrative Tools Configuring Mailbox Server Roles Configuring.
MS WINDOWS POWER SHELL CSE 535 Operating Systems.
Topic Of This Hour Exchange 2013: Database Availability Group Exchange 2013: Modern Public Folders Dec 18, 2013 Timing for the different Geography: 5:00.
Session Session 26 SAIG (Title IV WAN) Connectivity.
MIGRATING FROM MICROSOFT EXCHANGE SERVER AND OTHER MAIL SYSTEMS Appendix B.
XP New Perspectives on Browser and Basics Tutorial 1 1 Browser and Basics Tutorial 1.
CIM6400 CTNW (04/05) 1 CIM6400 CTNW Lesson 6 – More on Windows 2000.
Microsoft ® Official Course Module XA Using Windows PowerShell ®
PowerShell Basics. o PowerShell is a great way to manipulate server and/or workstation components o It’s geared toward system administrators by creating.
Appendix A Starting Out with Windows PowerShell™ 2.0.
Section 1: Introducing Group Policy What Is Group Policy? Group Policy Scenarios New Group Policy Features Introduced with Windows Server 2008 and Windows.
Computer Programming for Biologists Oct 30 th – Dec 11 th, 2014 Karsten Hokamp  Fill out.
Shell Scripting Introduction. Agenda What is Shell Scripting? Why use Shell Scripting? Writing and Running a Shell Script Basic Commands -ECHO - REM.
The In’s and Out’s of the IIS 6.0 Migration Tool The In’s and Out’s of the IIS 6.0 Migration Tool Chris Adams Web Platform Supportability Lead Microsoft.
Microsoft Exchange 2000 Service Pack 2 Features Mark Barringer Support Professional Enterprise Messaging Support Microsoft Corporation.
Section 6: Using Windows PowerShell to Manage Group Policy Introducing Windows PowerShell Windows PowerShell Library for Group Policy Windows PowerShell-Based.
December, 21, 2010 Bartek Bielawski Sr IT Site Services Specialist Warsaw, Poland.
Mail Attender for Exchange Technical Overview Presentation Introduction Sherpa Software Group Narrated by Thomas Hand Approximate Time 15 minutes.
Good Morning and Thank You!.  Have some Fun!  Learn at least one thing new!  Make myself available to you So please …  Ask questions and enjoy!
Reinsel Kuntz Lesher, LLP.  Outline Overview  netstat -an (-ano will give the PID)  ftp  bin  mget  mput  telnet  telnet bobm.us 25  helo  mail.
Module 4 : Installation Jong S. Bok
0 SharePoint Search 2013 Rafael de la Cruz SharePoint Developer Seneca Resources twitter.com/delacruz_rafael
Module 3 Configuring File Access and Printers on Windows 7 Clients.
Module 2 Creating Active Directory ® Domain Services User and Computer Objects.
EX02: Exchange 2007 Management Jim McBee
Online Conference June 17 th and 18 th SharePoint Online Administration with PowerShell.
MCSE Guide to Microsoft Exchange Server 2003 Administration Chapter Five Managing Addresses.
Module 3: Configuring Mailbox Server Roles. Overview Overview of Exchange Server 2007 Administration Tools Implementing Mailbox Server Roles Managing.
Module 2 Configuring Mailbox Servers. Module Overview Overview of Exchange Server 2010 Administrative Tools Configuring Mailbox Server Roles Configuring.
Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some.
Windows PowerShell Introduction 1 Morgan Simonsen Ementor.
MSG331 Exchange Server 2000/2003 Software Development Kit Susan Hill Lead Programmer Writer Microsoft Corporation.
CIS 1402: Intro to CIS Tom Gustafson. Facts About PowerShell PowerShell is Microsoft’s command-line interface that provides scripting and management capability.
POWERSHELL BASICS. BACKGROUND  Powershell is a task automation and scripting language based off the.NET framework  It provides the user full access.
 It is Microsoft's new task-based command- line shell and scripting language designed especially for system administration.  It helps Information Technology.
Windows PowerShell. What is Windows PowerShell? A command-line interface (CLI) A new way of developing Windows and other products to be more manageable.
MCSE Guide to Microsoft Exchange Server 2003 Administration Chapter Three Managing Recipients.
© 2015 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner.
MCSE Guide to Microsoft Exchange Server 2003 Administration Chapter One Introduction to Exchange Server 2003.
Automating SharePoint 2010 administration tasks with Power Shell Toni Frankola SharePoint MVP, Croatia
Get-Intro –Name PowerShell Jason Helmick Systems Instructor Interface Technical Training.
Module 14: Advanced Topics and Troubleshooting. Microsoft ® Windows ® Small Business Server (SBS) 2008 Management Console (Advanced Mode) Managing Windows.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Blog PowerShell for Managing Active.
Introduction to SQL Server  Working with MS SQL Server and SQL Server Management Studio.
Active-HDL Server Farm Course 11. All materials updated on: September 30, 2004 Outline 1.Introduction 2.Advantages 3.Requirements 4.Installation 5.Architecture.
PowerShell 5 & Windows 10. What are we covering today? What is PowerShell? Why is PowerShell important? Some simple demos on Windows 10.
Start-SPPowerShell – Introduction to PowerShell for SharePoint Admins and Developers Paul BAker.
The top ten PowerShell commands for Exchange
Fun with Reporting Services Tools
Introduction to PowerShell
SharePoint Saturday Omaha April 2016
PowerShell Best Practices for SQL DBA’s
Outlook Basics.
Cmdlets “Command-lets”
Presentation transcript:

Scripting Exchange: The Exchange Management Shell Jim McBee

Who is Jim McBee!!?? Consultant, Writer, MCSE, MVP and MCT – Honolulu, Hawaii Principal clients (Dell, Microsoft, SAIC, Servco Pacific) Author – Exchange 2003 Advanced Administration (Sybex) Contributor – Exchange and Outlook Administrator Blog – –

Introduction PowerShell 101 PowerShell and Exchange 2003 PowerShell and Exchange 2007 Faceoff: PowerShell vs Old-School Scripting Cool PowerShell One-Liners

PowerShell 101 Flexible, object-oriented command shell Supplements other scripting methods –CMD.exe –VBScript –WMI –CDO / CDOEX / CDOEXM –Extensions can be accessed via.NET classes Can be used for one-off commands or to write scripts and applications

PowerShell 101: Why? Why is Microsoft doing this? –Composition and pipelining –Richer functionality –Make the command line better than UNIX –Provide secure remote scripting –Provide better batching (one-to-many) –Automate and repeat anything you can do through the GUI

PowerShell 101: Vocabulary Cmdlet: –Base PowerShell object that takes input, does something to it, and produces output –Base set of cmdlets provided with PowerShell –Exchange 2007 adds its own Exchange-specific cmdlet set –You can write your own!

PowerShell 101: Vocabulary Cmdlets follow a standard verb-object naming structure –Get-XXX fetches an object or its properties –New-XXX creates something –Set-XXX sets a property on an object –Format-XXX displays object properties in a given format 120+ built-in cmdlets in default PowerShell install Exchange adds its own rich set of Exchange-specific cmdlets

Demo: Introduction to the PowerShell Verb-Noun combinations –Verbs: Get, Set, New, Delete, Mount, Disable –Nouns: User, Mailbox, MailboxServer, TransportServer, Database, Contact, DistributionGroup, ActiveSyncPolicy Not case sensitive Tab completion –Complete cmdlets and parameters Getting help –Help *mailbox*, Help *mailbox –Get-Mailbox -? –Get-Help Get-Mailbox –Full –Get-Help Get-Mailbox –Example We can view the properties used by a cmdlet –Get-Mailbox | Get-Member –MemberType Properties –Get-Mailbox “Lee Adama” | Format-List Output –Outputs to the screen “text” –Output to the shell is objects

PowerShell + Exchange 2003 If you’re running Exchange 2003, you can still use PowerShell –Install.NET Framework 2.0 –Install PowerShell beta 3 or later What can you do with it? Plenty! –Service management and control –WMI monitoring –WMI property setting

PowerShell in Exchange 2007 PowerShell is the core of Exchange Management Console –All EMC actions really call PowerShell cmdlets –All those cmdlets are available from the command line Don’t let the cmdlet idea fool you –Some Exchange cmdlets are extremely rich, e.g. move- mailbox –Many cmdlets compress big functionality into one line

Faceoff There are lots of things that you can do with Exchange WMI/CDOEXM Let's look at a few examples and their PowerShell equivalents

Mailbox-Enabling a User ' get the default and config NC names Set oIADS = GetObject("LDAP://RootDSE") strDefaultNC = oIADS.Get("defaultnamingcontext") strConfigNC = oIADS.Get("configurationNamingContext") strContainer= "/CN=Users," & strDefaultNC Set objContainer = GetObject("LDAP://" & strDCName & strContainer) ' find the target user and connect to it Set oIADSUser = GetObject("LDAP://Joe User,CN=Users," & strDefaultNC) Set oMailBox = oIADSUser Set oConnection = CreateObject("ADODB.Connection") set oCommand = CreateObject("ADODB.Command") Set oRecordSet = CreateObject("ADODB.Recordset") oConnection.Provider = "ADsDSOObject" oConnection.Open "ADs Provider"

Mailbox-Enabling a User ' Build the query to find the private MDBs. Use the first one if any are found. strQuery = "<LDAP://" & strConfigNC & _ ">;(objectCategory=msExchPrivateMDB);name,adspath;subtree" oCommand.ActiveConnection = oConnection oCommand.CommandText = strQuery Set oRecordSet = oCommand.Execute If Not oRecordSet.EOF Then oRecordSet.MoveFirst firstMDB = CStr(oRecordSet.Fields("ADsPath").Value) Else firstMDB = "" End If ' create the mailbox oMailbox.Creat box firstMDB oIADSUser.SetInfo

EMS: Mailbox-Enabling a User Enabl box "domain\JoeUser" "BATMAN\First Storage Group\UserMDB01" Note that you could also do this on many users at once, e.g. Get-DistributionGroupMember "New Hires" | Enabl box "BATMAN\First Storage Group\UserMDB01"

Turning on OWA Attachment Blocking ' SCRIPT CONFIGURATION strOWA = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\" strOwa = strOWA & "MSExchangeWeb\OWA\" strBlockList = "pst, tmp, pl, exe, cmd, pif, bat, msh" ' END CONFIGURATION Set objWSH = wscript.CreateObject("WScript.Shell") objWSH.RegWrite strOWA, "Level1FileTypes","REG_SZ", strBlockList Run this on *each* Exchange 2003 server

EMS: Turning on OWA Attachment Blocking Get-OWAVirtualDirectory | Set-OWAVirtualDirectory - BlockedFileTypes ".PST" Note that this sets the parameter on all the OWA instances in your organization, at once, with no extra steps!

Cool EMS One-Liners Get the number of user mailboxes for each database –Get-MailboxStatistics | Group MailboxDatabase | Format-Table count,name

Cool EMS One-Liners Which mailboxes are in a given database? –Get-Mailbox | Group Database | Format-List –Lists each MDB and shows you which users are in each database

Stop and Think It should be clear what get-service does Take a look at this demo…

Cool EMS One-Liners Mass-set properties on all members of a group –Get-DistributionGroupMember "Executives" | Set-Mailbox - SendStorageQuota

Cool EMS One-Liners Find all files created on a certain day and move them –dir *.eml | where {$_.LastWriteTime – like “04/02 *”} | move-item – destination c:\oldSpam You can just as easily remove them, rename them, or do other things

Cool EMS One-Liners Mailbox-enable every user in an OU –Get-User -OrganizationalUnit “gotham.ci.us/PublicSafety" | Where {$_.RecipientType -eq "user"}| Enabl box -database “BATMAN\Gotham\Gotham PD"

Cool EMS One-Liners Retry any message queue that has more than 50 pending messages –get-queue | where-object { $_.MessageCount -gt 50} | retry-queue

More One-Liners Output (output) of some cmdlets can be piped to another cmdlet to be used as input This allows the creation of “one-liners” –Get-MailboxStatistics | where {$_.DatabaseName –eq “Mailbox Database”} | Format-Table DisplayName, ItemCount, TotalItemSize,StorageLimitStatus –Get-Mailbox “Lee.Adama” | Set-Mailbox –ProhibitSendQuota:75000KB –Get-DistributionGroupMember “Raptor Pilots” | Mov box – TargetDatabase “Raptor Pilots” –Get-DistributionGroupMember “Raptor Pilots” | Set-Mailbox – IssueWarningQuota:100MB –ProhibitSendQuota:125MB – ProhibitSendReceiveQuota:150MB –UseDatabaseQuotaDefaults:$False

Demo: Creating Users and Mailboxes Creating a text file Name,Database,OrganizationalUnit,UserPrincipalName Saul Tigh,Mailbox Sharon Agathon,Mailbox Tom Zarek,Mailbox Laura Roslin,Mailbox Samuel Anders,Mailbox Script to read this text file and create users $Users = Import-Csv C:\Demo\newaccounts.txt $Users $Password = Read-Host “Please enter a password for the users” –AsSecureString Foreach ($User in $Users) { New-Mailbox -Name $User.Name -Database $User.Database -OrganizationalUnit $User.OrganizationalUnit -UserPrincipalName $User.UserPrincipalName -Password $Password }

EMS Cmdlet: What It Does get-mailbox -server CT-EXCH-MBX-01 | ` mov box ` –targetdatabase SG1\Executives Get all mailboxes on the mailbox server named CT-EXCH- MBX-01 and pipe this list to the next command: get-mailbox -server CT-EXCH-MBX-01| Move each mailbox in this list to the Executives database in the SG1 storage group: mov box –targetdatabase SG1\Executives

More EMS Examples Get-Mailbox -server CT-EXCH-MBX-01| ` Mov box -targetdatabase SG1\Executives Get-DistributionGroupMember “Engineering” Get-DistributionGroupMember “Engineering" | ` Get-Mailbox -IssueWarningQuota:1500MB Get-DistributionGroupMember “Engineering" | ` Get-Mailbox | Format-Table name,issuewarningquota

SP1 Management Improvements Service Pack 1 includes some major EMC improvements –Public folder management tools –POP / IMAP server management tools –Clustered mailbox server management There are EMS improvements as well –Import and export mailboxes to PST! –Improved tools for bulk mailbox manipulation –Some syntax improvements

PowerShell Tricks to Know Get-command -synopsis will give you all flags for the specified cmdlet –Get-command -name get-service -synopsis Get-excommand can be used to search for Exchange-specific commands –Get-ExCommand *ailbox* | where {$.Name -eq “Cmdlet”} tells you what command exist –Follow up by piping the cmdlet name to get-member Get-MailboxServer | Get-Member -MemberType property to get a list of properties

For more information Exchange Ninjas – Visit the Exchange 2007 home page – Exchange Team blog – Exchange 2007 Documentation –

Where to Learn More Exchange 2007 online help: canonical source for what Exchange cmdlets do PowerShell team blog – Vivek Sharma's blog – Exchange Ninjas –

Where to Learn More PowerShell (Oakley; O'Reilly Media; ISBN ) –Quick, light intro; no Exchange content Windows PowerShell in Action (Payette; Manning Publications; ISBN ) –Written by the lead designer of PowerShell PowerShell: TFM (Jones & Hicks; SAPIEN Press; ) –Written by Windows scripting gurus Don Jones & Jeffrey Hicks

Questions? Thanks for attending!

Book giveaway and notice Please give me a piece of paper with your name for drawing Include your address or give me a business card if you want: –20% discount code for Directory Update software –Notification when Mastering Exchange Server 2007 is available Keep an eye out for Mastering Exchange Server 2007 – Due out in late April