Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

4/14/2015

PowerShell: Collection was modified; enumeration operation may not execute

 

While the following example is for PowerShell, the same applies to C# code.

Collections that are being modified do not like to be processed with FOR EACH.
"Collection was modified; enumeration operation may not execute"

For example:

$web = Get-SPWeb someurl...

ForEach($list in $w.Lists)
{
  if (!$list.Hidden)
  {
    # do something to change the list
    # like add a new view...

    $list.Views.Add(.......)
    # error! 
    # "Collection was modified; enumeration operation may not execute..."
  }
 }
$web.Dispose()

 

The Fix

Change the FOR EACH to a FOR.

change:

  foreach($l in $web.Lists)
     {

to:

   for ($i=0; $i -lt $web.lists.count; $i++)
     {
        $l = $w.lists[$i]

 

And if you are deleting items in the collection…

Walk the collection in reverse order!

   for ($i=$web.lists.count-1; $i –gt 0; $i--)
     {
        $l = $web.lists[$i]

.

4/08/2015

Setting a SharePoint Group's Description Using PowerShell

 

The SharePoint Group object has a property named "Description", but it appears to be ignored. When you edit a group in the browser there is no "Description" field, but there is one named "About Me" that is a rich text field. Turns out there's a few secrets you need to know to set this seemly simple little property.

Secret #1: Many of the group's properties are stored in another object, the SPWeb.SiteUserInfoList object.

Secret #2: The internal name of "About Me" is "Notes".

The PowerShell:

#create the group as usual and then retrieve it...
$web = $site.RootWeb;
$group = $web.SiteGroups["Test Group with HTML desc"];

#find the group's SiteUserInfoList info...
$groupInfo = $web.SiteUserInfoList.GetItemById($group.id);

#update the text...
$groupInfo["Notes"] = "<div>This is <strong>bold</strong> and this is <em>italics</em></div>";

#and save it...
$groupInfo.Update();

 

For a C# example see the answer in this discussion: http://stackoverflow.com/questions/968819/change-description-of-a-sharepoint-group

 

.

4/07/2015

PowerShell: Finding all SharePoint Lists with Lookup Columns

 

Did you ever want to find all of the columns of a certain type? All Lookups, all Calculated or all Managed Metadata columns? All you have to do is look at the Fields object "TypeDisplayName" property. While the example script below is looking for Lookup columns, you could modify it to look for any kind of column.

 

Find all Lookup Columns

This will find all Lookup columns in the entire farm!

Notes:

  • Many of the out of the box lists are "custom" lists and will have fields that look like user added columns. Exclude those with the $TTNExcludeLists variable.
  • Field that are Hidden or FromBaseType are not typically user created and are excluded in this example.
$TTNExcludeLists = "Solution Gallery", 
                "Workflow Tasks", 
                "Master Page Gallery"

Get-SPSite -Limit All | Get-SPWeb -Limit All | 
  Select -ExpandProperty Lists | 
  Where { -Not ($TTNExcludeLists -Contains $_.Title) } | 
  Select -ExpandProperty Fields | 
  Where { $_.TypeDisplayName -eq "Lookup" -and 
          $_.Hidden -eq $false -and 
          $_.FromBaseType -eq $false } | 
  Select {$_.ParentList.ParentWebUrl}, 
         {$_.ParentList}, 
         Title

 

TypeDisplayName

If you would like to see the list of all of the column types used in your site or farm you can run a script like this:

Get-SPWeb "http://yourServer/sites/YourSite" |
  Select -ExpandProperty Lists | 
  Select -ExpandProperty Fields |
  Select TypeDisplayName –Unique |

Sort

It may take a long time to run (WARNING!) but this will list all of the columns in the farm:

Get-SPSite -Limit All | Get-SPWeb -Limit All | 
  Select -ExpandProperty Lists | 
  Select -ExpandProperty Fields |
  Select TypeDisplayName -Unique|
Sort TypeDisplayName

 

Here's the list I got from my test farm:

TypeDisplayName
---------------
All Day Event
Attachments
Audience Targeting
Calculated
Channel Alias
Check Double Booking
Choice
Computed
Content Type Id
Content Type ID
Counter
Cross Project Link
Date and Time
Event Type
File
Free/Busy
Guid
Hold Status
Hyperlink or Picture
Integer
Lookup
Managed Metadata
Moderation Status
Multiple lines of text
Number
Number of Likes
Number of Ratings
Out of Policy
Outcome choice
Page Separator
Permission Level
Person or Group
Publishing HTML
Publishing Image
Publishing Schedule End Date
Publishing Schedule Start Date
Rating (0-5)
Recurrence
Related Items
Resources
Single line of text
Summary Links
ThreadIndex
User Agent Substrings
Variations
Yes/No

 

.

2/22/2015

Working with Quick Launch from PowerShell

 

The following will work with both SharePoint 2010 and 2013. It will also work with SharePoint 2007 if you "manually" create the SPWeb object.

The basic steps to add a new link to Quick Launch:

  1. Get the SPWeb object for your site.
  2. Get the SPWeb.Navigation.QuickLaunch object.
  3. Create a new node .
  4. Add the new node to an existing node (like "Lists" or "Libraries") or the root of Quick Launch.
  5. Done… No need to call Update() on anything!

Note: This will work with publishing sites as long as you are not using Managed Metadata Navigation.

 

Get your web object and the QuickLaunch object:

$web = Get-SPWeb http://yourServer/sites/yourSite
$quicklaunch = $web.Navigation.QuickLaunch

You can explore your existing Quick Launch from here. Just type $quicklaunch and press enter to see your headings / top level nodes. Type $quicklaunch | where {$_.title -eq "Lists"} to see the links in one of the headings. You could even list all of the headings and their children with this one: $quicklaunch | select -ExpandProperty Children | Select {$_.Parent.Title}, {$_.Title}.

 

Create a new node object:

Each item added to Quick Launch is an SPNavigationNode object. It has three parameters: the text to display, the URL to the linked resource and $true if the link is external to SharePoint or $false if the link is internal to SharePoint. It appears that the $true/$false in the third parameter is used to see if the URL is validated as a real SharePoint URL or not. I could still add SharePoint links by leaving it as $true.

Example for a SharePoint link: (note the $false)

$navnode = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode("Get help!", "/sites/helpsite", $false)

Example for Bing or link external to SharePoint:

$navnode = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode("Bing", http://www.bing.com, $true)

Example for JavaScript:

$navnode = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode("Say Hello!", "javascript:alert('hello')", $true)

Example for JavaScript to open a new dialog box:
(Note the "`" in front of the "$" is needed because "$" means something special in PowerShell. (a variable follows))

$navnode = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode("Add a new task", "JavaScript:var options=SP.UI.`$create_DialogOptions();options.url='/sites/Publishing/Lists/Tasks/NewForm.aspx?RootFolder=&IsDlg=1';options.height = 400;void(SP.UI.ModalDialog.showModalDialog(options))", $true)

For more on JavaScript in Quick Launch see SharePoint: JavaScript in Quick Launch and Top Link Bar! and SharePoint: Opening a 2010 Dialog Box from Quick Launch.

 

Add the node to Quick Launch

To add the new node as a "heading" just add it to the Quick Launch object:

$quicklaunch.AddAsFirst($navnode)             or .AddAsLast

To add the new node as a child of a "heading" then use Where to find that heading:

$heading = $quicklaunch | where {$_.title -eq "Lists"}
$heading.Children.AddAsLast($navnode)

To add the new node after an existing node (i.e. not as First or Last) you will need to retrieve the existing node and then use the .Add method.

$existingLink = $heading.Children | where {$_.title -eq "Search the web with Bing"}

$navnode = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode("Search the web with Google", "http://www.google.com", $true)

$heading.Children.Add($navnode,$existingLink)

 

Delete a link?

Sure… Just retrieve the node and then call Delete.

$heading | Select -ExpandProperty Children | where { $_.Title -eq "Tasks" } | ForEach { $_.Delete() }

If you know that there's exactly one node that matches the Where test then you can shorten it to this:

($heading | Select -ExpandProperty Children | where { $_.Title -eq "Goog
le" }).Delete()

 

Bulk updates?

Sure… with extreme caution!  Danger! Will Robinson! Danger! Do the following at your own risk. No liability assumed, batteries not included!

Here's an example to add a Help link to every site in a site collection or to all site collections in the entire farm. (You way want to filter out the My Sites and the publishing sites!)

First confirm what you are about to change!

Get-SPSite http://sharepoint/sites/training | Get-SPWeb -Limit All | Select URL, Title
  
or
Get-SPSite -Limit All | Get-SPWeb -Limit All | Select URL, Title

Create the new link / node.

$navnode = New-Object Microsoft.SharePoint.Navigation.SPNavigationNode("HELP!", "http://yourServer/sites/yourHelpSite", $true)

Now add it to every site in a site collection!

Get-SPSite http://sharepoint/sites/training | Get-SPWeb -Limit All | ForEach { $_.Navigation.QuickLaunch.AddAsFirst($navnode) }

or for all site collections in the farm:

Get-SPSite -Limit All | Get-SPWeb -Limit All | ForEach { $_.Navigation.QuickLaunch.AddAsFirst($navnode) }

 

And if you want to delete all of those helpful links?

Get-SPSite http://sharepoint/sites/training | Get-SPWeb -Limit All | ForEach { ($_.Navigation.QuickLaunch | where {$_.Title -eq "Help!"}).Delete()  }

 

What about a Publishing Site?

Publishing Sites use the "Navigation" editor for links and it does not permit "URLs" that don't begin with "http". This means that you cannot add JavaScript to a Quick Launch link using that editor. For SharePoint 2010 you can use the workaround here, or for 2010 and 2013 you can use the PowerShell above. (PowerShell to the rescue!) For more on JavaScript in Quick Launch see SharePoint: JavaScript in Quick Launch and Top Link Bar! and SharePoint: Opening a 2010 Dialog Box from Quick Launch.

The PowerShell above will work as long as in your Navigation settings you have not selected "Managed Navigation" or "same as parent".

image

 

References:

MSDN's article showing C# examples: (This is for 2010 but applies to 2007-2013.)

https://msdn.microsoft.com/en-us/library/office/ms427791(v=office.14).aspx

1/29/2015

PowerShell Sorting Tip for Enumerations

 

Do you ever have a PowerShell script that just won't sort right?

The problem? PowerShell makes assumptions, and not always the ones you would make. For example let's get a list of SharePoint lists and sort them by their BaseTemplate property:

    $mtg = Get-SPWeb http://maxsp2013wfe/sites/Meetings
    $mtg.Lists | Sort BaseTemplate | Select BaseTemplate, Title

Is the result you would expect?

image

Not what I first expected… but there's a hint hiding there though… Why is the BaseTemplate column right aligned as if was numeric?

If we take the above script and pipe it to Get-Member we find that BaseTemplate is not a string! It's an object of some kind. It's an SPListTemplateType object!

image

So let's see what that is… Doing a Bing on Microsoft.SharePoint.SPListTemplateType reveals that it is an enumeration, which internally is a number. If you look at the list in the MSDN article you will see both the text and numeric values of the base types.

image

What we need is the display text for the enumeration, and we can get that by using the ToString() method. As that would then be an expression, we need to add the annoying curly brackets and the $_. notation.

    $mtg.Lists | Sort { $_.BaseTemplate.ToString() } | Select BaseTemplate, Title

And now we get:

image

And that's more like it! (except for the right align stuff that going on)

Convert the column in the Select to a string and all's well!

    $mtg.Lists | Sort {$_.BaseTemplate.ToString()} | Select {$_.BaseTemplate.ToString()}, Title

image

 

So what were the PowerShell assumptions?

  1. To display the text value of the enumeration, and align it as a number.
  2. To sort on the numeric value of the enumeration.

(And you know what "assume" does, right?)  Smile

 

.

1/26/2015

SharePoint Auditing and Site Content Administration using PowerShell

 

If you have attended one of my SharePoint Saturday PowerShell presentations or read my PowerShell series at SharePoint Pro magazine, then you know a bit about what's possible with PowerShell. This Friday. January, 30th, I will be delivering one of the more fun classes I do: "SharePoint 2010 and 2013 Auditing and Site Content Administration using PowerShell". If you are a SharePoint administrator and need to "find and inventory stuff" in SharePoint then you need this class! Whatever is hiding in SharePoint is visible to the PowerShell user, if you know where to look.

Class details are here: http://www.maxtrain.com/Classes/ClassInfo.aspx?Id=119394
You can join us at MAX Technical Training in Cincinnati or attend remotely from your office or home.

This class is available world wide though Microsoft training partners
and the Microsoft Courseware library. Just ask for course 55095.

 

MS-55095 SharePoint 2010 and 2013 Auditing and Site Content Administration using PowerShell

This one day instructor-led class is designed for SharePoint 2010 and 2013 server administrators and auditors who need to query just about anything in SharePoint. The class handout is effectively a take home cheat sheet with over 175 PowerShell scripts plus the general patterns to create your own scripts. These scripts cover:

  • getting lists / inventories of servers, services web applications, sites, webs, lists, libraries, items, fields, content types, users and much more
  • finding lists by template type, content type and types of content
  • finding files by user, content type, file extension, checked out status, size and age
  • finding inactive sites
  • finding and changing SharePoint Designer settings and finding and resetting customized pages
  • inventorying and managing features
  • deleting and recycling files and list items
  • inventorying users and user permissions and finding out “who can access what”
  • creating sites, lists and libraries
  • uploading and downloading files
  • general tips for counting, reformatting and exporting results;
  • drilling up and down the SharePoint object model
  • and much more…

 

Prerequisites: You should have good SharePoint skills as and end user and administrator along with some practical experience with PowerShell.

 

.

11/08/2014

SharePoint – Use PowerShell to get all Owners, Full Control Users and Site Collection Administrators

Updated 6/12/2015

The following works for both SharePoint 2010 and 2013.

 

So who has control in your SharePoint?

Some users are members of the site's Owners group while others have been directly given Full Control. Some may be Site Collection Administrators or even have "super powers" granted at the Web Application level. How do you find these?

PowerShell to the rescue!

 

Get all users who are members of the "Owners" groups.

Get-SPSite -Limit All | 
  Get-SPWeb -Limit All | 
  where { $_.HasUniquePerm -and $_.AssociatedOwnerGroup -ne $null } | 
  foreach { $TTNweburl = $_.Url; $_ } | 
  Select -ExpandProperty AssociatedOwnerGroup | 
  Select -ExpandProperty Users | 
  Select {$TTNweburl}, UserLogin, DisplayName

 

Get all users directly given Full Control

Get-SPSite -Limit All | 
  Get-SPWeb -Limit All | 
  Where { $_.HasUniquePerm } | 
  foreach { $TTNweb = $_; $_ } | 
  Select -ExpandProperty Users | 
  Where { $TTNweb.DoesUserHavePermissions($_,[Microsoft.SharePoint.SPBasePermissions]::FullMask) } | 
  Select {$TTNweb.Url}, UserLogin, DisplayName

You could also find users with Full Control like roles by testing for "ManageWeb" or "ManagePermissions". For a list of the permission types use:

[System.Enum]::GetNames("Microsoft.SharePoint.SPBasePermissions")

 

Get all users who are Site Collection Administrators:

Get-SPSite -Limit All | 
  Get-SPWeb -Limit All | 
  where { $_.HasUniquePerm } | 
  foreach { $TTNweburl = $_.Url; $_ } | 
  Select -ExpandProperty Users | 
  Where { $_.IsSiteAdmin } | 
  Select {$TTNweburl}, UserLogin, DisplayName

 

Who else can see the content, and might have Full Control?

Some users may have access to site content via Web Application level policies. These are set in Central Administration in the Web Application Management section.

Get-SPWebApplication | 
  foreach { $TTNwebappUrl = $_.Url; $_ } | 
  Select -ExpandProperty Policies |  
  Select {$TTNwebappUrl}, DisplayName, IsSystemUser, PolicyRoleBindings, UserName | FT

 

.

7/08/2014

SharePoint PowerShell–Find all Broken Inheritance

The following applies to both SharePoint 2010 and SharePoint 2013 on premises, but not to Office 365.

One of the common SharePoint tasks when you need to do a security audit, document security or cleanup a farm before an upgrade, is to try to figure out where the Site Owners have broken inheritance and created unique permissions. You could visit every site, list, library, folder, list item and document, or you could let PowerShell do the work for you.

The following is one of the many scripts found in SharePoint® 2010 Security for the Site Owner and my PowerShell class "MS-55095 SharePoint 2010 and 2013 Auditing and Site Content Administration using PowerShell". (Sign up for the July class and get a free copy of the book!)
 

First find all of the Webs with broken inheritance:

Get-SPSite http://yourSiteUrl  | 
Get-SPWeb -Limit All | 
Where { $_.HasUniquePerm -AND $_.ParentWeb -NE $Null } | 
Select ServerRelativeUrl, {$_.ParentWeb.ServerRelativeUrl}

 

Then find all of the Lists and Libraries with broken inheritance:

Get-SPSite http://yourSiteUrl  | 
Get-SPWeb -Limit All | 
Select -ExpandProperty Lists |
Where { $_.HasUniqueRoleAssignments -AND -NOT $_.Hidden } | 
Select Title, ParentWebUrl

 

Then find all of the folders with broken inheritance:

Get-SPSite http://yourSiteUrl  | 
Get-SPWeb -Limit All | 
Select -ExpandProperty Lists | 
Select -ExpandProperty Folders | 
Where { $_.HasUniqueRoleAssignments } | 
Select Title, {$_.ParentList.ParentWebUrl + "/" +$_.ParentList.Title}

 

Then find all of the items with broken inheritance:

Get-SPSite http://yourSiteUrl  | 
Get-SPWeb -Limit All | 
Select -ExpandProperty Lists | 
Select -ExpandProperty Items | 
Where { $_.HasUniqueRoleAssignments } | 
Select Name, {$_.ParentList.ParentWebUrl + "/" +$_.ParentList.Title}

 

What if we wanted a nice single list as the output?

Each of the scripts above return different kinds of columns. As PowerShell is a bit picky about what it will merge into a single column we will have a little more work to merge everything into a single list. One solution is to build an array or collection in memory, but this could get quite large. Another solution is to dump everything in to a CSV file and then open the result in Excel.

Note: The following script uses Export-CSV with the –Append parameter, which is not available in PowerShell 2.0.

Changes to the script:

  • Add something to the Selects to identify the source.
      Select "List Item", Url, {$_.Web.Url}
  • Create custom columns so all of the results have the same column names.
  • Output the results to a CSV file.
      | Export-CSV "c:\test\BrokenInheritanceReport.csv" –Append
  • Read them back and apply any needed sorting.

The following is all one script!


$siteUrl = "http://urlToYourSite"
$savePath = "c:\test\BrokenInheritanceReport.csv"

Get-SPSite $siteUrl  | 
  Get-SPWeb -Limit All | 
  Where { $_.HasUniquePerm -AND $_.ParentWeb -NE $Null } | 
  Select @{Label="Securable"; Expression={"Web"}}, 
         @{Label="Item"; Expression={$_.ServerRelativeUrl}}, 
         @{Label="Parent"; Expression={$_.ParentWeb.ServerRelativeUrl}} |
  Export-CSV $savePath

Get-SPSite $siteUrl  | 
  Get-SPWeb -Limit All | 
  Select -ExpandProperty Lists | 
  Where { $_.HasUniqueRoleAssignments -AND -NOT $_.Hidden } | 
  Select @{Label="Securable"; Expression={"List"}}, 
         @{Label="Item"; Expression={$_.Title}}, 
         @{Label="Parent"; Expression={$_.ParentWebUrl}} |
  Export-CSV $savePath -Append

Get-SPSite $siteUrl  | 
  Get-SPWeb -Limit All | 
  Select -ExpandProperty Lists | 
  Where { -NOT $_.Hidden -AND $_.EntityTypeName -NE "PublishedFeedList" } | 
  Select -ExpandProperty Folders | 
  Where { $_.HasUniqueRoleAssignments } | 
  Select @{Label="Securable"; Expression={"Folder"}}, 
         @{Label="Item"; Expression={$_.Title}}, 
         @{Label="Parent"; Expression={$_.ParentList.ParentWebUrl + "/" +$_.ParentList.Title}} | 
  Export-CSV $savePath -Append

Get-SPSite $siteUrl  | 
  Get-SPWeb -Limit All | 
  Select -ExpandProperty Lists | 
  Where { -NOT $_.Hidden -AND $_.EntityTypeName -NE "PublishedFeedList" } | 
  Select -ExpandProperty Items | 
  Where { $_.HasUniqueRoleAssignments } | 
  Select @{Label="Securable"; Expression={"Item"}}, 
         @{Label="Item"; Expression={$_.Name}}, 
         @{Label="Parent"; Expression={$_.ParentList.ParentWebUrl + "/" +$_.ParentList.Title}} | 
  Export-CSV $savePath -Append


Import-CSV  $savePath | Sort Parent | Select *
# or open the CSV file in Excel and sort there.

7/04/2014

New Book and New Class!

New book: SharePoint® 2010 Security for the Site Owner

SharePoint2010SecruityCoverBI was always looking for a SharePoint security resource to point people to. I found content for server administrators and for developers, but nothing for site owners. Finally I decided I could quickly put together a little book on the topic. Little did I know just how much I would end up writing, testing and rewriting to get this thing done!

It only took 2½ years to complete! Work on this book started with the creation of my blog site in 2007. Or maybe it started in 2006 with the students in my SharePoint classes when they asked questions about the obvious and not so obvious SharePoint security features. The actual writing started 2½ years ago.

Why a 2010 book in 2014? It took that long to write it. (I'm both slow and busy!) But… give me a few weeks and then you can get the 2013 version of the book.

You can order it now from Amazon.

 

New Class: MS-55095 SharePoint 2010 and 2013 Auditing and Site Content Administration using PowerShell

Starting with the PowerShell chapter from the security book, and adding another 100 or so scripts, I now have a class for on premises SharePoint 2010 and 2013 administrators, auditors and governance teams who need to query just about anything in SharePoint. The class handout is effectively a cheat sheet with over 175 PowerShell scripts plus the general patterns to create your own scripts.

For all of the details of the class see here: http://techtrainingnotes.blogspot.com/2014/06/new-sharepoint-powershell-course.html

For class schedules see here: http://www.maxtrain.com/Classes/ClassInfo.aspx?Id=119394 or call MAX Technical Training at 513-322-8888. This class is available both in Cincinnati, and remotely from anywhere. This class will soon be available to all Microsoft training centers as course 55095AC.

You will need core PowerShell skills for this class, so I'd recommend having attended either of these two classes: MS-10961 Automating Administration with Windows PowerShell or MS-50414 Powershell v2 for Administrators, or equivalent.

Bonus! When you register for the class, tell them that you heard about it from Mike, and we will get you a free copy of the security book!

 

.

6/18/2014

Merging Two PowerShell Collections into One Output

 

In SharePoint users and groups are both security principles, and both share some common properties. One property, ID, is interesting as it is unique and never duplicated between the lists of users and group. I.e. if there is a user with an ID of 5 then there is never a group with an ID of 5.

In PowerShell there are two separate properties for users and groups, but I wanted to merge the two into one sorted list. Turns out, as long as both Select statements return columns with the same names, then they can be "added" to get a merged result.

 

Example: Users and Groups

$users = $web.SiteUsers | Select Id, Name
$groups = $web.Groups | Select Id, Name
$users + $groups | Sort Id

image

If you wanted to do it all in one line, then use a few parentheses:

($web.SiteUsers | Select Id, Name)  +  ($web.Groups | Select Id, Name) | Sort Id

What if the column names don't match (but have similar data types)? You will need to create a PowerShell custom column. In the example below I wanted to use the user's DisplayName property instead of the Name property so I had to create a custom column named "Name" to match the "Name" property in the groups Select.

$users = $web.SiteUsers | Select Id, @{Label="Name"; Expression={$_.DisplayName|}}
$groups = $web.Groups | Select Id, Name
$users + $groups | Sort Id

 

.

6/08/2014

New SharePoint PowerShell Course 55095AC

 

PS C:\> Get-PSScripts | Organize-PSScripts | Create-MAXClass

I've written and collected SharePoint scripts for the last several years with the idea of one day turning them into a book or a class. I've finally pulled together a class from the scripts in this blog, from the PowerShell chapter of my SharePoint security book and from examples created for my classes. Turns out there are over 175 examples in the final class.

This class was a lot of fun to right, but it had a major challenge, limiting what I put into it. As there is a lot of good content on the web for SharePoint server administration, I focused this class on the rest of us who need to find stuff and answer those random management questions. You know, those kinds of things that a SharePoint governance auditor might need to do, and the kind of weird questions that SharePoint administrators get every day.

The class has been uploaded to the Microsoft Courseware Marketplace and should be available to training centers in a few weeks as course 55095AC. Check out the MAX Technical Training web site for the dates when I will be delivering the class. The next date is July 24th. At MAX you can attend local classes in Cincinnati or attend as a remote student from anywhere!


SharePoint 2010 and 2013 Auditing and Site Content Administration using PowerShell

Course #:                                      55095AC

Number of Days:                                         1

Format:                               Instructor-Led

Certification Exams:                           None

This one day class is designed for SharePoint 2010 and 2013 server administrators and auditors who need to query just about anything in SharePoint. The class handout is effectively a cheat sheet with over 175 PowerShell scripts plus the general patterns to create your own scripts. These scripts cover:

·        using the SharePoint Management Shell and the ISE

·        general tips for counting, reformatting and exporting results;

·        understand and drilling up and down the SharePoint object model

·        getting lists / inventories of servers, services web applications, sites, webs, lists, libraries, items, fields, content types, users and much more

·        finding lists by template type, content type and types of content

·        finding files by user, content type, file extension, checked out status, size and age

·        finding inactive sites

·        finding and changing SharePoint Designer settings and finding and resetting customized pages

·        inventorying and managing features

·        deleting and recycling files and list items

·        inventorying users and user permissions and finding out “who can access what”

·        creating sites, lists and libraries

·        uploading and downloading files

·        and much more…

Audience

·        SharePoint server administrators.

·        SharePoint auditors.

·        Also valuable for SharePoint developers.

 

At Course Completion

After completing this course, students will be able to:

·        Use PowerShell to query just about anything inside of SharePoint.

·        Understand the core SharePoint object model and object hierarchy as seen from PowerShell.

·        Format PowerShell output in to reports.

·        Manage resources to limit the impact on production servers.

·        Create and delete Site Collections, subsites, lists, libraries and content.

 

Prerequisites

Before attending this course, students must:

·        Very good knowledge of SharePoint and its features.

·        Good experience using PowerShell 2 or later or recent completion of a PowerShell class such as 10961 or 50414.

 


 

Module 1:  SharePoint and PowerShell

This module provides an introduction to the topics covered in the class, introduces SharePoint PowerShell terminology and provides a review of important PowerShell features.

 

Lessons

§  History of PowerShell in SharePoint

§  PowerShell vs. Search

§  PowerShell, SharePoint Management Shell and cmdlets

§  Security and Permissions Needed

§  Getting Started with PowerShell: Counting Items, Custom Columns, Reformatting Numbers, Saving Results to a File

§  Changing and Updating Content: Creating SharePoint Objects, Changing Objects

 

Lab:

§  Using PowerShell with SharePoint

 

 

After completing this module, students will be able to:

§  Get started using PowerShell to inventory and update SharePoint.

 

Module 2: Working with SharePoint CMDLETs and Objects

This module introduces the SharePoint object model and some important terminology.

 

Lessons

§  GUIDs

§  Sites vs. Webs

§  The SharePoint Object Hierarchy

 

Lab:

§  Get a list of all Site Collections and their GUIDs

§  Get a list of all Webs in all Site Collections

§  Given a web’s URL get its parent web and web application

 

After completing this module, students will be able to:

§  Explore sites and webs using PowerShell.

§  Retrieve important properties of common SharePoint objects

 

Module 3: Managing Memory and Limiting Performance Impact

This explores limiting impact on server memory usage and performance.

 

Lessons

§  Memory Management and Disposing Objects

§  Limiting Impact on Production Servers

 

Lab:

§  Exploring PowerShell’s use of system memory.

§  Testing the impact of scripts on server performance

 

After completing this module, students will be able to:

§  Recognize and manage the impact of PowerShell on a SharePoint server.

 

 

Module 4: Working with Content

This module explores SharePoint using PowerShell from the Farm down to individual list items.

 

Lessons

§  Getting Farm Information: version, services, services, features

§  Getting Web Application information

§  Exploring Site Collections: retrieve Site Collections, Site Collection Administrators, quotas

§  Working with the Recycle Bins: finding items, getting file counts and bytes, deleted sites

§  Exploring Webs: web templates, finding webs, finding webs based on template, Quick Launch and Top Link Bar navigation

§  Exploring Lists and Libraries: finding all lists, lists by type, lists by Content Type, columns/fields, document count by web or library

§  Exploring Content Types

§  Finding documents: by a word in the title, file type, content type, size, date age, checked out status, approval status and many more…

§  Deleting content

§  Downloading and uploading files

 

Lab:

§  Explore the farm.

§  Inventory site collections.

§  Create a recycle bin report.

§  Finding all blog sites.

§  Find all picture libraries.

§  Find all PDF files over 5 MB.

§  Delete all videos in a site collection.

 

After completing this module, students will be able to:

§  Explorer, inventory and maintain SharePoint content using PowerShell.

 

Module 5: Users and Security

This module covers the use of PowerShell to explore and document SharePoint permissions.

 

Lessons

§  Users: find a user, get a list of all users, working with Active Directory groups

§  SharePoint groups: Get lists of groups, get the members of a group, find all groups a user belongs to, find the groups associated with a web

§  Expanding users lists that include Active Directory groups

§  Documenting Broken Inheritance / Unique Permissions: webs, lists, libraries, folders, items

§  Working with Role Assignments

 

Lab:

§  Get a list of all users who have access to a Site Collection.

§  Get a list of all groups in a Site Collection.

§  Get a list of all groups a user belongs to.

§  List all users who may have access to a SharePoint securable.

§  Get a list of all securables with broken inheritance.

 

After completing this module, students will be able to:

§  Explore and document users and user permissions.

§  Explore and document SharePoint groups.

§  Explore and document broken inheritance.

 

 

 

Module 6: Managing Sites

This module explorers Site Collection and Web management from PowerShell.

 

Lessons

§  Finding Inactive Webs

§  Creating and Deleting Site Collections

§  Getting Site Collection Data

§  Creating and Deleting Subsites

§  Working With SharePoint Designer Settings

 

Lab:

§  Create a report for inactive sites.

§  Create a site collection and subsites.

§  Delete a site.

§  Delete a site collection.

§  Disable SharePoint Designer in all site collections.

 

 

After completing this module, students will be able to:

§  Manage SharePoint Site Collections and webs from PowerShell.

 

.

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.