5/13/2009. Dejan Foro dejan.foro@exchangemaster.net. Speaker

Similar documents
PowerShell for Exchange Admins

POWERSHELL (& SHAREPOINT) This ain t your momma s command line!

SUNGARD SUMMIT 2007 sungardsummit.com 1. Microsoft PowerShell. Presented by: Jeff Modzel. March 22, 2007 Course ID 453. A Community of Learning

Dejan Foro

Presented by: Robert Crane BE MBA MVP

ActiveRoles Management Shell for Active Directory

Windows PowerShell Fundamentals

Microsoft. Jump Start. M3: Managing Windows Server 2012 by Using Windows PowerShell 3.0


You Should Be Using PowerShell Aaron Kaiser Senior Technology Support Specialist Parkway School District

WHITE PAPER BT Sync, the alternative for DirSync during Migrations

WolfTech Active Directory: PowerShell

Release Note RM Unify CSV Extraction Tool

Avatier Identity Management Suite

AD SYNCHRONIZATION GUIDE

Create user mailboxes

Lab Answer Key for Module 1: Installing and Configuring Windows Server Table of Contents Lab 1: Configuring Windows Server

PowerShell for Dummies

Dejan Foro

ECAT SWE Exchange Customer Administration Tool Web Interface User Guide Version 6.7

Departmental IT Staff (CatNet OU Admin) Guide to Exchange 2010

Step-by-Step Guide to Active Directory Bulk Import and Export

Administrator s Guide

WHITE PAPER POWERSHELL FOR DUMMIES HOW TO KEEP TRACK OF

Using Management Shell Reports and Tracking User Access in the NetVanta UC Server

AddLocalUser AddLocalGroup AddLocalUserToLocalGroup AddDomainUserToLocalGroup AddDomainGroupToLocalGroup

Z-Term V4 Administration Guide

LAB 1: Installing Active Directory Federation Services

Step-by-step installation guide for monitoring untrusted servers using Operations Manager ( Part 3 of 3)

Windows PowerShell. 3.0 Step by Step. Ed Wilson

Click Studios. Passwordstate. Password Discovery, Reset and Validation. Requirements

Vtiger CRM Outlook Plugin Documentation

SystemTools Software Inc. White Paper Series Hyena Installation Requirements

TECHNICAL NOTE. The following information is provided as a service to our users, customers, and distributors.

How to move a SharePoint Server bit environment to a 64-bit environment on Windows Server 2008.

Administrator s Guide

Windows Server 2008 R2: What's New in Active Directory

Installing and Configuring Login PI

There are only a couple of things that need to happen once you've ordered the product from our Service Manager.

ScriptLogic File System Auditor User Guide

Access It! Universal Web Client Integration

EventTracker: Support to Non English Systems

INSTALLATION GUIDE Version 1.2

Quick Introduction System Requirements Main features Getting Started Connecting to Active Directory... 4

Z-Hire V4 Administration Guide

FrontDesk. (Server Software Installation) Ver

Bitrix Site Manager ASP.NET. Installation Guide

GALSYNC V7.0. Manual. NETsec. NETsec GmbH & Co.KG Schillingsstrasse 117 DE Düren. 01. June 2016

Cisco TelePresence Management Suite Extension for Microsoft Exchange

Mail Attender Version

Web Mail Classic Web Mail

NAS 253 Introduction to Backup Plan

Exchange Mailbox Protection Whitepaper

Managing Recipients in Exchange 2007

Installation Manual UC for Business Unified Messaging for Exchange 2010

Enable Federated Agents in Chime for Lync

SystemTools Software Inc. Hyena Installation Guide

Pcounter Web Report 3.x Installation Guide - v Pcounter Web Report Installation Guide Version 3.4

Cyclope Internet Filtering Proxy

Jeffrey Snover Distinguished Engineer & Lead Architect Jason Helmick Senior Technologist, Concentrated Technology

SPHOL205: Introduction to Backup & Restore in SharePoint Hands-On Lab. Lab Manual

ActiveRoles Management Shell for Active Directory

