15
Using Powershell 1.0 to Manage SharePoint Western Mass Microsoft User Group--Using Powershell to Manage SharePoint 1 08/27/2022

Using Powershell to manage SharePoint

Embed Size (px)

DESCRIPTION

Using Powershell to manage SharePoint

Citation preview

Page 1: Using Powershell to manage SharePoint

04/08/2023Western Mass Microsoft User Group--Using Powershell to Manage SharePoint

1

Using Powershell 1.0 to Manage SharePoint

Page 2: Using Powershell to manage SharePoint

04/08/2023Western Mass Microsoft User Group--Using Powershell to Manage SharePoint

2

Craig PilkentonoSharePoint Engineer at MassMutual• Enterprise User Group Lead• SharePoint Trainer

oWestern Mass Microsoft User Group: Co-Lead (http://mstech.org)

o LinkedIn.com (http://www.linkedin.com/in/craigpilkenton)

Profile

Page 3: Using Powershell to manage SharePoint

04/08/2023Western Mass Microsoft User Group--Using Powershell to Manage SharePoint

3

Overview: what is Windows Powershell What can('t) it do? Managing Server’s Managing SharePoint Updating SharePoint Take-Away’s

Page 4: Using Powershell to manage SharePoint

04/08/2023Western Mass Microsoft User Group--Using Powershell to Manage SharePoint

4

What is Windows Powershell?o Powershell is the new extensible command-line shell we

can run on any Windows Server or desktop that allows for automating administrative tasks, executing any other command-line toolset, or for calling any regular .NET class, including those for the SharePoint platform.

What does this really mean?o Powershell allows for automating repetitive maintenance tasks,

modularizing scripts to “snap-on” future functionality, built-in enumeration objects, and calling any other command-line or .NET object to get work done (e.g. FTP, file-shares, email, etc.). Everything that is queried or returned to us is an ‘object’ that has all of the available properties and methods.

Overview

Page 5: Using Powershell to manage SharePoint

04/08/2023Western Mass Microsoft User Group--Using Powershell to Manage SharePoint

5

What does Powershell look like?

Overview (cont…)

Page 6: Using Powershell to manage SharePoint

04/08/2023Western Mass Microsoft User Group--Using Powershell to Manage SharePoint

6

Demo : Usage and interaction

Overview

Page 7: Using Powershell to manage SharePoint

04/08/2023Western Mass Microsoft User Group--Using Powershell to Manage SharePoint

7

Monitor server status & activate (Get-Service, Get-EventLog, dir/ls, Stop-Service, Restart-Service)

Import/export files for processing or reports (Import-Csv, Export-Csv, Out-File, Copy-Item, FTP)

Call other command-line utilities (STSADM.exe, RoboCopy, Team Foundation Server, WinZip)

Instantiate .NET objects to use their functionality (Email, FileInfo, ArrayList, Hashtable)

Instantiate SharePoint’s .NET objects to manage the platform (Site-level, subweb-level, Document Library/List-level, permission-level)

And just about anything else…

What can('t) it do?

Page 8: Using Powershell to manage SharePoint

04/08/2023Western Mass Microsoft User Group--Using Powershell to Manage SharePoint

8

Many out-of-the-box cmdlets Not just informational, but reaction-ableoGet-Service

Stop-Service and/or Restart-Service can be fired as logic determines

oGet-EventLogWatch for certain events and then fire other

cmdlets, applications, or cmdlets in responseodir/ls (Get-ChildItem)

Can look for files existing and if not, take action to get or remove

Managing server’s

Page 9: Using Powershell to manage SharePoint

04/08/2023Western Mass Microsoft User Group--Using Powershell to Manage SharePoint

9

Demo : Monitoring our server, and reacting to it

Managing Server’s

Page 10: Using Powershell to manage SharePoint

04/08/2023Western Mass Microsoft User Group--Using Powershell to Manage SharePoint

10

Everything returned is a SharePoint object A ‘Site’ object is instantiated AND must be

disposed of when finishedo Load the Microsoft.SharePoint .NET 2.0 object into

memoryoCreate a ‘New-Object’ to store the SharePoint site

inside ofoBegin querying the new object for its properties,

methods, and stored values; some of which may be other SharePoint objects and/or collections themselves

Managing SharePoint

Page 11: Using Powershell to manage SharePoint

04/08/2023Western Mass Microsoft User Group--Using Powershell to Manage SharePoint

11

Demo: Checking on our SharePoint environment

Managing SharePoint

Page 12: Using Powershell to manage SharePoint

04/08/2023Western Mass Microsoft User Group--Using Powershell to Manage SharePoint

12

We still have a handle to the SharePoint site object to manipulate

So what does it take?oWe open a new SubWeb object (but this can be

done at any level)o Inside of our SubWeb object, create a new List

objectoOn the new List object, create an instance of an

item, add column-value pairs that match the SharePoint List,

o Finally call the .Update() method to add new item

Updating SharePoint

Page 13: Using Powershell to manage SharePoint

04/08/2023Western Mass Microsoft User Group--Using Powershell to Manage SharePoint

13

Demo: Add a new Announcement to our SharePoint site

Updating SharePoint

Page 14: Using Powershell to manage SharePoint

04/08/2023Western Mass Microsoft User Group--Using Powershell to Manage SharePoint

14

Powershell can manage any Microsoft server or platform (some actually have inherent cmdlets available e.g. Exchange 2007, SQL, etc.)

Not only is Microsoft moving all server/platforms to this model, many vendors are doing the same with their software packages and/or tools

Powershell not only talks to almost any command-line interface, but allows for reflexive decisions based on that data

Take-Away’s

Page 15: Using Powershell to manage SharePoint

04/08/2023Western Mass Microsoft User Group--Using Powershell to Manage SharePoint

15

Links oWindows Powershell Team

http://blogs.msdn.com/powershell/o PowershellCommunity.org

http://www.powershellcommunity.org/oMicrosoft Online—Windows SharePoint Services

http://office.microsoft.com/en-us/sharepointtechnology/FX100503841033.aspx

Reference Link