1. Trang chủ
  2. » Kinh Doanh - Tiếp Thị

Beginning powershell for sharepoint 2016

226 6 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Contents at a Glance

  • Contents

  • About the Authors

  • About the Technical Reviewer

  • Acknowledgments

  • Chapter 1: Introduction

    • The SharePoint Challenges

    • History of PowerShell

    • What Is PowerShell?

    • SharePoint Foundation versus SharePoint Server

    • What You Will Learn in This Book

    • Summary

  • Chapter 2: What’s New in SharePoint 2016

    • New Features

      • Zero Downtime Patching

      • OneDrive Redirection

      • File Size

      • Durable Links

      • App Launcher

      • Fast Site Creation

        • Get-SPWebTemplatesEnabledForSiteMaster

        • Disable-SPWebTemplateForSiteMaster

        • Enable-SPWebTemplateForSiteMaster

        • New-SPSiteMaster

        • Get-SPSiteMaster

        • Remove-SiteMaster

        • How Fast Site Creation Works

      • Filename Support

      • Hybrid Search

      • Sharing of Documents with QR Code

      • Office Online Server (OOS)

      • Automatic Indexing for Large SharePoint Lists

      • MinRoles

    • Summary

  • Chapter 3: PowerShell Basics

    • Terminology

      • Session

      • Cmdlets

      • Profile

      • Snap-In

      • Module

    • PowerShell Operators and Common Operations

      • Printing Values on Screen

      • Console Colors

      • Variables

      • Comments

      • Casting

      • Conditional Logic

        • Decisions

        • Comparison

        • Logical Operators

      • Functions

      • Loops

      • Piping

      • Instance Referrer

      • Error Handling

      • Enumerations

      • Arrays

      • Environment Variables

      • WhatIf Rollback

      • Graphical User Interface

      • Demo Project—Selective Deletion of Files in a Folder

      • Customization

        • My Profile

        • Custom Modules

    • Leaping Ahead

      • Desired State Configuration

      • Dynamic Method and Property Names

    • Summary

  • Chapter 4: Installing and Deploying SharePoint with PowerShell

    • Requirements

      • Hardware Requirements

      • Software Requirements

    • Roles and Features

      • Domain Controller

      • Users and Groups

      • Application Server Role

    • Installing the Software Components

      • Installing SQL Server 2014

      • Installing SharePoint Prerequisites

      • Installing SharePoint

    • Configuring Your SharePoint Farm

      • Creating the Databases

      • Configuring Central Administration

      • Creating Your First Web Application

      • Creating Your Root Site Collection

      • Granting Users Access

    • Putting It All Together

      • Writing to the Registry

      • Automatic Login

      • Script Orchestrator

    • Summary

  • Chapter 5: Managing SharePoint with PowerShell

    • Interacting with Objects

      • Site Collections

        • Get-SPSite

        • Move-SPSite

        • Copy-SPSite

        • New-SPSite

        • Set-SPSite

        • Remove-SPSite

        • Get-SPDeletedSite

        • Remove-SPDeletedSite

        • Restore-SPDeletedSite

        • Putting It Together: Creating a Site Collection Structure

      • Webs

        • Get-SPWeb

        • New-SPWeb

        • Remove-SPWeb

        • Set-SPWeb

        • Export-SPWeb

        • Import-SPWeb

        • Putting It Together: Creating Supporting Webs

      • Lists

        • Getting a List Instance

      • Creating a New List

      • Removing a List Instance

      • Restoring a List Instance

      • Copying a List Instance

      • Putting It Together: Creating Common Lists

      • List Items

        • Getting List Items

        • Removing a List Item

        • Creating a List Item

        • Updating a List Item

        • Putting It Together: Creating Default Tasks Items

      • List Fields

        • Getting an Instance of a Field

        • Creating a New Field

        • Removing a Field

      • Permissions

      • List Permissions on an Object

      • Breaking Permission Inheritance

      • Granting New Permissions

      • Removing Permissions

      • Updating Permissions

      • Objects Disposal

        • Scenario #1 - Bad Memory Management

        • Scenario #2 - Good Memory Management

    • Summary

  • Chapter 6: Monitoring SharePoint with PowerShell

    • Features

      • Getting a Reference to an Existing Feature

    • Activating a Feature

      • Disabling a Feature

      • Backups

        • Automating a Farm Backup

      • Viewing Backup History

      • Automating a Site-Collection Backup

      • Restores

        • Restoring a Farm Backup

      • Restoring a Site Collection Backup

        • Timer Jobs

        • Getting a Reference to an Existing Timer Job

      • Disabling a Timer Job

      • Enabling a Timer Job

      • Changing a Timer Job’s Schedule

      • Starting a Timer Job

      • Managing Services

      • Getting a Reference to a Service Instance

      • Starting a SharePoint Service Instance

      • Stopping a SharePoint Service Instance

    • SharePoint Health Analyzer

      • Getting References to Health Analyzer Rules

      • Disabling a SharePoint Health Analyzer Rule

      • Enabling a SharePoint Health Analyzer Rule

    • Summary

  • Chapter 7: Upgrading from SharePoint 2013 to 2016 with PowerShell

    • Why Should I Upgrade?

    • The Upgrade Process

    • Overview of the Source Environment

    • Copying the Database to the New Farm

    • Restoring the Database to the New Farm

    • Upgrading the Content Database

    • Additional Steps

    • Summary

  • Chapter 8: Managing Office 365 SharePoint Online with PowerShell

    • Overview of the Environment

    • SharePoint Online Management Shell

    • Connecting to the Office 365 Instance

    • Listing Available Commands

    • SharePoint Online Cmdlets

      • Site Collections

        • Get-SPOSite

        • New-SPOSite

        • Remove-SPOSite

        • Repair-SPOSite

        • Set-SPOSite

        • Test-SPOSite

        • Upgrade-SPOSite

        • Request-SPOUpgradeEvaluationSite

        • Get-SPODeletedSite

        • Restore-SPODeletedSite

        • Remove-SPODeletedSite

      • SPOSiteGroup

        • Get-SPOSiteGroup

        • New-SPOSiteGroup

        • Remove-SPOSiteGroup

        • Set-SPOSiteGroup

      • Users

        • Get-SPOUser

        • Get-SPOExternalUser

        • Add-SPOUser

        • Remove-SPOUser

        • Remove-SPOExternalUser

        • Set-SPOUser

      • Apps

        • Get-SPOAppInfo

        • Get-SPOAppErrors

      • Tenant

        • Get-SPOTenant

        • Set-SPOTenant

        • Get-SPOTenantLogEntry

        • Get-SPOTenantLogLastAvailableTimeInUtc

      • Web

        • Get-SPOWebTemplate

    • Doing More with the Client Context

    • Summary

  • Chapter 9: Managing Add-ins and Solutions using PowerShell

    • Solutions

      • Types of Solutions

      • Adding a New Farm Solution

        • Installing a Farm Solution

        • Uninstalling a Farm Solution

        • Removing a Farm Solution

        • Updating a Farm Solution

    • Apps

      • Configuring your Environment to Support Apps

    • App Management Service Application

    • The Microsoft SharePoint Foundation Subscription Settings Service Application

    • Final Configuration Steps

    • Importing an App Package

    • Exporting App Packages

    • Installing an App Package

    • Uninstalling a SharePoint App

    • The App Catalog

    • Creating an App Catalog

    • Adding an App to the Catalog

    • Managing App Permissions

    • Updating an Existing App

    • Summary

  • Chapter 10: Extending PowerShell for SharePoint

    • Creating Modules and Cmdlets

      • Creating a Function

    • Summary

  • Appendix: Common Cmdlets

    • Set-SPServer

    • Get-SPFarmConfig

    • Set-SPPassPhrase

    • Add-SPSolution

    • Backup-SPFarm

    • Backup-SPSite

    • Copy-SPSite

    • Disable-SPTimerJob

    • Enable-SPTimerJob

    • Export-SPAppPackage

    • Export-SPWeb

    • Get-SPAppInstance

    • Get-SPBackupHistory

    • Get-SPFarm

    • Get-SPServiceApplication

    • Get-SPServiceApplicationPool

    • Get-SPServiceInstance

    • Get-SPSite

    • Get-SPTimerJob

    • Get-SPUser

    • Get-SPWeb

    • Get-SPWebApplication

    • Get-SPWebTemplate

    • Import-SPAppPackage

    • Import-SPWeb

    • Install-SPApp

    • Install-SPSolution

    • Mount-SPContentDatabase

    • Move-SPSite

    • New-SPAppManagementServiceApplication

    • New-SPAppManagementServiceApplicationProxy

    • New-SPConfigurationDatabase

    • New-SPContentDatabase

    • New-SPServiceApplicationPool

    • New-SPSite

    • New-SPSubscriptionSettingsServiceApplication

    • New-SPSubscriptionSettingsServiceApplicationProxy

    • New-SPWeb

    • New-SPWebApplication

    • Remove-SPConfigurationDatabase

    • Remove-SPContentDatabase

    • Remove-SPServiceApplication

    • Remove-SPServiceApplicationPool

    • Remove-SPSite

    • Remove-SPSolution

    • Remove-SPWeb

    • Remove-SPWebApplication

    • Request-SPUpgradeEvaluationSite

    • Set-SPServiceApplicationPool

    • Set-SPTimerJob

    • Set-SPWeb

    • Start-SPServiceInstance

    • Start-SPTimerJob

    • Stop-SPServiceInstance

    • Test-SPContentDatabase

    • Uninstall-SPAppInstance

    • Uninstall-SPSolution

    • Update-SPAppCatalogConfiguration

    • Update-SPAppInstance

    • Update-SPSolution

  • Index

