#Requires –Version 5.0 # #.Synopsis # Creates a zip file of PowerShell scripts #.Description # The script creates a zip file containing all the files, # recursing through the top level PowerShell Script Library folder. # #.Notes # This script require PowerShell V5 for the zip file cmdlets! # Author - Thomas Lee - tfl@psp.co.uk # #.Example # PS [c:\foo]> .\Zip-PSHScripts3.ps1 # Total files : 347 # ps1 files : 342 # txt files : 1 # other files : 4 # Define what to zip and from where $zipfile = "C:\foo\ScriptLib.ZIP" $zipfrom = "C:\Users\tfl\Dropbox\PowerShell Script Library (master)" $recurse = "true" $ziptoadd = "ps1" # Check it out if ( ! (Test-path -Path $zipfrom )) { Write-Host 'scripts folder does not exist' } # Zip it up! Try { Compress-Archive -Path $zipfrom -DestinationPath $zipfile -CompressionLevel Optimal -Update } Catch { Write-Host ' Error Zipping up the script library' $Error[0] } # Stats $files = ls $zipfrom -file -recurse $files_ps1 = $files | Where-Object Extension -eq '.ps1' $files_txt = $files | Where-Object Extension -eq '.txt' $files_other = $files | Where-Object { $_.extension -NE '.PS1' -and $_.Extension -ne '.txt'} "Total files : {0}" -f $($files.count) "ps1 files : {0}" -f $($files_ps1.count) "txt files : {0}" -f $($files_txt.count) "other files : {0}" -f $($files_other.count) # All done ls $zipfile
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Thursday, 27 November 2014
Zip-Pshscripts3.ps1
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment