Created
May 17, 2018 13:43
-
-
Save mwjcomputing/43fe3a53793d099da7b30ff0213efbce to your computer and use it in GitHub Desktop.
Copy-VSCodeUserSnippets copies the VS Code User Snippet Files to a directory for backup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Copy-VSCodeUserSnippets { | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$true, HelpMessage="Enter the destination address")] | |
[String] $Destination | |
) | |
# Global Variables | |
$SnippetFolder = "C:\Users\$ENV:Username\AppData\Roaming\Code\User\snippets\" | |
Write-Debug -Message "Checking for destination directory." | |
if (-not (Test-Path -Path $Destination)) { | |
Write-Debug -Message "Creating $Destination Directory" | |
Write-Verbose -Message "Creating Destination Directory" | |
New-Item -Path $Destination -ItemType 'directory' -Force | Out-Null | |
} | |
try { | |
Copy-Item -Path "$SnippetFolder\*" -Destination $Destination -ErrorAction Stop | |
} | |
catch { | |
throw $PSItem | |
} | |
finally { | |
if (Test-Path -Path "$Destination\*.code-snippets") { | |
Write-Verbose -Message "Files copied to $Destination" | |
} else { | |
Write-Error -Message "Snippet files not copied." | |
} | |
} | |
<# | |
.SYNOPSIS | |
This function copies the user snippet files in the snippet folder to another folder. | |
.DESCRIPTION | |
This function copies the user snippet files in the snippet folder to another folder for purposes of backup. | |
.EXAMPLE | |
PS> Copy-VSCodeUserSnippets -Destination 'C:\Backups\Snippets\' | |
.NOTES | |
This is part of the MWJModule module. | |
#> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment