37,19 €
Learn the art of leveraging PowerShell to automate Office 365 repetitive tasks
The book is aimed at sys admins who are administering office 365 tasks and looking forward to automate the manual tasks. They have no knowledge about PowerShell however basic understanding of PowerShell would be advantageous.
While most common administrative tasks are available via the Office 365 admin center, many IT professionals are unaware of the real power that is available to them below the surface. This book aims to educate readers on how learning PowerShell for Office 365 can simplify repetitive and complex administrative tasks, and enable greater control than is available on the surface.
The book starts by teaching readers how to access Office 365 through PowerShell and then explains the PowerShell fundamentals required for automating Office 365 tasks.
You will then walk through common administrative cmdlets to manage accounts, licensing, and other scenarios such as automating the importing of multiple users,assigning licenses in Office 365, distribution groups, passwords, and so on.
Using practical examples, you will learn to enhance your current functionality by working with Exchange Online, and SharePoint Online using PowerShell. Finally, the book will help you effectively manage complex and repetitive tasks (such as license and account management) and build productive reports.
By the end of the book, you will have automated major repetitive tasks in Office 365 using PowerShell.
This step by step guide focuses on teaching the fundamentals of working with PowerShell for Office 365. It covers practical usage examples such as managing user accounts, licensing, and administering common Office 365 services. You will be able to leverage the processes laid out in the book so that you can move forward and explore other less common administrative tasks or functions.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 199
Veröffentlichungsjahr: 2017
BIRMINGHAM - MUMBAI
< html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
Copyright © 2017 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: July 2017
Production reference: 1250717
ISBN 978-1-78712-799-9
www.packtpub.com
Authors
Martin Machado
Prashant G Bhoyar
Copy Editors
Stuti Srivastava
Madhusudan Uchil
Reviewer
Steve Parankewich
Project Coordinator
Virginia Dias
Acquisition Editor
Rahul Nair
Proofreader
Safis Editing
Content Development Editor
Sweeny Dias
Indexer
Aishwarya Gangawane
Technical Editor
Khushbu Sutar
Graphics
Kirk D'Penha
Production Coordinator
Aparna Bhagat
Martin Machado is an MCSD with over 15 years, experience in designing and implementing systems. He moved into consulting as a way to satisfy his curiosity and interest in diverse IT scenarios and applications very early in his career. He started as an Oracle developer and quickly moved into systems integration with Microsoft technologies. He has a passion for designing complex systems and intricate migrations.
Martin currently works for Microsoft as a Senior Consultant in the Modern Applications Division. He has extensive experience helping customers of all sizes and currently spends most of his time designing solutions that take advantage of Azure and Office 365. When he is not working, Martin enjoys the company of his wife, Raquel, and son, David. He also spends time with his soldering gun, creating custom keyboards and other tinkering projects. Martin is originally from Uruguay but currently lives in the Washington DC metro area.
Prashant G Bhoyar is a Microsoft Office Server and Services MVP and a Microsoft Certified Professional. He is a trusted advisor and subject matter expert and specializes in the development and post-implementation adoption of complex custom solutions in Office 365, Azure, and SharePoint. He has supported many commercial and government agencies and non-profit organizations in the Washington D.C. metropolitan area. He serves on the leadership committee for the DC Metro Office 365 User Group, the SharePoint Saturday Baltimore event, and the SharePoint Saturday Washington DC event. He actively speaks at technical conferences across the United States of America.
Prashant is a recipient of the Antarctic Service Medal of the United States of America for his outstanding service in Antarctica. He currently works as a Senior Consultant at WithumSmith+Brown, PC, and hails from the Washington DC metro area. When not working, Prashant likes to explore new places with his wife, Mayuri.
Steve Parankewich is a professional systems analyst, architect, and engineer. With over 20 years experience Steve has always had a passion for automation. He is currently a PowerShell evangelist and leads the Boston PowerShell user group, organizing monthly meetups with fellow IT professionals. Steve currently focuses on implementation and migration to both Office 365 and Azure. You can reach Steve, or read additional PowerShell-based articles that he has written, on the powershellblogger website.
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https://www.amazon.com/dp/1787127990.
If you'd like to join our team of regular reviewers, you can e-mail us at [email protected]. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products!
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
PowerShell Fundamentals
Why do we need to learn PowerShell for Office 365?
PowerShell is a cmdlet based language with verb-noun syntax
How to pass parameters to cmdlets and storing results as a variable
Parameters
How to get help with PowerShell
What is a module?
What is a pipe?
How PowerShell is an object-oriented language and how to work with objects
Using the if and where statements
Using the for and while loops
Creating your first script
Summary
Managing Office 365 with PowerShell
Admin roles for Office 365
Installing and working with the Office 365 admin tools
Installing Microsoft Online Service Sign-In Assistant
Installing the Windows Azure Active Directory Module for PowerShell
Verifying installation of the Office 365 admin tools
Creating the first user account in PowerShell
Ensuring user account permissions
Checking license availability
Creating a new user
Summary
Azure AD and Licensing Management
Common administrative cmdlets that are used for managing accounts and licensing
How to change the license for existing users
Formatting data to be used for bulk account management
How to reset account passwords
How to update user account details
Summary
Managing SharePoint Online Using PowerShell
A brief overview of the SharePoint APIs
The SharePoint web services API
The SharePoint server-side API and PowerShell API
The client-side object model
The REST API
The SharePoint Online API
Setting up your environment
PowerShell execution policy
SharePoint Online Management Shell
Security requirements
SharePoint Online scripting
Scenario 1 - getting to know the API
Scenario 2 - site collection information
Scenario 3 - site collection maintenance
Testing site health
Scenario 4 - personal sites
Scenario 5 - sharing and external access
Guest access
Scenario 6 - CSOM scripting using PowerShell
Environment setup
Connecting to SharePoint Online via CSOM
CSOM queries
Scenario 7 - the REST API in PowerShell
Summary
Managing Exchange Online Using PowerShell
Connecting to Exchange Online
Exploring the API
Working with Exchange accounts
Creating new mailboxes
Scenario 1 - a new user mailbox
Scenario 2 - an unlicensed existing user
Scenario 3 - a licensed user without the Exchange service
Scenario 4 - MailUser
User photos
Email forwarding
Out-of-office reply
Inbox rules
User impersonation
Installing Exchange Web Services
Role-based access control
Management roles
Role groups
Management role assignment
RBAC scenario - creating a custom administrator
First requirement - limiting access to PowerShell commands
Second requirement - limiting access to a group of users
Summary
Script Automation
PowerShell modules
Module manifest
Script modules
Cmdlets
Scheduled execution
Scripting instrumentation - the next steps
Code signing
Setting up a signing infrastructure
The PKI module
Self-signed certificates
Creating a CA certificate
Querying certificate stores
Exporting, importing, and publishing certificates
Issuing certificates with a self-signed CA
Active Directory Certificate Services
Prerequisites
Requesting and issuing certificates in AD CS
Signing PowerShell scripts
IncludeChain
TimestampServer
Summary
Patterns and Practices PowerShell
Why do we need to learn PnP PowerShell?
Installing and working with PnP PowerShell cmdlets
PowerShell Gallery
Using Setup files/binaries
Installation script
Verifying the installation of the PnP PowerShell module for SharePoint Online
Using Windows Credential Manager with PnP PowerShell
An example of provisioning site collection using a standard template
Summary
OneDrive for Business
Feature configuration
Personal site management
Data migration
The CSOM API
The SPO Migration API
Office 365 Import service
Creating an Azure Blob storage account
Migrating data using Azure Blob storage
Summary
PowerShell Core
Installing PowerShell Core
Remoting on PowerShell Core
WinRM remote management
SSH Remote management
Managing SharePoint with PowerShell Core
Managing SharePoint Online from PowerShell Core
Summary
PowerShell for Office 365 is a powerful tool that is used to perform common administrative tasks. However, there is much more that it can do. PowerShell for Office 365 helps automate repetitive and complex administrative tasks, which can greatly increase the speed and efficiency of your business. This book will walk you through all the aspects of PowerShell for Office 365 and enable you to get greater control over it and extract more from Office 365.
This step-by-step guide focuses on teaching the fundamentals of working with PowerShell for Office 365. It covers practical usage examples such as managing user accounts, licensing, and administering common Office 365 services. You will be able to leverage the processes laid out in the book so that you can move forward and explore other less common administrative tasks or functions.
Chapter 1, PowerShell Fundamentals, covers the basics of working with PowerShell. We will cover topics from command structures, to logical syntax.
Chapter 2, Managing Office 365 with PowerShell, explains the various PowerShell packages and permissions required to manage Office 365 through PowerShell.
Chapter 3, Azure AD and Licensing Management, gives an overview on how to use basic PowerShell skills discussed in previous chapter to create, manage, and remove Office 365 accounts and licenses. This chapter also addresses group management.
Chapter 4, Managing SharePoint Online using PowerShell, focuses on tips and tricks working with SharePoint Online with PowerShell.
Chapter 5, Managing Exchange Online using PowerShell, focuses on tips and tricks working with Exchange Online using PowerShell with practical examples.
Chapter 6, Script Automation, explains taking a script and turning it into an automated process. This can be useful for repetitive tasks such as license and account management.
Chapter 7, Patterns and Practices PowerShell, explores Office 365 PnP PowerShell to manage artifacts in SharePoint Online.
Chapter 8, OneDrive For Business, explains OneDrive, which is another key component for the digital workplace. Individuals can safely keep/sync content on the cloud, making it available anywhere while businesses can manage and retain content securely. In this chapter, we go over common provisioning and management scenarios.
Chapter 9, PowerShell Core, ends this book by covering how to use PowerShell on other platforms. It also explains how to use Office 365 APIs through remoting.
A basic understanding of PowerShell.
The book is aimed at sys admins administering office 365 tasks and looking forward to automating manual tasks. They need not have knowledge of PowerShell; however, a basic understanding of PowerShell would be advantageous.
Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support, and register to have the files e-mailed directly to you. You can download the code files by following these steps:
Log in or register to our website using your e-mail address and password.
Hover the mouse pointer on the
SUPPORT
tab at the top.
Click on
Code Downloads & Errata
.
Enter the name of the book in the
Search
box.
Select the book for which you're looking to download the code files.
Choose from the drop-down menu where you purchased this book from.
Click on
Code Download
.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR / 7-Zip for Windows
Zipeg / iZip / UnRarX for Mac
7-Zip / PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/PowerShell-for-Office-365. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/PowerShellforOffice365_ColorImages.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title. To view the previously submitted errata, go to https://www.packtpub.com/books/content/support, and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at [email protected] with a link to the suspected pirated material. We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.
PowerShell is a command-line environment that is designed for system administrators. It helps you manage and automate administrative tasks on the Windows operating system. With the trend of DevOps, developers are also getting on board with PowerShell.
Microsoft first introduced PowerShell in 2006. 10 years later, in 2016, Microsoft announced that they have made PowerShell open source and cross-platform with support for Windows, macOS X, CentOS, and Ubuntu. The source code is available on GitHub.
Office 365 is a subscription-based SAS offering from Microsoft. To manage Office 365, we have the following options:
Office 365 admin center
: We can use this web-based administration center provided by Microsoft to manage users, licenses, support tickets, billing and subscription, and other services such as Exchange, SharePoint, and Skype for Business that are part of our Office 365 subscription. To sign up for Office 365, we need to use Office 365 admin center. During this signing up process, we select the unique name for our tenant and the global admin account:
Office 365 Admin app
: This app allows us to manage Office 365 with limited functionality. We can reset user passwords, manage support tickets, and so on. It is not a full management tool. However, it helps you to be connected to your subscription when you are away from your computer:
Office 365 management API
: The APIs are designed for developers to create custom apps to manage Office 365:
https://msdn.microsoft.com/en-us/office-365/office-365-managment-apis-overview
. ISVs use these APIs to create products to manage Office 365. These APIs are out of the scope of this book.
PowerShell for Office 365
: This is the management tool that complements Office 365 admin center. We can use Office 365 PowerShell automation to quickly manage Office 365 users and licenses, Skype for Business Online, SharePoint Online, and Microsoft Exchange Online, and create reports:
In this chapter, we will discuss the following topics:
Why do we need to learn PowerShell for Office 365?
PowerShell is a cmdlet-based language with verb-noun syntax
How to pass parameters to cmdlets and storing results as a variable
How to get help with PowerShell?
How PowerShell is an object-oriented language and how to work with objects?
Using the if and where statements
Using the for and while loops
Creating your first script
Office 365 admin center is an out-of-the-box solution that is designed to handle the most common administrative tasks, such as creating new users and assigning licenses. There are situations where PowerShell for Office 365 helps us save time and effort. If you are a systems administrator, PowerShell is now a must-have skill. PowerShell for Office 365 helps you automate a lot of repetitive tasks and also work with advanced functions that are not available in Office 365 admin center:
Office 365 PowerShell can reveal additional information that you cannot see with Office 365 admin center
Office 365 has features that you can only configure using Office 365 PowerShell
Office 365 PowerShell is great at performing bulk operations
Office 365 PowerShell is great for filtering data
Office 365 PowerShell allows us to automate repetitive tasks
Office 365 PowerShell makes it easy to print or save data
Office 365 PowerShell lets you manage operations across server products
I think using the Office 365 admin center is like using public transportation. We have to live with the options provided by Microsoft. If we need something custom, like in the case of transportation when we use taxis or personal vehicles, in Office 365, we can use PowerShell. We still have to write scripts in accordance with Microsoft's guidelines. However, we get far more flexibility and options as compared to Office 365 admin center.
Before we dive deep into PowerShell for Office 365, let's cover the basics of PowerShell in the next few sections.
The building blocks of PowerShell are called cmdlets (pronounced command-lets). Cmdlets allow us to get things done in PowerShell. A cmdlet is a lightweight command that is used in the Windows PowerShell environment. The Windows PowerShell runtime evokes these cmdlets within the context of automation scripts that are provided at the command line. We can put multiple cmdlets together into a set of commands to run all at once, or we can place them in a file with the extension .ps1
