Skip to content

Instantly share code, notes, and snippets.

@goyalmohit
Last active December 28, 2016 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goyalmohit/a4e21514694a059ccbf6a812acd48751 to your computer and use it in GitHub Desktop.
Save goyalmohit/a4e21514694a059ccbf6a812acd48751 to your computer and use it in GitHub Desktop.
#Specify the directory location to export files
$dirName = "c:\spbackups"
if(!(Test-Path $dirName)){
New-Item -Path $dirName -ItemType Directory -Force
}
Write-Output Exporting solutions to $dirName
foreach ($solution in Get-SPSolution)
{
$id = $solution.SolutionID
$title = $solution.Name
$filename = $solution.SolutionFile.Name
Write-Output "Exporting ‘$title’ to …\$filename" -nonewline
try {
$solution.SolutionFile.SaveAs("$dirName\$filename")
Write-Output " – done" -foreground green
}
catch
{
Write-Output " – error : $_" -foreground red
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment