SPFest Chicago: Jack Fruh’s SharePoint PowerShell Time Machine

“Gosh that takes me back… or is it forward? That’s the trouble with time travel, you can never tell.”

~ The Fourth Doctor in Dr. Who

Attending Jack Fruh‘s session, SharePoint PowerShell Time Machine, at SharePoint Fest Chicago has persuaded me. If you are a SharePoint Administrator, having a collection of PowerShell scripts running on a scheduled basis is better than having a TARDIS when it comes to getting information from the past to save time in the future. (You may argue that the TARDIS is cooler – and I am certainly not going to disagree – but, if we are honest, we know that the unpredictability of TARDIS’s short-range guidance, relative to the size of the universe, would make it an unreliable SharePoint tool.)

Clearly the opportunity to become a Time Lord of SharePoint was appealing to many, and Jack whet our “wannabe” appetites by demoing some administrator-friendly back-in-time scripts, including:

  • Enabling versioning on document libraries
    • Jack showed us how easy it is to not only turn on versioning across all sites but also to specify the number of major versions that you want to keep so users can easily go back in time to see earlier iterations of documents.
  • Recording current permission levels on sites
    • You know that one day someone is going to find his way to the Site Permissions and click Inherit Permissions to see what happens. With a scheduled job that records site permissions, recovery is no longer a daunting, time-consuming process.
  • Estimating your upcoming hardware requirement
    • It’s about that time when organizations plan for the next year. Capturing the size of a Site Collection or Content Db on a regular basis allows your projections to be based on past growth trends
      rather than a wild guess.

Each of these PowerShell scripts beg to be regularly scheduled.  If you need a quick refresher on Windows Task Scheduler, you’ll want to take a look at this short video.

Almost as important as capturing the information is having a logging structure. Each script Jack presented used
variables to give each file a unique timestamp and name. If you are scheduling jobs and outputting log files to the same directory, including a similar structure in your scripts will save you time down the road.

Note the script below from Enable Versions on every SharePoint Site with PowerShell (updated with logging):

   1: Add -PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
   2:
   3: $timestamp= get- date - format "yyMMdd_hhmmtt"
   4: $filenameprefix ="location_where_file_will_be_savedFilename
   5: $logfile= ("{0}_{1}.csv" -f $filenameprefix, $timestamp)
   6:
   7:
   8: $header = " this is vary from script to script"
   9: $header| out-file  -FilePath $logfile

# filenameprefix – Identifies where the files will be stored on your machine and the name of the file.

# logfile – Shows how Jack likes to format his files, but there are lots of ways to do this.

# out – File will not append, it will overwrite. However, with the timestamp, it is very unlikely that two files will have the same name.

Some additional handy tips from Jack included:

  • Using * copy filename will merge together multiple files. (This works from the command prompt, not PowerShell, but think about how easy this would make it to present an excel chart of disk capacity overtime to support your cry for additional hardware!)
  • Use $false not false
  • Notepad ++ is “awesome
  • Check out this PowerShell Cheat Sheet

In the session, he also stated that you’d be given information that you could use on your first day back in the
office. Not only is it true, but if you are a SharePoint Admin, it should not be put off!

“You know how it is; you put things off for a day and next thing you know, it’s a hundred years later.”

~ The Fifth
Doctor in Dr. Who

SharePoint Online

The cloud parts are functional components that extend your SharePoint Online environment in Microsoft 365.

Supports Classic and Modern sites for SharePoint Online/Microsoft 365

SharePoint

Top SharePoint Online Products

Experience greater power and savings by bundling our SharePoint apps and cloud parts.


Calendar Plus


Chart Plus


Knowledge Base


Project Management Central


Simple List Search

 

On-Premises Only

These web parts extend SharePoint beyond its out-of-the-box capabilities by tailoring it to your requirements with Bamboo Solution’s growing portfolio of SharePoint Web Parts.

SharePoint 2013, 2016, 2019, 2022 - Classic Pages Only

SharePoint

Top On-Premises Only Products

Experience greater power and savings by bundling our SharePoint apps and web parts.


Calendar Plus


Data Viewer


Password Change


Password Expiration


Password Reset

 

Our team of Microsoft 365 experts help you get the most out of your Microsoft technology, we have the best Microsoft 365 talent to streamline your organization.

Streamline Your Department

We Have What You Need

Bamboo Solutions

Tools


Resources


Bamboo Installer