Nội dung

Beginning PowerShell for SharePoint 2016 A Guide for Administrators, Developers, and DevOps Engineers — Second Edition — Nikolas Charlebois-Laprade John Edward Naguib Beginning PowerShell for SharePoint 2016 A Guide for Administrators, Developers, and DevOps Engineers Second Edition Nikolas Charlebois-Laprade John Edward Naguib Beginning PowerShell for SharePoint 2016: A Guide for Administrators, Developers, and DevOps Engineers Nikolas Charlebois-Laprade Gatineau, Québec, Canada John Edward Naguib Cairo, Egypt ISBN-13 (pbk): 978-1-4842-2883-8 DOI 10.1007/978-1-4842-2884-5 ISBN-13 (electronic): 978-1-4842-2884-5 Library of Congress Control Number: 2017942718 Copyright © 2017 by Nikolas Charlebois-Laprade and John Edward Naguib This work is subject to copyright All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed Trademarked names, logos, and images may appear in this book Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made The publisher makes no warranty, express or implied, with respect to the material contained herein Cover image designed by Freepik Managing Director: Welmoed Spahr Editorial Director: Todd Green Acquisitions Editor: Gwenan Spearing Development Editor: Laura Berendson Technical Reviewer: Adam Driscoll Coordinating Editor: Nancy Chen Copy Editor: James A Compton, Compton Editorial Services Compositor: SPi Global Indexer: SPi Global Artist: SPi Global Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013 Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc) SSBM Finance Inc is a Delaware corporation For information on translations, please e-mail rights@apress.com, or visit http://www.apress.com/ rights-permissions Apress titles may be purchased in bulk for academic, corporate, or promotional use eBook versions and licenses are also available for most titles For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the book’s product page, located at www.apress.com/9781484228838 For more detailed information, please visit http://www.apress.com/source-code Printed on acid-free paper Thanks to my parents for raising, helping, and support Thanks to my wife and my daughter for understanding and support Thanks to my whole family I love you so much —John Naguib To my beautiful kids Eloïk & Emy, and wife Krystel Thanks for allowing me to always reach my goals in life and set even bigger ones once I reach them —Nik Contents at a Glance About the Authors��������������������������������������������������������������������������������������������������xvii About the Technical Reviewer��������������������������������������������������������������������������������xix Acknowledgments��������������������������������������������������������������������������������������������������xxi ■Chapter ■ 1: Introduction����������������������������������������������������������������������������������������� ■Chapter ■ 2: What’s New in SharePoint 2016����������������������������������������������������������� ■Chapter ■ 3: PowerShell Basics����������������������������������������������������������������������������� 21 ■Chapter ■ 4: Installing and Deploying SharePoint with PowerShell����������������������� 43 ■Chapter ■ 5: Managing SharePoint with PowerShell���������������������������������������������� 67 ■Chapter ■ 6: Monitoring SharePoint with PowerShell������������������������������������������ 109 ■Chapter ■ 7: Upgrading from SharePoint 2013 to 2016 with PowerShell�������������� 127 ■Chapter ■ 8: Managing Office 365 SharePoint Online with PowerShell���������������� 139 ■Chapter ■ 9: Managing Add-ins and Solutions using PowerShell������������������������ 167 ■Chapter ■ 10: Extending PowerShell for SharePoint�������������������������������������������� 191 ■Appendix: ■ Common Cmdlets������������������������������������������������������������������������������ 199 Index��������������������������������������������������������������������������������������������������������������������� 209 v Contents About the Authors��������������������������������������������������������������������������������������������������xvii About the Technical Reviewer��������������������������������������������������������������������������������xix Acknowledgments��������������������������������������������������������������������������������������������������xxi ■Chapter ■ 1: Introduction����������������������������������������������������������������������������������������� The SharePoint Challenges���������������������������������������������������������������������������������������������� History of PowerShell������������������������������������������������������������������������������������������������������� What Is PowerShell?�������������������������������������������������������������������������������������������������������� SharePoint Foundation versus SharePoint Server����������������������������������������������������������� What You Will Learn in This Book������������������������������������������������������������������������������������� Summary�������������������������������������������������������������������������������������������������������������������������� ■Chapter ■ 2: What’s New in SharePoint 2016����������������������������������������������������������� New Features������������������������������������������������������������������������������������������������������������������� Zero Downtime Patching������������������������������������������������������������������������������������������������������������������������ OneDrive Redirection������������������������������������������������������������������������������������������������������������������������������ File Size�������������������������������������������������������������������������������������������������������������������������������������������������� Durable Links������������������������������������������������������������������������������������������������������������������������������������������ App Launcher��������������������������������������������������������������������������������������������������������������������������������������� 10 Fast Site Creation��������������������������������������������������������������������������������������������������������������������������������� 11 Filename Support��������������������������������������������������������������������������������������������������������������������������������� 15 Hybrid Search��������������������������������������������������������������������������������������������������������������������������������������� 15 Sharing of Documents with QR Code��������������������������������������������������������������������������������������������������� 16 vii ■ Contents Office Online Server (OOS)�������������������������������������������������������������������������������������������������������������������� 16 Automatic Indexing for Large SharePoint Lists������������������������������������������������������������������������������������ 17 MinRoles����������������������������������������������������������������������������������������������������������������������������������������������� 19 Summary������������������������������������������������������������������������������������������������������������������������ 19 ■Chapter ■ 3: PowerShell Basics����������������������������������������������������������������������������� 21 Terminology�������������������������������������������������������������������������������������������������������������������� 21 Session������������������������������������������������������������������������������������������������������������������������������������������������� 21 Cmdlets������������������������������������������������������������������������������������������������������������������������������������������������ 21 Profile��������������������������������������������������������������������������������������������������������������������������������������������������� 22 Snap-In������������������������������������������������������������������������������������������������������������������������������������������������� 22 Module�������������������������������������������������������������������������������������������������������������������������������������������������� 22 PowerShell Operators and Common Operations������������������������������������������������������������ 24 Printing Values on Screen��������������������������������������������������������������������������������������������������������������������� 24 Console Colors�������������������������������������������������������������������������������������������������������������������������������������� 24 Variables����������������������������������������������������������������������������������������������������������������������������������������������� 25 Comments�������������������������������������������������������������������������������������������������������������������������������������������� 25 Casting�������������������������������������������������������������������������������������������������������������������������������������������������� 25 Conditional Logic���������������������������������������������������������������������������������������������������������������������������������� 26 Functions���������������������������������������������������������������������������������������������������������������������������������������������� 29 Loops���������������������������������������������������������������������������������������������������������������������������������������������������� 30 Piping���������������������������������������������������������������������������������������������������������������������������������������������������� 31 Instance Referrer���������������������������������������������������������������������������������������������������������������������������������� 32 Error Handling��������������������������������������������������������������������������������������������������������������������������������������� 33 Enumerations��������������������������������������������������������������������������������������������������������������������������������������� 34 Arrays��������������������������������������������������������������������������������������������������������������������������������������������������� 35 Environment Variables�������������������������������������������������������������������������������������������������������������������������� 36 WhatIf Rollback������������������������������������������������������������������������������������������������������������������������������������� 36 Graphical User Interface����������������������������������������������������������������������������������������������������������������������� 37 Demo Project—Selective Deletion of Files in a Folder������������������������������������������������������������������������� 37 Customization��������������������������������������������������������������������������������������������������������������������������������������� 39 viii ■ Contents Leaping Ahead���������������������������������������������������������������������������������������������������������������� 42 Desired State Configuration������������������������������������������������������������������������������������������������������������������ 42 Dynamic Method and Property Names������������������������������������������������������������������������������������������������� 42 Summary������������������������������������������������������������������������������������������������������������������������ 42 ■Chapter ■ 4: Installing and Deploying SharePoint with PowerShell����������������������� 43 Requirements����������������������������������������������������������������������������������������������������������������� 43 Hardware Requirements����������������������������������������������������������������������������������������������������������������������� 44 Software Requirements������������������������������������������������������������������������������������������������������������������������ 44 Roles and Features��������������������������������������������������������������������������������������������������������� 45 Domain Controller��������������������������������������������������������������������������������������������������������������������������������� 46 Users and Groups��������������������������������������������������������������������������������������������������������������������������������� 47 Application Server Role������������������������������������������������������������������������������������������������������������������������ 48 Installing the Software Components������������������������������������������������������������������������������ 51 Installing SQL Server 2014������������������������������������������������������������������������������������������������������������������� 51 Installing SharePoint Prerequisites������������������������������������������������������������������������������������������������������ 52 Installing SharePoint����������������������������������������������������������������������������������������������������������������������������� 54 Configuring Your SharePoint Farm��������������������������������������������������������������������������������� 56 Creating the Databases������������������������������������������������������������������������������������������������������������������������ 56 Configuring Central Administration������������������������������������������������������������������������������������������������������� 58 Creating Your First Web Application������������������������������������������������������������������������������������������������������ 58 Creating Your Root Site Collection�������������������������������������������������������������������������������������������������������� 59 Granting Users Access�������������������������������������������������������������������������������������������������������������������������� 60 Putting It All Together����������������������������������������������������������������������������������������������������� 62 Writing to the Registry�������������������������������������������������������������������������������������������������������������������������� 62 Automatic Login������������������������������������������������������������������������������������������������������������������������������������ 62 Script Orchestrator������������������������������������������������������������������������������������������������������������������������������� 63 Summary������������������������������������������������������������������������������������������������������������������������ 66 ix ■ Contents ■Chapter ■ 5: Managing SharePoint with PowerShell���������������������������������������������� 67 Interacting with Objects������������������������������������������������������������������������������������������������� 67 Site Collections������������������������������������������������������������������������������������������������������������������������������������� 68 Webs����������������������������������������������������������������������������������������������������������������������������������������������������� 75 Lists������������������������������������������������������������������������������������������������������������������������������������������������������ 85 Creating a New List������������������������������������������������������������������������������������������������������������������������������ 86 Removing a List Instance��������������������������������������������������������������������������������������������������������������������� 88 Restoring a List Instance���������������������������������������������������������������������������������������������������������������������� 88 Copying a List Instance������������������������������������������������������������������������������������������������������������������������� 89 Putting It Together: Creating Common Lists����������������������������������������������������������������������������������������� 90 List Items���������������������������������������������������������������������������������������������������������������������������������������������� 91 List Fields��������������������������������������������������������������������������������������������������������������������������������������������� 98 Permissions���������������������������������������������������������������������������������������������������������������������������������������� 100 List Permissions on an Object������������������������������������������������������������������������������������������������������������ 101 Breaking Permission Inheritance������������������������������������������������������������������������������������������������������� 102 Granting New Permissions����������������������������������������������������������������������������������������������������������������� 102 Removing Permissions����������������������������������������������������������������������������������������������������������������������� 104 Updating Permissions������������������������������������������������������������������������������������������������������������������������� 104 Objects Disposal��������������������������������������������������������������������������������������������������������������������������������� 104 Summary���������������������������������������������������������������������������������������������������������������������� 107 ■Chapter ■ 6: Monitoring SharePoint with PowerShell������������������������������������������ 109 Features����������������������������������������������������������������������������������������������������������������������� 109 Getting a Reference to an Existing Feature���������������������������������������������������������������������������������������� 110 Activating a Feature����������������������������������������������������������������������������������������������������� 110 Disabling a Feature����������������������������������������������������������������������������������������������������������������������������� 111 Backups���������������������������������������������������������������������������������������������������������������������������������������������� 111 Viewing Backup History���������������������������������������������������������������������������������������������������������������������� 113 Automating a Site-Collection Backup������������������������������������������������������������������������������������������������� 114 Restores��������������������������������������������������������������������������������������������������������������������������������������������� 114 Restoring a Site Collection Backup���������������������������������������������������������������������������������������������������� 115 Disabling a Timer Job������������������������������������������������������������������������������������������������������������������������� 116 x ■ Contents Enabling a Timer Job�������������������������������������������������������������������������������������������������������������������������� 117 Changing a Timer Job’s Schedule������������������������������������������������������������������������������������������������������ 117 Starting a Timer Job��������������������������������������������������������������������������������������������������������������������������� 119 Managing Services����������������������������������������������������������������������������������������������������������������������������� 120 Getting a Reference to a Service Instance����������������������������������������������������������������������������������������� 120 Starting a SharePoint Service Instance���������������������������������������������������������������������������������������������� 121 Stopping a SharePoint Service Instance�������������������������������������������������������������������������������������������� 121 SharePoint Health Analyzer������������������������������������������������������������������������������������������ 122 Getting References to Health Analyzer Rules������������������������������������������������������������������������������������� 123 Disabling a SharePoint Health Analyzer Rule������������������������������������������������������������������������������������� 125 Enabling a SharePoint Health Analyzer Rule�������������������������������������������������������������������������������������� 125 Summary���������������������������������������������������������������������������������������������������������������������� 126 ■Chapter ■ 7: Upgrading from SharePoint 2013 to 2016 with PowerShell�������������� 127 Why Should I Upgrade?������������������������������������������������������������������������������������������������ 128 The Upgrade Process��������������������������������������������������������������������������������������������������� 128 Overview of the Source Environment��������������������������������������������������������������������������� 129 Copying the Database to the New Farm����������������������������������������������������������������������� 129 Restoring the Database to the New Farm�������������������������������������������������������������������� 131 Upgrading the Content Database��������������������������������������������������������������������������������� 133 Additional Steps����������������������������������������������������������������������������������������������������������� 138 Summary���������������������������������������������������������������������������������������������������������������������� 138 ■Chapter ■ 8: Managing Office 365 SharePoint Online with PowerShell���������������� 139 Overview of the Environment��������������������������������������������������������������������������������������� 140 SharePoint Online Management Shell�������������������������������������������������������������������������� 140 Connecting to the Office 365 Instance������������������������������������������������������������������������� 142 Listing Available Commands���������������������������������������������������������������������������������������� 143 SharePoint Online Cmdlets������������������������������������������������������������������������������������������� 144 Site Collections����������������������������������������������������������������������������������������������������������������������������������� 144 SPOSiteGroup������������������������������������������������������������������������������������������������������������������������������������� 153 Users�������������������������������������������������������������������������������������������������������������������������������������������������� 156 xi APPENDIX Common Cmdlets This appendix gives a brief overview of the various PowerShell cmdlets we covered in this book and some other useful cmdlets, along with examples of how to use them Set-SPServer Sets the role in the SharePoint 2016 farm: Set-SPServer -Identity -Role Get-SPFarmConfig Returns a global property or a collection of global properties for the local farm: Get-SPFarmConfig [-AssignmentCollection ] [-ServiceConnectionPoint ] Set-SPPassPhrase Sets the passphrase to a new value: Set-SPPassPhrase -ConfirmPassPhrase -PassPhrase [-AssignmentCollection ] [-Confirm []] [-WhatIf []] Add-SPSolution Adds a SharePoint solution to the farm Needs to reference the local wsp solution file: Add-SPSolution –LiteralPath c:\solution.wsp   [UNCPath to the local wsp file] © Nikolas Charlebois-Laprade and John Edward Naguib 2017 N Charlebois-Laprade and J E Naguib, Beginning PowerShell for SharePoint 2016, DOI 10.1007/978-1-4842-2884-5 199 APPENDIX ■ Common Cmdlets Backup-SPFarm Creates a backup of a specific database, a web application, or the entire SharePoint farm: Backup-SPFarm -Directory [Path to the backup directory] -BackupMethod Full Backup-SPSite Creates a backup of a specific site collection: Backup-SPSite -Identity [URL of the site collection to backup] -Path [Path to where to store the resulting bak file] Copy-SPSite Creates a copy of an existing site collection at a different location in the same SharePoint web application: Copy-SPSite –Identity http://contoso/sites/OldTeam  [URL of the site collection to copy] -TargetUrl http://contoso/sites/NewTeam [URL of the destination to copy the site collection to] Disable-SPTimerJob Disables a specific timer job, preventing its execution: Disable-SPTimerJob –Identity [Reference to the timer job instance] Enable-SPTimerJob Enables a specific timer job, allowing it to execute based on its established schedule: Enable-SPTimerJob –Identity [Reference to the timer job instance] Export-SPAppPackage Exports a specific app instance into a local app package: Export-SPAppPackage -App [Reference to the app instance] -Path [Local path to the app file to store] 200 APPENDIX ■ Common Cmdlets Export-SPWeb Exports a SharePoint web into a local file: Export-SPWeb -Identity[URL of the web to export] -Path [Local path of the cmp export file where to store the exported web] Get-SPAppInstance Returns a collection of app instances installed on a specific web: Get-SPAppInstance -Web [URL of the web to get the app instances from] Get-SPBackupHistory Returns the history of all backup and restore operations that took place in a specific folder: Get-SPBackupHistory -Directory [Path to backup folder] Get-SPFarm Returns a reference to the local SharePoint farm: Get-SPFarm Get-SPServiceApplication Returns a collection of all instances of service applications in the SharePoint farm: Get-SPServiceApplication Get-SPServiceApplicationPool Returns a collection of all IIS application pools: Get-SPServiceApplicationPool Get-SPServiceInstance Returns a collection of all service instances for a specific server or for the entire SharePoint farm: Get-SPServiceInstance 201 APPENDIX ■ Common Cmdlets Get-SPSite Returns a collection of all site collections in the SharePoint farm: Get-SPSite Get-SPTimerJob Returns a collection of all timer jobs registered in the SharePoint farm: Get-SPTimerJob Get-SPUser Returns a collection of all users associated with a specific SharePoint web: Get-SPUser -Web [URL of the web to get the user list from] Get-SPWeb Returns a reference to a specific SharePoint web: Get-SPWeb -Identity[URL of the web to get a reference to] Get-SPWebApplication Returns a collection of all SharePoint web applications contained in the local farm: Get-SPWebApplication Get-SPWebTemplate Returns a collection of all web templates contained in the local SharePoint farm: Get-SPWebTemplate Import-SPAppPackage Imports a local app package into a specified site collection It requires users to specify the source origin of the package This value can be Marketplace, CorporateCatalog, DeveloperSite, ObjectModel, or RemoteObjectModel: Import-SPAppPackage -Path [Local path to the app package to import] -Site [URL of the site collection in which to import the app package] -Source ([Microsoft.SharePoint.Administration.SPAppSource]::ObjectModel) 202 APPENDIX ■ Common Cmdlets Import-SPWeb Imports a SharePoint web, a list, or a library based on an exported cmp SharePoint artifact from a local file: Import-SPWeb -Identity [URL of where to restore the web] -Path [Local path to the cmp exported web file] Install-SPApp Installs an app on a specific SharePoint web: Install-SPApp -Web [URL of the web on which to install the app instance] -Identity [Reference to app instance] Install-SPSolution Installs a SharePoint farm solution that has been previously added to the farm: Install-SPSolution -Identity [Name of the solution] Mount-SPContentDatabase Attaches a SharePoint database to the current farm: Mount-SPContentDatabase –Name [Name of the content database on the SQL Server] -WebApplication [URL of the web application to link the database to] Move-SPSite Moves a site collection from one content database to another: Move-SPSite -Identity [URL of the site collection to move] -DestinationDatabase [Name of the destination database on the SQL Server] New-SPAppManagementServiceApplication Creates a new instance of the App Management Service application: New-SPAppManagementServiceApplication –ApplicationPool [Reference to the associated application pool] –Name [Name to give to the service application instance] –DatabaseName [Name to give to the associated SQL Server database] 203 APPENDIX ■ Common Cmdlets New-SPAppManagementServiceApplicationProxy Creates an App Management Service application proxy and associates it with its service application instance: New-SPAppManagementServiceApplicationProxy -ServiceApplication [Reference to the service application instance] -Name [Name you wish to give to the service application proxy] New-SPConfigurationDatabase Creates a new SharePoint configuration database for the local farm: New-SPConfigurationDatabase -DatabaseServer [Name of the SQL Server] -DatabaseName [Name you wish to give to the new database] -AdministrationContentDatabaseName [Reference to the SharePoint Administrative Database] -Passphrase [Secret passphrase to configure the farm] -FarmCredentials [Secure credentials to run the farm account] New-SPContentDatabase Creates a new SharePoint content database in the farm’s SQL Server: New-SPContentDatbase –Name [Name of the new content database] -DatabaseServer [Name of the farm's SQL Server] -WebApplication [URL of the SharePoint web application to associate the content database with] New-SPServiceApplicationPool Creates a new IIS application pool: New-SPServiceApplicationPool –Name [Name to give] -Account [Username of the account to use to run this application pool] New-SPSite Creates a new site collection: New-SPSite -Url [URL of the new site collection] -OwnerAlias [Username of the account to use as farm administrator] 204 APPENDIX ■ Common Cmdlets New-SPSubscriptionSettingsServiceApplication Creates a new instance of the Subscription Settings Service application: New-SPSubscriptionSettingsServiceApplication -Name [Name to give the service application instance] -DatabaseName [Name of the database associated to the service application instance] -ApplicationPool [Reference to the application pool to use to run the service application] New-SPSubscriptionSettingsServiceApplicationProxy Creates a new service application proxy for a Subscription Settings Service application instance: New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication [Reference to the associated service application] New-SPWeb Creates a new SharePoint web: New-SPWeb –Url [URL of the new web] New-SPWebApplication Creates a new SharePoint web application: New-SPWebApplication -Name [Name of the new Web Application] -ApplicationPool [Name of an existing application pool to associate the web application with] Remove-SPConfigurationDatabase Permanently deletes the SharePoint farm’s configuration database that has been previously dismounted: Remove-SPConfigurationDatabase Remove-SPContentDatabase Permanently deletes an instance of a SharePoint content database from SQL Server: Remove-SPContentDatabase –Identity [Reference to the SharePoint content database] 205 APPENDIX ■ Common Cmdlets Remove-SPServiceApplication Permanently deletes an instance of a SharePoint service application: Remove-SPServiceApplication –Identity [GUID of the service application to delete] Remove-SPServiceApplicationPool Permanently deletes an IIS web service application pool: Remove-SPServiceApplicationPool –Identity [Reference to the IIS web service application pool to delete] Remove-SPSite Deletes a SharePoint site collection: Remove-SPSite -Identity [URL of the site collection to delete] Remove-SPSolution Deletes a SharePoint farm solution from the farm: Remove-SPSolution –Identity [Name of the wsp package to remove] Remove-SPWeb Deletes a SharePoint web: Remove-SPWeb -Identity [URL to the web to delete] Remove-SPWebApplication Deletes a SharePoint web application: Remove-SPWebApplication -Identity [URL or name of the web application to delete] Request-SPUpgradeEvaluationSite Makes a request to have an upgrade evaluation site collection created in a queue The daily timer job will then take care of creating it: Request-SPUpgradeEvaluationSite –Identity [Reference to the original site collection] 206 APPENDIX ■ Common Cmdlets Set-SPServiceApplicationPool Changes the account used to run a SharePoint IIS web service application pool: Set-SPServiceApplicationPool –Identity [Reference to the IIS web service application pool] -Account [Username to use to run the application pool] Set-SPTimerJob Sets a new schedule for a running SharePoint timer job: Set-SPTimerJob -Identity [Reference to the timer job] -Schedule "Hourly between and 10" Set-SPWeb Configures various properties of a specific SharePoint web: Set-SPWeb -Identity[URL to the SharePoint Web] -RelativeUrl [New relative URL of SharePoint web] Start-SPServiceInstance Enables a specific SharePoint service instance on a specific server or on the entire farm: Start-SPServiceInstance –Identity [GUID of the service instance to start] Start-SPTimerJob Immediately executes a specific SharePoint timer job; then its normal execution schedule resumes: Start-SPTimerJob -Identity[Reference to the timer job to execute] Stop-SPServiceInstance Stops a service instance for a specific SharePoint service: Stop-SPServiceInstance Identity [GUID of the service instance to stop] 207 APPENDIX ■ Common Cmdlets Test-SPContentDatabase Tests a SharePoint content database against its associated web application to ensure that all customized components are installed: Test-SPContentDatabase -Name[Name of the content database to test] -WebApplication [URL of the web application to test the database against] Uninstall-SPAppInstance Uninstalls a specific SharePoint app instance: Uninstall-SPAppInstance -Identity[Reference to the app instance to uninstall] Uninstall-SPSolution Uninstalls a specific SharePoint farm solution from the environment Uninstalling it doesn’t remove the wsp from the server You will need to use the Remove-SPSolution cmdlet to so Uninstall-SPSolution –Identity [Name of the wsp solution to remove with its wsp extension] Update-SPAppCatalogConfiguration Updates the location of the app catalog: Update-SPAppCatalogConfiguration -Site [URL of the new location of the app catalog] Update-SPAppInstance Updates an app instance to a newer version: Update-SPAppInstance -Identity[Reference to the old version of the app instance] -App [Reference to the newest app instance] Update-SPSolution Updates an already deployed SharePoint farm solution to its newest version: Update-SPSolution -Identity [Name of the farm solution to update including the wsp extension] -LiteralPath [Local path to the newest wsp solution package] -GACDeploy 208 Index „„         A Add-ins, 172 Add-SPOUser cmdlet, 159 Add-SPSolution, 199 App catalog creation, 183–184 document libraries, 185 SharePoint 2016 app uploaded, 186 Application server role, 48 App Management Service application central administration, 173 central administration interface, 175 IIS application pool creation, 172 notification, turned off, 175 proxy, 174 service instance status, 175 SharePoint 2016 server, 174 „„         B Backup-SPFarm, 200 Backup-SPSite, 200 Business Productivity Online Services (BPOS), 139 „„         C Central Administration, 58 Client Side Object Model, 166 Cmdlets Add-SPSolution, 199 Backup-SPFarm, 200 Backup-SPSite, 200 Copy-SPSite, 200 Disable-SPTimerJob, 200 Enable-SPTimerJob, 200 Export-SPAppPackage, 200 Export-SPWeb, 201 Get-SPAppInstance, 201 Get-SPBackupHistory, 201 Get-SPFarm, 201 Get-SPFarmConfig, 199 Get-SPServiceApplication, 201 Get-SPServiceApplicationPool, 201 Get-SPServiceInstance, 201 Get-SPSite, 202 Get-SPTimerJob, 202 Get-SPUser, 202 Get-SPWeb, 202 Get-SPWebApplication, 202 Get-SPWebTemplate, 202 Import-SPAppPackage, 202 Import-SPWeb, 203 Install-SPApp, 203 Install-SPSolution, 203 Mount-SPContentDatabase, 203 Move-SPSite, 203 New-SPAppManagementServiceApplication, 203 New-SPAppManagementService ApplicationProxy, 204 New-SPConfigurationDatabase, 204 New-SPContentDatabase, 204 New-SPServiceApplicationPool, 204 New-SPSite, 204 New-SPSubscriptionSettingsService Application, 205 New-SPSubscriptionSettingsServiceApplication Proxy, 205 New-SPWeb, 205 New-SPWebApplication, 205 Remove-SPConfigurationDatabase, 205 Remove-SPContentDatabase, 205 Remove-SPServiceApplication, 206 Remove-SPServiceApplicationPool, 206 Remove-SPSite, 206 Remove-SPSolution, 206 Remove-SPWeb, 206 Remove-SPWebApplication, 206 Request-SPUpgradeEvaluationSite, 206 Set-SPPassPhrase, 199 Set-SPServer, 199 Set-SPServiceApplicationPool, 207 © Nikolas Charlebois-Laprade and John Edward Naguib 2017 N Charlebois-Laprade and J E Naguib, Beginning PowerShell for SharePoint 2016, DOI 10.1007/978-1-4842-2884-5 209 ■ INDEX Cmdlets (cont.) Set-SPTimerJob, 207 Set-SPWeb, 207 Start-SPServiceInstance, 207 Start-SPTimerJob, 207 Stop-SPServiceInstance, 207 Test-SPContentDatabase, 208 Uninstall-SPAppInstance, 208 Uninstall-SPSolution, 208 Update-SPAppCatalogConfiguration, 208 Update-SPAppInstance, 208 Update-SPSolution, 208 Conditional logic comparison operators, 27 if and else statements, 26 logical operators, 28 Connect-SPOService, 142 „„         D Desired state configuration, 42 Disable-SPTimerJob, 200 Durable links, „„         E Error handling, 33 Export-SPAppPackage, 200 „„         F Fast site creation Disable-SPWebTemplateForSiteMaster, 12 Enable-SPWebTemplateForSiteMaster, 13 Get-SPSiteMaster, 14 Get-SPWebTemplatesEnabledForSiteMaster, 12 New-SPSiteMaster, 13 Remove-SiteMaster, 14 Filename Support, 15 „„         G Get-SPAppInstance, 201 Get-SPFarm, 201 Get-SPFarmConfig, 199 Get-SPOAppErrors, 162 Get-SPOAppInfo cmdlet, 162 Get-SPODeletedSite, 151 Get-SPOExternalUser cmdlet, 157 Get-SPOSite cmdlet, 145 Get-SPOSiteGroup PowerShell cmdlet, 154 Get-SPOTenant cmdlet, 163 Get-SPOTenantLogEntry, 164 Get-SPOTenantLogLastAvailableTimeInUtc, 165 Get-SPOUser cmdlet, 157 210 Get-SPServiceApplicationPool, 201 Graphical user interface (GUI), 37 „„         H Hybrid search, 15 „„         I Interacting with SharePoint objects list fields creation, 99–100 listing information, 99 removing, 100 list instance common lists, creation, 90–91 copying, 89–90 creation, 86–87 removing, 88 restoring, 88 list items creation, 96–97 default tasks items, creation, 98 fruits and unit price, 92 removing, 94–96 updation, 97 objects disposal, 104 bad memory management, 104 good memory management, 105 permissions breaking inheritance, 102 granting new permissions, 102–103 list, 101–102 removing, 104 updation, 104 site collections Copy-SPSite, 69 creation, 74–75 Get-SPDeletedSite, 73 Get-SPSite, 68 Move-SPSite, 69 New-SPSite, 70 Remove-SPDeletedSite, 73 Remove-SPSite, 72 Restore-SPDeletedSite, 74 Set-SPSite, 71 Webs Export-SPWeb, 82 Get-SPWeb, 75 Import-SPWeb, 82 New-SPWeb, 76 Remove-SPWeb, 80 Set-SPWeb, 81 supporting webs, creation, 82–84 templates, 76–79 ■ INDEX Interact with SharePoint 2016 features automating, site-collection backup, 114 backups, 111–113 disabling, 111 enabling, 111 Get-SPFeature PowerShell cmdlet, 110 reference, 110 restores farm backup, 114–115 service instance starting, 121 stopping, 121–122 site collection backup, restoring reference, existing timer job, 116 timer jobs, 115 Timer Job changing schedule, 117–119 disabling, 116 enabling, 117 starting, 119–120 viewing backup history, 113 Invoke-WebRequest PowerShell, 53 „„         J, K Job-List-Automatic-Index-Management, 17 „„         L Logical operators, 28 „„         M Microsoft SharePoint Foundation Subscription Settings Service Application, 175, 177 MinRoles, 19 Modules and Cmdlets, creation class Library project, 192 SharePoint DLL, 194 site collections, parameter, 195–196 System.Management.Automation, 193 web application names, 196 „„         N New-SPOSite, 146 New-SPOSiteGroup PowerShell cmdlet, 155 „„         O Office 365 app launcher, 10 default site collection, 140 Client Side Object Model, 166 PowerShellBook.onmicrosoft.com, 140 security groups and permissions, 154 SharePoint admin center, 140 SharePoint Online cmdlets (see SharePoint Online cmdlets) SharePoint Online Management Shell (see SharePoint Online Management Shell) trial account, 140 Office 365 app launcher, 10 Office Online Server (OOS), 16 OneDrive redirection, Orchestrator, 63 „„         P, Q Piping, 31 PowerShell definition, dynamic method and property names, 42 external NET assemblies, graphical interface generated, history, operators and common operations arrays, 35 casting, 25 colors, 24 comments, 25 conditional logic (see Conditional logic) custom modules, 41 enumerations, 34 environment variables, 36 error handling, 33 files listing, folder, 37–38 for loops and while loops, 30–31 function, 29–30 GUI, 37 instance referrer, 32 piping, 31 profile, 40 variables, 25 WhatIf switch, 36 write-host and read-host cmdlets, 24 terminology binary (.dll) module, 23 Cim (.cdxml) module, 23 cmdlets, 21 Get-Module-ListAvailable cmdlet, 23 manifest (.psd1) module, 23 profile, 22 script (.psm1) module, 23 session, 21 snap-ins, 22 workflow (.xaml) module, 24 variables, PowerShellBook.onmicrosoft.com, 140 PowerShell function, creation, 197 211 ■ INDEX „„         R Remove-SPODeletedSite, 153 Remove-SPOExternalUser cmdlet, 160 Remove-SPOSite cmdlet, 148 Remove-SPOSiteGroup, 156 Remove-SPOUser cmdlet, 160 Repair-SPOSite, 148 Request-SPOUpgradeEvaluationSite PowerShell cmdlet, 151 Restore-SPODeletedSite PowerShell cmdlet, 152 „„         S Script Orchestrator, 63 Set-SPOSite, 149 Set-SPOTenant, 164 Set-SPOUser cmdlet, 161 Set-SPPassPhrase, 199 Set-SPServer, 199 SharePoint 2016 features app launcher, 10–11 automatic indexing, 17–18 durable links, fast site creation (see Fast site creation) filename support, 15 file size, 7–9 hybrid search, 15 MinRoles, 19 Office Online Server (OOS), 16 onedrive redirection, share documents, QR code, 16 zero downtime patching, SharePoint app catalog (see App catalog) configuration, 178 deploy and install, 179 DNS manager console, 180 existing app updation, 188–189 package exporting, 181 importing, 180–181 installation, 182 uninstallation, 182 permissions, 186–187 Set-SPAppDomain cmdlet, 178 trust dialog, 188 SharePoint Challenges, 1–2 SharePoint farm environment automatic login, 62 configuration Central Administration, 58 databases, 56 first web application creation, 58 212 granting users access, 60 root site collection, 59 hardware requirements, 44 registry, 62 script orchestrator, 63 software requirements, 44 SharePoint Foundation vs SharePoint Server, SharePoint health analyzer disabling, 125 enabling, 125 Get-SPHealthAnalysisRule method, 123 list, timer jobs, 123 SharePoint Online cmdlets Apps Get-SPOAppErrors, 162 Get-SPOAppInfo, 162 Get-SPOWebTemplate, 166 site collections Get-SPODeletedSite, 151 Get-SPOSite, 145 New-SPOSite, 146 Remove-SPODeletedSite, 153 Repair-SPOSite, 148 Request-SPOUpgradeEvaluationSite, 151 Restore-SPODeletedSite PowerShell, 152 Set-SPOSite, 149 Site Collections, 148 Test-SPOSite, 150 Upgrade-SPOSite, 150 SPOSiteGroup Get, 154 New, 155 Remove, 156 Set, 156 tenant Get-SPOTenant, 163 Get-SPOTenantLogEntry, 164 Get-SPOTenantLogLastAvailableTimeIn Utc, 165 Set-SPOTenant, 164 users Add-SPOUser, 159 Get-SPOExternalUser, 157 Get-SPOUser, 157 Remove-SPOExternalUser, 160 Remove-SPOUser cmdlet, 160 Set-SPOUser, 161 SharePoint Online Management Shell cmdlets list, 143–144 Connect-SPOService, 142 credentials, 142 Get-Command cmdlet, 143 PowerShell console, 142 setup, 141 ■ INDEX SharePoint solutions adding new farm solution, 168 farm solution installation, 169–170 removing, 171 uninstalling, 171 updation, 171 types, 167–168 Software components installation SharePoint core bits, 54 SharePoint prerequisites, 52 SQL Server 51, 2014 SPOSite, 144 SQL Server 51, 2014 „„         U, V „„         T Windows Presentation Framework (WPF), 24 Windows Server 2012 installation roles and features application server role, 48 domain controller, 46 users and groups, 47 Windows Workflow Foundation (WWF), 24 Test-SPOSite cmdlet, 150 Timer jobs, 115 changing schedule, 117–119 disabling, 116 enabling, 117 existing, 116 health analyzer–related, 123 starting, 119–120 Traditional developers vs traditional administrators, Upgrading, SharePoint 2013 to 2016 content database, 133–137 database copying, 129 database restoring, 131–132 migrated site, 135 migrations paths, 127–128 process, 128 site collection settings, 136 site collection upgrade status, 137 source environment, 129 „„         W, X, Y „„         Z Zero downtime patching, 213 .. .Beginning PowerShell for SharePoint 2016 A Guide for Administrators, Developers, and DevOps Engineers Second Edition Nikolas Charlebois-Laprade John Edward Naguib Beginning PowerShell for SharePoint. .. of the SharePoint 2016 farm in order to function as expected 16 Chapter ■ What’s New in SharePoint 2016 Automatic Indexing for Large SharePoint Lists It has always been a problem with SharePoint. .. automatic indexing of a SharePoint 2016 list using PowerShell After executing these PowerShell lines, you can go back through the SharePoint 2016 graphical interface and see for yourself that the

Ngày đăng: 26/09/2021, 20:16

w