NetWrix USB Blocker. Version 3.6 Administrator Guide

How To Install An Archive Service On An Exchange Server (For A Free) With A Free Version Of Ios (For Free) On A Windows Xp Or Windows 7 (For Windows) (For An Ubuntu) (

Forefront Management Shell PowerShell Management of Forefront Server Products

MSSQL quick start guide

Windows Server 2008 R2: Server Management and PowerShell V2

Dell One Identity Manager 7.0. Administration Guide for Connecting to Microsoft Exchange

Specops Command. Installation Guide

User Management Tool 1.6

Step-by-Step Guide to Bulk Import and Export to Active Directory


How to monitor AD security with MOM


Note: With v3.2, the DocuSign Fetch application was renamed DocuSign Retrieve.

Exchange 2007 Role Build-In protection ( Overview) Anywhere Access Unified Messaging Console Powershell for Exchange Outlook 2007 and Exchange 2007 :

Manual POLICY PATROL SIGNATURES FOR OUTLOOK, GOOGLE APPS & OFFICE 365

XEROX, The Document Company, the stylized X, and the identifying product names and numbers herein are trademarks of XEROX CORPORATION.

Legal Notes. Regarding Trademarks KYOCERA Document Solutions Inc.

Windows PowerShell Cookbook

Managing an Active Directory Infrastructure O BJECTIVES

Pronestor Room & Catering

Module 4: Implementing User, Group, and Computer Accounts

CONFIGURING MICROSOFT SQL SERVER REPORTING SERVICES

Microsoft IT Camp Hands-On Lab

Magento Extension Point of Sales User Manual Version 1.0

HELP DOCUMENTATION UMRA USER GUIDE

TROUBLESHOOTING GUIDE

Downloading and Installing Core FTP

How to Configure a Stress Test Project for Microsoft Office SharePoint Server 2007 using Visual Studio Team Suite 2008.

PowerSearch for MS CRM 2011

Item Audit Log 2.0 User Guide

Powershell Management for Defender

How To Install Outlook Addin On A 32 Bit Computer

LT Auditor Windows Assessment SP1 Installation & Configuration Guide

Installing Microsoft Outlook on a Macintosh. This document explains how to download, install and configure Microsoft Outlook on a Macintosh.

vtcommander Installing and Starting vtcommander

Advanced Event Viewer Manual

Outlook Anywhere Local Client Setup Instructions

How To Install Ctera Agent On A Pc Or Macbook With Acedo (Windows) On A Macbook Or Macintosh (Windows Xp) On An Ubuntu (Windows 7) On Pc Or Ipad

Transcription:

Dejan Foro dejan.foro@exchangemaster.net Speaker 16years of years of experience with MS technologies 11years and 5generations of experience with Exchange (5.5, 2000, 2003, 2007, 2010) MCP, MCP+I, MCSE NT40, MCSE+I, MCSE 2000, MCSE 2000:Messaging, MCSA 2003, MCSA 2003:Messaging, MCSE 2003, MCSE 2003:Messaging, MCT 1

Speaker Communities Exchange User Group Europe (founder) Swiss IT Pro UserGroup Rewards MCP Hall of Fame (1 of 6 worldwide) Microsoft MVP - Exchange (1 of 120 worldwide, the only 1 in Switzerland) MCP Success Stories Agenda Introduction Doing common tasks in Exchange Users related tasks Testing and troubleshooting Setting up your own PowerShell enviroment Additional resources 3rd party tools, web sites, communities, books, webcasts... Q&A 2

Presentation dowlnoad This presentation will be available for download from: www.exchangemaster.net Introduction How it used to be... Problemsof Scripting in Windows enviroment Manythingscould be done through command line VBScript programming knowledge required, knowledge of VB, WMI, WBEM, ADSI, object models security voulnearable 3

Introduction How it is today... Scriptingwith PowerShell in Exchange Command line interface developed first, than GUI EVERYTHING can be done via command line Exchange managment GUI actually executes PowerShell commands and shows you the syntax Single line commands replace pages of VB code Symple syntax Better security exectution of powershell scripts completely disabled by default, require scripts to be signed, etc. Example 4

Introduction Windows Powershell - 129 commands Get-Command Exchange Powershell additional 394 commands Get-Excommand Don t worry, you will be cool with approx. 20 Why are you going to love PowerShell Task example : Get a list of mailboxes and export into.csv file 5

Why you are going to love PowerShell VBScript Dim SWBemlocator Dim objwmiservice Dim colitems Dim objfso Dim objfile strtitle="mailbox Report" strcomputer = MyServer" UserName= "" Password = "" strlog="report.csv" Set objfso=createobject("scripting.filesystemobject") Set objfile=objfso.createtextfile(strlog,true) strquery="select * from Exchange_Mailbox" Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator") Set objwmiservice= SWBemlocator.ConnectServer(strComputer,"\root\MicrosoftExchangeV2",UserName,Password) Set colitems = objwmiservice.execquery(strquery,,48) For Each objitem In colitems objfile.writelineobjitem.servername& "," &objitem.storagegroupname&_ "," & objitem.storename& "," & Chr(34) & objitem.mailboxdisplayname Next objfile.close Why you are going to love PowerShell PowerShell Get-mailbox export-csv c:\report.csv 6

