SlideShare una empresa de Scribd logo
1 de 37
berrydunn.com | GAIN CONTROL
USING POWERSHELL TO
IMPROVE SHAREPOINT
MANAGEMENT
SharePoint Saturday Boston
June 13, 2015
Mitch Darrow, Senior Consultant
2
• Public accounting and
management/IT consulting firm
• Founded in 1974, the firm now
has over 250 personnel and 36
principals
• $50 million in annual revenue
• For the last four years, BerryDunn was designated as an
INSIDE Public Accounting (IPA) “Top 100 Firm,” and was
also named as a “Fastest-Growing” firm.
• Named “Best CPA Firm for Women” by the American
Society of Women Accountants and the American Woman’s
Society of Certified Public Accountants.
BerryDunn Overview
Legend
Office Locations
Satellite Office Locations
3
INDEPENDENCE AND OBJECTIVITY
We do not sell or develop hardware or software.
We do not partner with software developers
or solution providers.
Independence allows our team to provide objective IT
consulting services and to offer recommendations that
represent only the client’s best interests.
4
MITCH DARROW
SENIOR CONSULTANT
GOVERNMENT CONSULTING GROUP
Over 25 years of IT experience in global manufacturing companies.
Specializing in:
• Windows Architecture
• Security Best Practices
• Databases
• SharePoint
• Exchange
• Programming ( C#, PowerShell)
Representative clients
• Colorado DHS
• Washington State Auditors Office
• West Virginia Bureau of Medical Services
5
MITCH DARROW
About me
Husband and father of three
Live in the Portland, Maine area
Avid Kayaker, hopefully soon to be a
Maine guide
Bike commuter
Volunteer
IT Geek
6
GAP YEAR
ADVOCATE
All three of my kids have had an
adventure before starting
University. Ask me about it after
the presentation, if you are
interested!
7
WHAT ARE THE CHALLENGES?
Important information is everywhere
• Central Administration
• Site Collection
• Sites
• SQL Management Studio
How do we get the information into the hands of those who need it?
Helpdesk
IT On Call
Managers
Business Users
POWERSHELL CAN HELP!
Read information from almost anywhere in SharePoint
Read information from SQL Server
Read data from Active Directory
Write all this data into a SharePoint Site
Create Ops dashboard
Management dashboard
All using the same toolkit!
8
SOME PREREQUISITES
User context running the script needs permissions:
Add-SPShellAdmin
Adds user to:
• SharePoint_Shell_Access Role
• WSS_ADMIN_WPG group on the local computer
Add-SPShellAdmin -UserName CONTOSOUser1 -database 4251d855-3c15-4501-8dd1-98f960359fa6
Additional information:
https://technet.microsoft.com/en-us/library/ff607596.aspx
9
BEFORE WE BEGIN
Please don’t develop and/or test in Production!
If you don’t understand what a script is doing, you probably shouldn’t be running it!
PowerShell allows you to structure logic in dramatically different ways. All are
correct, but they are not all equal.
Don’t assume that one structure is better than another. If performance is important,
measure it with measure-command{}.
Error handling (Try/Catch) is always a best practice. I acknowledge this is absent
from my sample code.
10
THE BASICS:
Add the snap in to PowerShell
Add-PSSnapIn Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Create an array of all the web application objects:
$webApps = Get-SPWebApplication http://intranet.contoso.com
foreach($webApp in $webApps) {
}
11
THE BASICS CONTINUED:
Looping through all the site collections in the web application:
foreach($site in $webApp.Sites){
}
Looping through all of the sites in each site collection:
foreach($web in $site.AllWebs) {
}
12
SO, WHAT KINDS OF
INFORMATION CAN WE COLLECT?
Inventory the names and URLs of all sites in the farm
Inventory Crawl information for the farm
Last status & Duration
Number of items crawled
Get all Role Assignments and Permission levels
Expand SharePoint groups
Expand AD groups
13
SO, WHAT KINDS OF
INFORMATION CAN WE COLLECT?
Get content database associated with site collection
database growth settings
database sizes
backup mode
full/differential/log backup statuses
Inventory list versioning settings
Site size
Site last updated
14
USERS AND PERMISSIONS OVERVIEW
SharePoint Site Permissions can be messy
Role Assignments can be
SharePoint Groups
AD Groups
User Objects
SharePoint Groups can contain users or AD groups
AD groups can contain users and other groups
15
USERS AND PERMISSIONS
Check if the site has unique permissions of inherits:
if($web.HasUniqueRoleAssignments -eq $false) { }
If permissions are unique:
foreach($assignment in $web.RoleAssignments){ }
Check if the member string is empty or not:
if(-not [string]::IsNullOrEmpty($assignment.Member.Xml)) { }
Check if the xml starts with a group tag:
if($assignment.Member.XML.StartsWith('<Group') -eq "True") { }
16
USERS AND PERMISSIONS 2
Check if the xml starts with a group tag:
if($assignment.Member.XML.StartsWith('<Group') -eq "True") { }
Get the members of the SharePoint group:
foreach($SPGroupMember in $assignment.Member.Users) { }
Check to see if the IsDomainGroup property for the member is true:
if($SPGroupMember.IsDomainGroup) { }
17
WRITING DATA TO SHAREPOINT
#Get the SPWeb object and save it to a variable
$web = Get-SPWeb $webURL
#Get the List object to retrieve the "Demo List"
$list = $web.Lists[$listName]
#Create a new item
$newItem = $list.Items.Add()
18
WRITING DATA TO SHAREPOINT 2
Add data to this list item
$newItem["SiteURL"] = $SiteURL
$newItem["InheritsPerms"] = $InheritsPerms
$newItem["SPGroup"] = $SPGroup
$newItem["ADGroup"] = $ADGroup
$newItem["ADUserGroupMembers"] = $ADUserGroupMembers
$newItem["PermLevel"] = $PermLevel
$newItem["ADUser"] = $ADuser
Update the object so it gets saved to the list
$newItem.Update()
19
LETS LOOK AT THE SCRIPT
SP_SiteandLibraryInventoryTemplate.ps1
Basic script that will iterate through all sites, just add actions.
SP_SiteandLibrarySecurityInventory.ps1
This script will also catalog any Library that has unique permission assignments
Utilizes the constructions highlighted
This is one way to structure the code, there are others.
20
THE RESULTS
21
SITE MAP
We can easily get these data points for every site:
• Site Name via the Name property
• URL
• Parent Site Collection
This is not very useful in an environment where you have a lot
of project sites.
22
SITE MAP 2
We add a list and populate it with data at creation:
• Project Sponsor
• Project Manager
• Client
• Executive Summary
Combining this data using powershell into a single list creates
a dynamic and functional site map that the helpdesk,
management and employees can leverage.
This may not fit all use cases.
23
A DIFFERENT USE CASE
Find where a particular lives on web part on pages in
your site
Maybe it is one of the “Fab 40”, maybe just a feature
that you think may no longer be needed.
• Use the structure to iterate through all your sites
• Look for ASPX pages
• Read the data into an object (check textstream)
• Check for the web part GUID
• Write information to a custom object for any site and page that has the web part.
24
VERSIONING SETTINGS
Function GetVersioningSettings{
foreach ($web in (Get-SPSite -Limit All | Get-SPWeb -Limit All)){
foreach ($list in ($web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})){
$Moderation = $list.EnableModeration
$VersioningEnabled= $list.EnableVersioning
$MajorVersionEnabled = $list.EnableMinorVersions
$MajorMinorVersionLimit = $list.MajorWithMinorVersionsLimit
$MajorVersionLimit = $list.MajorVersionLimit
$RequireCheckout = $list.ForceCheckout
$DraftVisibility = $list.DraftVersionVisibility
} #end for each list
$web.Dispose();
} #end for each web
} #end function
25
SITE SIZE
[long]$WebSize = BD-CalculateFolderSize($Web.RootFolder)
foreach($RecycleBinItem in $Web.RecycleBin){
$WebSize += $RecycleBinItem.Size
}
$Size = [Math]::Round($WebSize/1MB, 2)
26
SITE SIZE 2
Function BD-CalculateFolderSize($Folder){
[long]$FolderSize = 0
foreach ($File in $Folder.Files){
#Get File Size
$FolderSize += $file.TotalLength;
#Get the Versions Size
foreach ($FileVersion in $File.Versions){
$FolderSize += $FileVersion.Size
}#end foreach version
}#end foreach file
foreach ($SubFolder in $Folder.SubFolders){
$FolderSize += CalculateFolderSize $SubFolder
}#end foreach subfolder
return $FolderSize
} #end function
27
CONTENT DATABASES
Identify the content databases for a web application:
$ContentDatabases = $webapp.ContentDatabases
Connect to SQL server:
$srv = new-object ('Microsoft.SqlServer.Management.Smo.Server')
$dbinfo = $srv.databases
$selectfields =
@("DatabaseName","Parent","CreateDate","dboLogin","CompatibilityLevel","Encrypti
onEnabled","IsAccessible","ID","Owner","RecoveryModel","LastBackupDate","LastDiff
erentialBackupDate","LastLogBackupDate", "Status", "PrimaryFilePath")
28
CONTENT DATABASES 2
$props = New-Object -TypeName PSCustomObject -Property @{
DatabaseName = $db.Name
Parent = $db.Parent
CreateDate = $db.CreateDate
dboLogin = $db.dboLogin
CompatibilityLevel = $db.CompatibilityLevel
EncryptionEnabled = $db.EncryptionEnabled
ID = $db.ID
Owner = $db.Owner
RecoveryModel = $db.RecoveryModel
LastBackupDate = $db.LastBackupDate
LastDifferentialBackupDate = $db.LastDifferentialBackupDate
LastLogBackupDate = $db.LastLogBackupDate
} | Select-Object $selectfields
$log += $props
} # end foreach db
29
CRAWL INFORMATION
30
$sources = Get-SPEnterpriseSearchServiceApplication | Get-SPEnterpriseSearchCrawlContentSource
$array = @()
$obj = $null
Foreach($i in $sources) {
if($i.fullcrawlschedule) {
$obj = new-object Psobject -prop @{
Source = $i.Name
Status = $i.crawlstatus
Started = $i.crawlstarted
Completed = $i.crawlcompleted
Schedule = ($i | select -expand fullcrawlschedule).description
}
$array += $obj
}
WHAT IS NEXT
Load Data into a SharePoint site
Build dashboards with different views of the data for different audiences
• Helpdesk
• On Call
• Management
31
SOME SUGGESTIONS FOR BEST PRACTICES
Make repeating code into functions
• Use a prefix to readily identify
• I prefix all of my functions with BD-
Use parameters for input values rather than hard coding variables.
Get stuff for free: Use Advanced functions
• Put this line of code as the first none commented line: [cmdletbinding()]
• This gives you a verbose switch which executes write-verbose
• This gives you write-debug as well
Here is a good reference: http://blogs.technet.com/b/heyscriptingguy/archive/2014/05/30/powershell-best-
practices-advanced-functions.aspx
32
RESOURCES
Here are some resources that I rely upon:
Use the get-member command to discover properties of an object. Here is a good
resource: https://technet.microsoft.com/en-us/library/ee176854.aspx
MSDN is the best resource, but it can be hard to find/read. Here is a good starting
point: http://blogs.msdn.com/b/powershell/
One of the best resources is http://powershell.org. This organization is constantly
posting great information. I suggest that you follow them on twitter @PSHOrg.
Follow Don Jones, who is also part of PowerShell.org @ConcentratedDon
The Scripting Guys blog about all things script related, but a large percentage are
powershell related. http://blogs.technet.com/b/heyscriptingguy/
33
FINAL THOUGHTS
The samples will be available for download at the SPSBOS Site.
I don’t have all the answers, so:
• If you improve a script, share it with me!
• If a script triggers a cool idea, share it with me!
One final note, if you use one of these scripts in production please replace my
contact details with yours! I will gladly answer questions, but I really don’t have the
capacity to support another production environment.
34
35
SPS Boston 2015 is made possible
by our Sponsors
37
Thanks for Attending!
How you can reach me:
• Email: mitchell.darrow@gmail.com
• Twitter: @mitchdarrow
• Linkedin: https://www.linkedin.com/pub/mitch-darrow/13/268/8b7

Más contenido relacionado

La actualidad más candente

A Real World Guide to Building Highly Available Fault Tolerant SharePoint Farms
A Real World Guide to Building Highly Available Fault Tolerant SharePoint FarmsA Real World Guide to Building Highly Available Fault Tolerant SharePoint Farms
A Real World Guide to Building Highly Available Fault Tolerant SharePoint FarmsEric Shupps
 
SPTechCon Boston 2015 - Overcoming SharePoint Limitations
SPTechCon Boston 2015 - Overcoming SharePoint LimitationsSPTechCon Boston 2015 - Overcoming SharePoint Limitations
SPTechCon Boston 2015 - Overcoming SharePoint LimitationsMark Rackley
 
Configuring Sakai Newport
Configuring Sakai NewportConfiguring Sakai Newport
Configuring Sakai Newportjiali zhang
 
SharePoint 2010 - User Profile Store
SharePoint 2010 - User Profile Store SharePoint 2010 - User Profile Store
SharePoint 2010 - User Profile Store Joshua Haebets
 
Getting Everything You want Out of SharePoint
Getting Everything You want Out of SharePointGetting Everything You want Out of SharePoint
Getting Everything You want Out of SharePointCorey Burke
 
ECS19 - Laura Kokkarinen - Everything you need to know about SharePoint site ...
ECS19 - Laura Kokkarinen - Everything you need to know about SharePoint site ...ECS19 - Laura Kokkarinen - Everything you need to know about SharePoint site ...
ECS19 - Laura Kokkarinen - Everything you need to know about SharePoint site ...European Collaboration Summit
 
Sps redmond 2014 deck
Sps redmond 2014 deckSps redmond 2014 deck
Sps redmond 2014 deckDorinda Reyes
 
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...SPTechCon
 
Chris McNulty: ECM/WCM Planning, Implementation and Migration Strategies
Chris McNulty: ECM/WCM Planning, Implementation and Migration StrategiesChris McNulty: ECM/WCM Planning, Implementation and Migration Strategies
Chris McNulty: ECM/WCM Planning, Implementation and Migration StrategiesSharePoint Saturday NY
 
Alfresco tech talk live share extensibility metadata and actions for 4.1
Alfresco tech talk live share extensibility metadata and actions for 4.1Alfresco tech talk live share extensibility metadata and actions for 4.1
Alfresco tech talk live share extensibility metadata and actions for 4.1Alfresco Software
 
Understanding SharePoint site structure what's inside
Understanding SharePoint site structure  what's insideUnderstanding SharePoint site structure  what's inside
Understanding SharePoint site structure what's insideBenjamin Niaulin
 
Configuring Sakai Boston09
Configuring Sakai Boston09Configuring Sakai Boston09
Configuring Sakai Boston09jleasiaum
 
Clockwork 2013 - SharePoint overview
Clockwork 2013 - SharePoint overviewClockwork 2013 - SharePoint overview
Clockwork 2013 - SharePoint overviewWilco Sinnema
 
Architectural changes in SharePoint 2013
Architectural changes in SharePoint 2013Architectural changes in SharePoint 2013
Architectural changes in SharePoint 2013Shai Petel
 
Avoiding 10 common SharePoint Administration mistakes
Avoiding 10 common SharePoint Administration mistakesAvoiding 10 common SharePoint Administration mistakes
Avoiding 10 common SharePoint Administration mistakesBenjamin Athawes
 
Monitoring and Maintaining SharePoint 2013 Server
Monitoring and Maintaining SharePoint 2013 ServerMonitoring and Maintaining SharePoint 2013 Server
Monitoring and Maintaining SharePoint 2013 ServerLearning SharePoint
 
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshopIntroduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshopMichael Blumenthal (Microsoft MVP)
 
Build a Search Driven Site-Understanding Cross-Site Publishing
Build a Search Driven Site-Understanding Cross-Site PublishingBuild a Search Driven Site-Understanding Cross-Site Publishing
Build a Search Driven Site-Understanding Cross-Site PublishingSPC Adriatics
 

La actualidad más candente (20)

A Real World Guide to Building Highly Available Fault Tolerant SharePoint Farms
A Real World Guide to Building Highly Available Fault Tolerant SharePoint FarmsA Real World Guide to Building Highly Available Fault Tolerant SharePoint Farms
A Real World Guide to Building Highly Available Fault Tolerant SharePoint Farms
 
Share point 2010
Share point 2010Share point 2010
Share point 2010
 
Ron
RonRon
Ron
 
SPTechCon Boston 2015 - Overcoming SharePoint Limitations
SPTechCon Boston 2015 - Overcoming SharePoint LimitationsSPTechCon Boston 2015 - Overcoming SharePoint Limitations
SPTechCon Boston 2015 - Overcoming SharePoint Limitations
 
Configuring Sakai Newport
Configuring Sakai NewportConfiguring Sakai Newport
Configuring Sakai Newport
 
SharePoint 2010 - User Profile Store
SharePoint 2010 - User Profile Store SharePoint 2010 - User Profile Store
SharePoint 2010 - User Profile Store
 
Getting Everything You want Out of SharePoint
Getting Everything You want Out of SharePointGetting Everything You want Out of SharePoint
Getting Everything You want Out of SharePoint
 
ECS19 - Laura Kokkarinen - Everything you need to know about SharePoint site ...
ECS19 - Laura Kokkarinen - Everything you need to know about SharePoint site ...ECS19 - Laura Kokkarinen - Everything you need to know about SharePoint site ...
ECS19 - Laura Kokkarinen - Everything you need to know about SharePoint site ...
 
Sps redmond 2014 deck
Sps redmond 2014 deckSps redmond 2014 deck
Sps redmond 2014 deck
 
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
 
Chris McNulty: ECM/WCM Planning, Implementation and Migration Strategies
Chris McNulty: ECM/WCM Planning, Implementation and Migration StrategiesChris McNulty: ECM/WCM Planning, Implementation and Migration Strategies
Chris McNulty: ECM/WCM Planning, Implementation and Migration Strategies
 
Alfresco tech talk live share extensibility metadata and actions for 4.1
Alfresco tech talk live share extensibility metadata and actions for 4.1Alfresco tech talk live share extensibility metadata and actions for 4.1
Alfresco tech talk live share extensibility metadata and actions for 4.1
 
Understanding SharePoint site structure what's inside
Understanding SharePoint site structure  what's insideUnderstanding SharePoint site structure  what's inside
Understanding SharePoint site structure what's inside
 
Configuring Sakai Boston09
Configuring Sakai Boston09Configuring Sakai Boston09
Configuring Sakai Boston09
 
Clockwork 2013 - SharePoint overview
Clockwork 2013 - SharePoint overviewClockwork 2013 - SharePoint overview
Clockwork 2013 - SharePoint overview
 
Architectural changes in SharePoint 2013
Architectural changes in SharePoint 2013Architectural changes in SharePoint 2013
Architectural changes in SharePoint 2013
 
Avoiding 10 common SharePoint Administration mistakes
Avoiding 10 common SharePoint Administration mistakesAvoiding 10 common SharePoint Administration mistakes
Avoiding 10 common SharePoint Administration mistakes
 
Monitoring and Maintaining SharePoint 2013 Server
Monitoring and Maintaining SharePoint 2013 ServerMonitoring and Maintaining SharePoint 2013 Server
Monitoring and Maintaining SharePoint 2013 Server
 
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshopIntroduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
 
Build a Search Driven Site-Understanding Cross-Site Publishing
Build a Search Driven Site-Understanding Cross-Site PublishingBuild a Search Driven Site-Understanding Cross-Site Publishing
Build a Search Driven Site-Understanding Cross-Site Publishing
 

Similar a Gain Control of SharePoint Management with PowerShell

New World Of SharePoint 2010 Administration Oleson
New World Of SharePoint 2010 Administration OlesonNew World Of SharePoint 2010 Administration Oleson
New World Of SharePoint 2010 Administration OlesonJoel Oleson
 
Give Your SharePoint Site a Physical
Give Your SharePoint Site a PhysicalGive Your SharePoint Site a Physical
Give Your SharePoint Site a PhysicalAscendum Solutions
 
SharePoint Object Model, Web Services and Events
SharePoint Object Model, Web Services and EventsSharePoint Object Model, Web Services and Events
SharePoint Object Model, Web Services and EventsMohan Arumugam
 
Basics of SharePoint
Basics of SharePointBasics of SharePoint
Basics of SharePointsamirsangli
 
AZMS PRESENTATION.pptx
AZMS PRESENTATION.pptxAZMS PRESENTATION.pptx
AZMS PRESENTATION.pptxSonuShaw16
 
SharePoint 2010 Application Development Overview
SharePoint 2010 Application Development OverviewSharePoint 2010 Application Development Overview
SharePoint 2010 Application Development OverviewRob Windsor
 
The SharePoint & jQuery Guide - Updated 1/14/14
The SharePoint & jQuery Guide - Updated 1/14/14The SharePoint & jQuery Guide - Updated 1/14/14
The SharePoint & jQuery Guide - Updated 1/14/14Mark Rackley
 
SharePoint 2016 Adoption - Lessons Learned and Advanced Troubleshooting
SharePoint 2016 Adoption - Lessons Learned and Advanced TroubleshootingSharePoint 2016 Adoption - Lessons Learned and Advanced Troubleshooting
SharePoint 2016 Adoption - Lessons Learned and Advanced TroubleshootingJohn Calvert
 
Sps Boston The Share Point Beast
Sps Boston   The Share Point BeastSps Boston   The Share Point Beast
Sps Boston The Share Point Beastgueste918732
 
The SharePoint & jQuery Guide
The SharePoint & jQuery GuideThe SharePoint & jQuery Guide
The SharePoint & jQuery GuideMark Rackley
 
The SharePoint and jQuery Guide by Mark Rackley - SPTechCon
The SharePoint and jQuery Guide by Mark Rackley - SPTechConThe SharePoint and jQuery Guide by Mark Rackley - SPTechCon
The SharePoint and jQuery Guide by Mark Rackley - SPTechConSPTechCon
 
Teched Middle East New World of SharePoint 2010 Administration with Joel Oles...
Teched Middle East New World of SharePoint 2010 Administration with Joel Oles...Teched Middle East New World of SharePoint 2010 Administration with Joel Oles...
Teched Middle East New World of SharePoint 2010 Administration with Joel Oles...Joel Oleson
 
Best Practices to SharePoint Architecture Fundamentals NZ & AUS
Best Practices to SharePoint Architecture Fundamentals NZ & AUSBest Practices to SharePoint Architecture Fundamentals NZ & AUS
Best Practices to SharePoint Architecture Fundamentals NZ & AUSguest7c2e070
 
What's new in SharePoint 2010 for Backup and Recovery - SP Saturday Copenhagen
What's new in SharePoint 2010 for Backup and Recovery - SP Saturday CopenhagenWhat's new in SharePoint 2010 for Backup and Recovery - SP Saturday Copenhagen
What's new in SharePoint 2010 for Backup and Recovery - SP Saturday CopenhagenIlia Sotnikov
 
Unlocking the Value of Your Data Lake
Unlocking the Value of Your Data LakeUnlocking the Value of Your Data Lake
Unlocking the Value of Your Data LakeDATAVERSITY
 
Enhance Your Flask Web Project With a Database Python Guide.pdf
Enhance Your Flask Web Project With a Database  Python Guide.pdfEnhance Your Flask Web Project With a Database  Python Guide.pdf
Enhance Your Flask Web Project With a Database Python Guide.pdfInexture Solutions
 
FAST for SharePoint Deep Dive
FAST for SharePoint Deep DiveFAST for SharePoint Deep Dive
FAST for SharePoint Deep Diveneil_richards
 

Similar a Gain Control of SharePoint Management with PowerShell (20)

New World Of SharePoint 2010 Administration Oleson
New World Of SharePoint 2010 Administration OlesonNew World Of SharePoint 2010 Administration Oleson
New World Of SharePoint 2010 Administration Oleson
 
Give Your SharePoint Site a Physical
Give Your SharePoint Site a PhysicalGive Your SharePoint Site a Physical
Give Your SharePoint Site a Physical
 
Cqrs api v2
Cqrs api v2Cqrs api v2
Cqrs api v2
 
SharePoint Object Model, Web Services and Events
SharePoint Object Model, Web Services and EventsSharePoint Object Model, Web Services and Events
SharePoint Object Model, Web Services and Events
 
Basics of SharePoint
Basics of SharePointBasics of SharePoint
Basics of SharePoint
 
AZMS PRESENTATION.pptx
AZMS PRESENTATION.pptxAZMS PRESENTATION.pptx
AZMS PRESENTATION.pptx
 
SharePoint 2010 Application Development Overview
SharePoint 2010 Application Development OverviewSharePoint 2010 Application Development Overview
SharePoint 2010 Application Development Overview
 
The SharePoint & jQuery Guide - Updated 1/14/14
The SharePoint & jQuery Guide - Updated 1/14/14The SharePoint & jQuery Guide - Updated 1/14/14
The SharePoint & jQuery Guide - Updated 1/14/14
 
SharePoint 2016 Adoption - Lessons Learned and Advanced Troubleshooting
SharePoint 2016 Adoption - Lessons Learned and Advanced TroubleshootingSharePoint 2016 Adoption - Lessons Learned and Advanced Troubleshooting
SharePoint 2016 Adoption - Lessons Learned and Advanced Troubleshooting
 
Sps Boston The Share Point Beast
Sps Boston   The Share Point BeastSps Boston   The Share Point Beast
Sps Boston The Share Point Beast
 
Salesforce connect
Salesforce connectSalesforce connect
Salesforce connect
 
The SharePoint & jQuery Guide
The SharePoint & jQuery GuideThe SharePoint & jQuery Guide
The SharePoint & jQuery Guide
 
The SharePoint and jQuery Guide by Mark Rackley - SPTechCon
The SharePoint and jQuery Guide by Mark Rackley - SPTechConThe SharePoint and jQuery Guide by Mark Rackley - SPTechCon
The SharePoint and jQuery Guide by Mark Rackley - SPTechCon
 
Mstr meetup
Mstr meetupMstr meetup
Mstr meetup
 
Teched Middle East New World of SharePoint 2010 Administration with Joel Oles...
Teched Middle East New World of SharePoint 2010 Administration with Joel Oles...Teched Middle East New World of SharePoint 2010 Administration with Joel Oles...
Teched Middle East New World of SharePoint 2010 Administration with Joel Oles...
 
Best Practices to SharePoint Architecture Fundamentals NZ & AUS
Best Practices to SharePoint Architecture Fundamentals NZ & AUSBest Practices to SharePoint Architecture Fundamentals NZ & AUS
Best Practices to SharePoint Architecture Fundamentals NZ & AUS
 
What's new in SharePoint 2010 for Backup and Recovery - SP Saturday Copenhagen
What's new in SharePoint 2010 for Backup and Recovery - SP Saturday CopenhagenWhat's new in SharePoint 2010 for Backup and Recovery - SP Saturday Copenhagen
What's new in SharePoint 2010 for Backup and Recovery - SP Saturday Copenhagen
 
Unlocking the Value of Your Data Lake
Unlocking the Value of Your Data LakeUnlocking the Value of Your Data Lake
Unlocking the Value of Your Data Lake
 
Enhance Your Flask Web Project With a Database Python Guide.pdf
Enhance Your Flask Web Project With a Database  Python Guide.pdfEnhance Your Flask Web Project With a Database  Python Guide.pdf
Enhance Your Flask Web Project With a Database Python Guide.pdf
 
FAST for SharePoint Deep Dive
FAST for SharePoint Deep DiveFAST for SharePoint Deep Dive
FAST for SharePoint Deep Dive
 

Más de Mitch Darrow

Cathedralite June 12 1980
Cathedralite June 12 1980Cathedralite June 12 1980
Cathedralite June 12 1980Mitch Darrow
 
Cathedralite December 1980
Cathedralite December 1980Cathedralite December 1980
Cathedralite December 1980Mitch Darrow
 
Class of 1981 Commencement Program
Class of 1981 Commencement ProgramClass of 1981 Commencement Program
Class of 1981 Commencement ProgramMitch Darrow
 
Cathedralite June1981
Cathedralite June1981Cathedralite June1981
Cathedralite June1981Mitch Darrow
 
Northwest Argentina: Humahauca
Northwest Argentina: HumahaucaNorthwest Argentina: Humahauca
Northwest Argentina: HumahaucaMitch Darrow
 

Más de Mitch Darrow (6)

Cathedralite June 12 1980
Cathedralite June 12 1980Cathedralite June 12 1980
Cathedralite June 12 1980
 
Cathedralite December 1980
Cathedralite December 1980Cathedralite December 1980
Cathedralite December 1980
 
Class of 1981 Commencement Program
Class of 1981 Commencement ProgramClass of 1981 Commencement Program
Class of 1981 Commencement Program
 
Cathedralite June1981
Cathedralite June1981Cathedralite June1981
Cathedralite June1981
 
Northwest Argentina: Humahauca
Northwest Argentina: HumahaucaNorthwest Argentina: Humahauca
Northwest Argentina: Humahauca
 
The Moving Men
The Moving MenThe Moving Men
The Moving Men
 

Último

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 

Gain Control of SharePoint Management with PowerShell

  • 1. berrydunn.com | GAIN CONTROL USING POWERSHELL TO IMPROVE SHAREPOINT MANAGEMENT SharePoint Saturday Boston June 13, 2015 Mitch Darrow, Senior Consultant
  • 2. 2 • Public accounting and management/IT consulting firm • Founded in 1974, the firm now has over 250 personnel and 36 principals • $50 million in annual revenue • For the last four years, BerryDunn was designated as an INSIDE Public Accounting (IPA) “Top 100 Firm,” and was also named as a “Fastest-Growing” firm. • Named “Best CPA Firm for Women” by the American Society of Women Accountants and the American Woman’s Society of Certified Public Accountants. BerryDunn Overview Legend Office Locations Satellite Office Locations
  • 3. 3 INDEPENDENCE AND OBJECTIVITY We do not sell or develop hardware or software. We do not partner with software developers or solution providers. Independence allows our team to provide objective IT consulting services and to offer recommendations that represent only the client’s best interests.
  • 4. 4 MITCH DARROW SENIOR CONSULTANT GOVERNMENT CONSULTING GROUP Over 25 years of IT experience in global manufacturing companies. Specializing in: • Windows Architecture • Security Best Practices • Databases • SharePoint • Exchange • Programming ( C#, PowerShell) Representative clients • Colorado DHS • Washington State Auditors Office • West Virginia Bureau of Medical Services
  • 5. 5 MITCH DARROW About me Husband and father of three Live in the Portland, Maine area Avid Kayaker, hopefully soon to be a Maine guide Bike commuter Volunteer IT Geek
  • 6. 6 GAP YEAR ADVOCATE All three of my kids have had an adventure before starting University. Ask me about it after the presentation, if you are interested!
  • 7. 7 WHAT ARE THE CHALLENGES? Important information is everywhere • Central Administration • Site Collection • Sites • SQL Management Studio How do we get the information into the hands of those who need it? Helpdesk IT On Call Managers Business Users
  • 8. POWERSHELL CAN HELP! Read information from almost anywhere in SharePoint Read information from SQL Server Read data from Active Directory Write all this data into a SharePoint Site Create Ops dashboard Management dashboard All using the same toolkit! 8
  • 9. SOME PREREQUISITES User context running the script needs permissions: Add-SPShellAdmin Adds user to: • SharePoint_Shell_Access Role • WSS_ADMIN_WPG group on the local computer Add-SPShellAdmin -UserName CONTOSOUser1 -database 4251d855-3c15-4501-8dd1-98f960359fa6 Additional information: https://technet.microsoft.com/en-us/library/ff607596.aspx 9
  • 10. BEFORE WE BEGIN Please don’t develop and/or test in Production! If you don’t understand what a script is doing, you probably shouldn’t be running it! PowerShell allows you to structure logic in dramatically different ways. All are correct, but they are not all equal. Don’t assume that one structure is better than another. If performance is important, measure it with measure-command{}. Error handling (Try/Catch) is always a best practice. I acknowledge this is absent from my sample code. 10
  • 11. THE BASICS: Add the snap in to PowerShell Add-PSSnapIn Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue Create an array of all the web application objects: $webApps = Get-SPWebApplication http://intranet.contoso.com foreach($webApp in $webApps) { } 11
  • 12. THE BASICS CONTINUED: Looping through all the site collections in the web application: foreach($site in $webApp.Sites){ } Looping through all of the sites in each site collection: foreach($web in $site.AllWebs) { } 12
  • 13. SO, WHAT KINDS OF INFORMATION CAN WE COLLECT? Inventory the names and URLs of all sites in the farm Inventory Crawl information for the farm Last status & Duration Number of items crawled Get all Role Assignments and Permission levels Expand SharePoint groups Expand AD groups 13
  • 14. SO, WHAT KINDS OF INFORMATION CAN WE COLLECT? Get content database associated with site collection database growth settings database sizes backup mode full/differential/log backup statuses Inventory list versioning settings Site size Site last updated 14
  • 15. USERS AND PERMISSIONS OVERVIEW SharePoint Site Permissions can be messy Role Assignments can be SharePoint Groups AD Groups User Objects SharePoint Groups can contain users or AD groups AD groups can contain users and other groups 15
  • 16. USERS AND PERMISSIONS Check if the site has unique permissions of inherits: if($web.HasUniqueRoleAssignments -eq $false) { } If permissions are unique: foreach($assignment in $web.RoleAssignments){ } Check if the member string is empty or not: if(-not [string]::IsNullOrEmpty($assignment.Member.Xml)) { } Check if the xml starts with a group tag: if($assignment.Member.XML.StartsWith('<Group') -eq "True") { } 16
  • 17. USERS AND PERMISSIONS 2 Check if the xml starts with a group tag: if($assignment.Member.XML.StartsWith('<Group') -eq "True") { } Get the members of the SharePoint group: foreach($SPGroupMember in $assignment.Member.Users) { } Check to see if the IsDomainGroup property for the member is true: if($SPGroupMember.IsDomainGroup) { } 17
  • 18. WRITING DATA TO SHAREPOINT #Get the SPWeb object and save it to a variable $web = Get-SPWeb $webURL #Get the List object to retrieve the "Demo List" $list = $web.Lists[$listName] #Create a new item $newItem = $list.Items.Add() 18
  • 19. WRITING DATA TO SHAREPOINT 2 Add data to this list item $newItem["SiteURL"] = $SiteURL $newItem["InheritsPerms"] = $InheritsPerms $newItem["SPGroup"] = $SPGroup $newItem["ADGroup"] = $ADGroup $newItem["ADUserGroupMembers"] = $ADUserGroupMembers $newItem["PermLevel"] = $PermLevel $newItem["ADUser"] = $ADuser Update the object so it gets saved to the list $newItem.Update() 19
  • 20. LETS LOOK AT THE SCRIPT SP_SiteandLibraryInventoryTemplate.ps1 Basic script that will iterate through all sites, just add actions. SP_SiteandLibrarySecurityInventory.ps1 This script will also catalog any Library that has unique permission assignments Utilizes the constructions highlighted This is one way to structure the code, there are others. 20
  • 22. SITE MAP We can easily get these data points for every site: • Site Name via the Name property • URL • Parent Site Collection This is not very useful in an environment where you have a lot of project sites. 22
  • 23. SITE MAP 2 We add a list and populate it with data at creation: • Project Sponsor • Project Manager • Client • Executive Summary Combining this data using powershell into a single list creates a dynamic and functional site map that the helpdesk, management and employees can leverage. This may not fit all use cases. 23
  • 24. A DIFFERENT USE CASE Find where a particular lives on web part on pages in your site Maybe it is one of the “Fab 40”, maybe just a feature that you think may no longer be needed. • Use the structure to iterate through all your sites • Look for ASPX pages • Read the data into an object (check textstream) • Check for the web part GUID • Write information to a custom object for any site and page that has the web part. 24
  • 25. VERSIONING SETTINGS Function GetVersioningSettings{ foreach ($web in (Get-SPSite -Limit All | Get-SPWeb -Limit All)){ foreach ($list in ($web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})){ $Moderation = $list.EnableModeration $VersioningEnabled= $list.EnableVersioning $MajorVersionEnabled = $list.EnableMinorVersions $MajorMinorVersionLimit = $list.MajorWithMinorVersionsLimit $MajorVersionLimit = $list.MajorVersionLimit $RequireCheckout = $list.ForceCheckout $DraftVisibility = $list.DraftVersionVisibility } #end for each list $web.Dispose(); } #end for each web } #end function 25
  • 26. SITE SIZE [long]$WebSize = BD-CalculateFolderSize($Web.RootFolder) foreach($RecycleBinItem in $Web.RecycleBin){ $WebSize += $RecycleBinItem.Size } $Size = [Math]::Round($WebSize/1MB, 2) 26
  • 27. SITE SIZE 2 Function BD-CalculateFolderSize($Folder){ [long]$FolderSize = 0 foreach ($File in $Folder.Files){ #Get File Size $FolderSize += $file.TotalLength; #Get the Versions Size foreach ($FileVersion in $File.Versions){ $FolderSize += $FileVersion.Size }#end foreach version }#end foreach file foreach ($SubFolder in $Folder.SubFolders){ $FolderSize += CalculateFolderSize $SubFolder }#end foreach subfolder return $FolderSize } #end function 27
  • 28. CONTENT DATABASES Identify the content databases for a web application: $ContentDatabases = $webapp.ContentDatabases Connect to SQL server: $srv = new-object ('Microsoft.SqlServer.Management.Smo.Server') $dbinfo = $srv.databases $selectfields = @("DatabaseName","Parent","CreateDate","dboLogin","CompatibilityLevel","Encrypti onEnabled","IsAccessible","ID","Owner","RecoveryModel","LastBackupDate","LastDiff erentialBackupDate","LastLogBackupDate", "Status", "PrimaryFilePath") 28
  • 29. CONTENT DATABASES 2 $props = New-Object -TypeName PSCustomObject -Property @{ DatabaseName = $db.Name Parent = $db.Parent CreateDate = $db.CreateDate dboLogin = $db.dboLogin CompatibilityLevel = $db.CompatibilityLevel EncryptionEnabled = $db.EncryptionEnabled ID = $db.ID Owner = $db.Owner RecoveryModel = $db.RecoveryModel LastBackupDate = $db.LastBackupDate LastDifferentialBackupDate = $db.LastDifferentialBackupDate LastLogBackupDate = $db.LastLogBackupDate } | Select-Object $selectfields $log += $props } # end foreach db 29
  • 30. CRAWL INFORMATION 30 $sources = Get-SPEnterpriseSearchServiceApplication | Get-SPEnterpriseSearchCrawlContentSource $array = @() $obj = $null Foreach($i in $sources) { if($i.fullcrawlschedule) { $obj = new-object Psobject -prop @{ Source = $i.Name Status = $i.crawlstatus Started = $i.crawlstarted Completed = $i.crawlcompleted Schedule = ($i | select -expand fullcrawlschedule).description } $array += $obj }
  • 31. WHAT IS NEXT Load Data into a SharePoint site Build dashboards with different views of the data for different audiences • Helpdesk • On Call • Management 31
  • 32. SOME SUGGESTIONS FOR BEST PRACTICES Make repeating code into functions • Use a prefix to readily identify • I prefix all of my functions with BD- Use parameters for input values rather than hard coding variables. Get stuff for free: Use Advanced functions • Put this line of code as the first none commented line: [cmdletbinding()] • This gives you a verbose switch which executes write-verbose • This gives you write-debug as well Here is a good reference: http://blogs.technet.com/b/heyscriptingguy/archive/2014/05/30/powershell-best- practices-advanced-functions.aspx 32
  • 33. RESOURCES Here are some resources that I rely upon: Use the get-member command to discover properties of an object. Here is a good resource: https://technet.microsoft.com/en-us/library/ee176854.aspx MSDN is the best resource, but it can be hard to find/read. Here is a good starting point: http://blogs.msdn.com/b/powershell/ One of the best resources is http://powershell.org. This organization is constantly posting great information. I suggest that you follow them on twitter @PSHOrg. Follow Don Jones, who is also part of PowerShell.org @ConcentratedDon The Scripting Guys blog about all things script related, but a large percentage are powershell related. http://blogs.technet.com/b/heyscriptingguy/ 33
  • 34. FINAL THOUGHTS The samples will be available for download at the SPSBOS Site. I don’t have all the answers, so: • If you improve a script, share it with me! • If a script triggers a cool idea, share it with me! One final note, if you use one of these scripts in production please replace my contact details with yours! I will gladly answer questions, but I really don’t have the capacity to support another production environment. 34
  • 35. 35
  • 36. SPS Boston 2015 is made possible by our Sponsors
  • 37. 37 Thanks for Attending! How you can reach me: • Email: mitchell.darrow@gmail.com • Twitter: @mitchdarrow • Linkedin: https://www.linkedin.com/pub/mitch-darrow/13/268/8b7

Notas del editor

  1. Some info is in Central Admin, some in Site Collection Administration, some in Site Administration, some in SQL