Packing up My Documents: A PowerShell Story

I am frequently asked by colleagues and customers for a dump of all of my SharePoint content (presentations, white papers, etc.)  While I continue to add files like these to my hard drive in various different locations, it has started to take me a while to aggregate them all forward.  It dawned on me that this need not be a half an hour exercise of locating documents.

Bing!  PowerShell

Thanks to another colleagues blog:

I created a few functions and added them to my PowerShell module that loads with my profile.  Now it’s as simple as:

Get-ChildItem -path c: -filter *sharepoint* -recurse | create-zip "c:\"

#Special Thanks to: 

# Create a new zip file from pipeline
function Create-Zip()
    New-Zip -zipfileName $zipFile
    $zip = Get-Zip -zipfileName $zipFile
    #loop through files in pipeline
    foreach($file in $input)
        #add file to zip and sleep 1/2 second
        Start-sleep -milliseconds 500


#create a new zip file
function New-Zip
    set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
    (dir $zipfilename).IsReadOnly = $false

#get the zip file
function Get-Zip
        $shellApplication = new-object -com shell.application
        $zipFullFilename = (get-childitem $zipfilename).FullName