... And Action!!! Command Syntax New-Mailbox Get-Mailbox Set-Mailbox Move-Mailbox Remove-Mailbox... 7

Getting help List of all available PowerShell commands Get-Command List of onlyexchange commands Get-Excommand Getting help about specific command Get-Help Get-Mailbox Get-Help Get-Mailbox detailed Get-Help Get-Mailbox full Getting info about users/mailboxes List of all mailboxes in organisation Get-Mailbox Get-Mailbox -ResultSize unlimited 8

Getting all available properties Get-Mailbox Format-List Get-Mailbox ResultSize 1 Format-List Getting just a list of properties names Get-Mailbox Get-Member -MemberType *Property Select-Object Name 9

Selecting & Sorting Get-Mailbox Select-Object -Property DisplayName, PrimarySMTPAddress Get-Mailbox Select-Object -Property DisplayName, PrimarySMTPAddress Sort-Object -Property DisplayName Examples List all mailboxes, sort by name, and export into a CSV file Get-Mailbox Sort-Object -Property Name Export-csv c:\mailboxes.csv Get a list of mailboxes from Active Directory OU named Users Get-Mailbox -OrganizationalUnit Users 10

Examples Count mailboxes in organisation (Get-mailbox).count Getting all properties for a specific user Get-Mailbox where {$_.DisplayName -eq "Dejan Foro"} format-list Who is thepostmaster? Get-Mailbox where {$_.EmailAddresses - contains "postmaster@exchangemaster.net"} Examples Who is the user with GUID e65a6ff3-d193-4563-9a8e- 26a22315a686? Get-Mailbox where {$_.guid -eq "e65a6ff3-d193-4563-9a8e-26a22315a686"} Who has UM extention 200? Get-Mailbox where {$_.extensions - contains "200"} 11

Getting info about servers Give me a list of Exchange servers Get-Exchangeserver Get-ExchangeServer Select-Object -Property Name, Edition, AdminDisplayVersion, ServerRole format-list Examples Give me a list of mailbox servers Get-ExchangeServer where {$_.ServerRole -ilike "*Mailbox*"} Do we have servers running on trial version of Exchange and if yes when do they expire? Get-ExchangeServer where {$_.IsExchange2007TrialEdition -eq "True"} Select-Object -Property FQDN, RemainingTrialPeriod 12

Getting membership of a group Get-DistributionGroupMember -identity "Swiss IT Pro User Group Moderators" Managing the user lifecycle Creating users - Importing from a.csv file Modifing users move to another database Removing mailboxes and users 13

Importing users from a.csv file Task Import users from a file c:\users.csv For every user Create user account in AD of form First.Last@exchangemaster.net Put them in Organizational Unit VIP Create a mailbox in database Standard users Enter his first and last name Set all users with password Password123 and require the users to change the password at first logon Importing users from a.csv file Import-CSV c:\users.csv 14

