Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Microsoft Exchange Server PowerShell Essentials

You're reading from   Microsoft Exchange Server PowerShell Essentials Leverage the power of basic Windows PowerShell scripts to manage your Exchange messaging environment

Arrow left icon
Product type Paperback
Published in Feb 2016
Publisher
ISBN-13 9781782176039
Length 210 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Biswanath Banerjee Biswanath Banerjee
Author Profile Icon Biswanath Banerjee
Biswanath Banerjee
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Getting Started with PowerShell 2. Learning Recipient Management FREE CHAPTER 3. Handling Distribution Groups 4. Exchange Security 5. Everything about Microsoft Exchange Policies 6. Handling Exchange Server Roles 7. Auditing and E-Discovery 8. Managing High Availability 9. Exploring EWS Managed API 10. Common Administration Tasks Index

Writing a basic script

Now that we have covered the basics of Windows PowerShell, let's write our first script. PowerShell uses the .ps1 format to save scripts. Before we get into executing scripts, let's first understand the following PowerShell Script Execution Policies that are in place to prevent unwanted scripts from being executed on your computer.

The cmdlet Set-Execution Policy helps you to change the Policy of which scripts you can run on your computer. There are four different execution policies:

  • Restricted: In this mode, you cannot run any script and can use Windows PowerShell to run cmdlets in the interactive mode only.
  • AllSigned: Locally created and those signed by a trusted publisher can be run
  • RemoteSigned: Scripts downloaded from another computer can run only if these are signed by a trusted publisher
  • Unrestricted: All the scripts will run regardless of whether they are signed or not

Now, let's set the execution Policy to Remote Signed and verify using Get-Execution Policy cmdlet:

PS C:\> Set-ExecutionPolicy RemoteSigned
PS C:\> Get-ExecutionPolicy

I am going to introduce the PowerShell Integrated Scripting Engine (ISE) that makes it easier to run scripts with features, such as syntax-coloring, tab completion, IntelliSense, visual debugging, and context sensitive Help, as compared to the PowerShell console.

The following script will query the win32_logical disk WMI class. This is a representation of a local storage device on a Windows Computer. There are six possible Drive Types, and we will use a Switch statement to get the output in text describing the type of storage:

Writing a basic script
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image