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 time stamp 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 over time 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 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

All SharePoint Versions

The web parts are functional components that extend your SharePoint environment whether it’s hosted, on-premises, or part of Microsoft® Office 365.

SharePoint 2013, 2016, 2019, Online (Office 365)

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

SharePoint

Product Suites

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


Essentials Suite


Essentials Plus Suite


Bamboo Premier Suite


Project Management Suite


Knowledge Management Suite


External User Manager


 

For more information on our product suites, contact us.

Featured Services

SharePoint Health Check

A SharePoint Health Check will identify the causes of issues and risks associated with your specific environment, and is custom tailored to provide you with the best recommendations to optimize your SharePoint environment.

SQL Health Check

Document recommendations relating to performance, stability, availability, or a specific focus you request of your SQL Server database instances.

My SharePointXperts

The truth is that each SharePoint skill may not be a full time job for many organizations, and it is nearly impossible for one person to do everything you need – so augment your team with SharePointXperts; providing the skill sets you need when you need them!