Procesing values from a csv file Processing each row of data from.csv file Import-CSV c:\users.csv ForEach-Object { SOME ACTION} Command for creating Users New-Mailbox Get-Help New-Mailbox full Processing values from.csv file Referencing column names from the.csv file $_.columnname Converting Password text into secure string $Password = ConvertTo-SecureString - String "Password123" -asplaintext -force 15

Importing users from a.csv file Putted all together $Password = ConvertTo-SecureString -String "Password123" - asplaintext -force Import-Csv c:\users.csv ForEach-Object { $Name = $_.First + " " + $_.Last $UPN = $_.First + "." + $_.Last + "@exchangemaster.net" New-Mailbox -Name $Name -UserPrincipalName $UPN -Password $Password -OrganizationalUnit VIP -Database 'standard users' - FirstName $_.First -LastName $_Last -ResetPasswordOnNextLogon $True} Making changes to users Apply policies Assing to groups Enable or disable features Changing attributes Moving mailboxes... 16

Moving mailboxes Moving mailoboxes of users in OU VIP to a new database for VIPs Get-Mailbox -OrganizationalUnit "VIP" Move-Mailbox -TargetDatabase "VIP users" Moving mailboxes Checking for mailbox location after move Get-Mailbox Select-Object Name,Database 17

Removing mailboxes Check before deleting! Get-Mailbox -OrganizationalUnit VIP Remove-Mailbox -WhatIf Remove them Get-Mailbox -OrganizationalUnit VIP Remove-Mailbox Recommendation 3rd party snap-in for better manipulation of ADobjects Quest Software ActiveRoles Management Shell for Active Directoy 18

Managing queues Removing spam messages from the queue Remove-Message -Filter {FromAddress -like "*spammer.com* } -withndr $false Testing Get a list of test commands Get-Command test* 19

Testing Script example Report on Exchange database backups with Powershell http://www.exchangemaster.net/index.php?option=com_conte nt&task=view&id=68&itemid=57 20

Setting up your Exchange PowerShell learning enviroment Prerequisites Supported OS Microsoft Windows Server 2003 R2, or Microsoft Windows Server 2003 with SP1 or SP2 Windows XP with Service Pack 2 Windows Vista Windows 2008 The Microsoft.NET Framework 2.0 (2.0.50727) Powershell Exchange 2007 Setting up your Exchange PowerShell learning enviroment Alternative if you don t want to bother: Microsoft Virtual PC Ready-made Microsoft Virtual Hard drive Exchange 2007 Exchange 2007 SP1 beta 21

PowerShell security and common problems for beginners How do I run PowerShell script? When you try to run a PowerShell script from the Run dialog box or by double clicking it, the script does not execute, but opens in Notepad. Answer: Invoke PowerShell.exe with full path to script PowerShell.exe c:\scripts\myscript.ps1 PowerShell security and common problems for beginners 22

PowerShell security and common problems for beginers Script blocked due to execution policy Policy Types Restricted, AllSigned RemoteSigned Unrestricted Commands Get-ExecutionPolicy Set-ExecutionPolicy Unrestricted Setting to Unrestricted is not recommended in production!!! PowerShell and Common problems for beginers Problem script will not execute if contains Exchange commands Solution -create a PowerShell profile which will load Exchange snap-ins for instructions see: FAQ 000037 -error when executing PowerShell script which contains Exchange PowerShell commands 23

Communicating with user from the script Prompting user Write-Host -ForegroundColor red -BackgroundColor yellow "Formating your drive c:..." Write-Host -ForegroundColor blue -BackgroundColor green "Be cool I am just kidding" Getting user input Read-Host 3rd party editors Primal Script 2009 Autocomplete, Shows you syntax as you type List of switches Color coding Debugging Script signing with a one button click Comparing scripts Source control FTP transfer Code reusing Etc. 24

Primal Script Editors and enhancments Primal Script http://www.primalscript.com/ PowerShell IDE http://powershell.de/ PowerShell Analyzer www.powershellanalyzer.com PowerShell Plus http://www.powershell.com/plus/ 25

I don t like comand line Alternatives to PowerShell Power GUI http://www.powergui.org/index.jspa AD Infinitum http://www.newfawm.com/adi2.htm Scriptlogic http://www.scriptlogic.com/ PowerGUI 26

PowerGUI PowerGUI 27

PowerGUI Additional Exchange resources Microsoft Exchange server web site http://www.microsoft.com/exchange Microsoft Exchange Team Blog (You had me at EHLO) http://msexchangeteam.com Technet Microsoft Exchange Server TechCenter http://www.microsoft.com/technet/prodtechnol/exchange/defa ult.mspx Virtual labs http://www.microsoft.com/technet/prodtechnol/exchange/virtu allab/default.mspx Webcasts http://www.microsoft.com/technet/prodtechnol/exchange/2007 /webcasts.mspx 28

PowerShell books Lite Frank Koch, Microsoft Switzerland German version English version PowerShell books medium PowerShell documentation Pack Manuals that comes with Powershell http://www.microsoft.com/downloads/details.aspx?famil yid=b4720b00-9a66-430f-bd56- ec48bfca154f&displaylang=en 29

Powershell Books Advanced Converting VBScript Commands to Windows PowerShell Commands http://www.microsoft.com/technet/scriptcenter/topics/winpsh/convert/default. mspx 30

Webcasts in German Klickst Du noch oder skriptestdu schon? Frank RöderMVP Windows Server System - Directory Services Teil 1Windows PowerShell Einführung Teil 2 Server-Administration mitwindows PowerShell Teil 3 Exchange Server 2007 Administration mit Windows PowerShell Websites and blogs Windows PowerShell Home http://www.microsoft.com/windowsserver2003/technologies/management/po wershell/default.mspx Blog of Windows Powershellteam http://blogs.msdn.com/powershell The Microsoft Exchange Team blog: http://msexchangeteam.com/default.aspx Vivek Sharma s blog: http://www.viveksharma.com/techlog/category/scripts/ The PowerShell Guy http://thepowershellguy.com/blogs/posh/pages/powertab.aspx 31

Websites and blogs Glen Scales development blog http://gsexdev.blogspot.com/ Webcasts Introduction to Windows PowerShell Scripting in Exchange Server 2007 (Level 200) TechNet Webcast: 24 Hours of Exchange Server 2007 (Part 09 of 24): Using PowerShell for Exchange Management (Level 200) Microsoft Windows PowerShell Scripting for Microsoft Exchange Server 2007 (Level 300) 32

Community PowerShell Anwendergruppe www.powershell-ag.de Community PowerShell Live Get-Community Where {$_.passion -eq "PowerShell } http://powershelllive.com 33

Community Swiss IT Pro user group www.swisitpro.ch Exchange User Group Europe http://www.eugeurope.org Speakers wanted Get-speaker where {$._passion eq commnunity } Contact dejan.foro@eugeurope.org 34

Questions? Questions and Answers Q - Can powershell be used against Exchange 2003 machines? A yes, but not with all functionality and looks ugly http://blog.sapien.com/current/2007/2/21/managingexchange-2003-servers-with-powershell.html 35

Questions and Answers Q CanPowerShellbeusedfrom.NETLanguageslike IronPhyton? A PowerShellis basedon.netframeworkandthereforecanbe embededinother.netlanguagesandvice versa. Hereare some examples: Using IronPythonfrom PowerShell Part 1 : Watch folder for changes without blocking Console http://thepowershellguy.com/blogs/posh/archive/2007/02/10/usingironpython-from-powershell-part-1-watch-folder-for-changeswithout-blocking-console.aspx Embedding PowerShell in IronPythonand vice versa -- two great tastes that taste great together http://stevegilham.blogspot.com/2008/02/embedding-powershellin-ironpython.html Presentation dowlnoad This presentation will be available for download from: www.exchangemaster.net 36

Contact: E-mail: dejan.foro@exchangemaster.net LinkedIn: http://www.linkedin.com/in/dejanforo Xing (OpenBC): http://www.xing.com/profile/dejan_foro 37