Skip to content

Instantly share code, notes, and snippets.

@NicholasRoge
Last active May 7, 2019 14:36
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 NicholasRoge/7ec88b35e6aec41c7d028ecc5748a70a to your computer and use it in GitHub Desktop.
Save NicholasRoge/7ec88b35e6aec41c7d028ecc5748a70a to your computer and use it in GitHub Desktop.
$EXPORT_DIR = "$HOME\Desktop"
$EXPORT_FILENAME = "ClipboardContent.xml"
$CONTENT = [xml](Get-Clipboard)
$CONTENT_BYTE_COUNT = $CONTENT.Length
Write-Verbose "Writing $CONTENT_BYTE_COUNT bytes to '$EXPORT_DIR\$EXPORT_FILENAME'."
Write-Output $CONTENT > "$EXPORT_DIR\$EXPORT_FILENAME"
@romero126
Copy link

romero126 commented May 7, 2019

$EXPORT_DIR      = "$HOME\Desktop"
$EXPORT_FILENAME = "ClipboardContent.xml"


$CONTENT = Get-Clipboard
$CONTENT = $CONTENT.Trim()
if ($CONTENT.Length -lt 6 -or $CONTENT.Substring(0, 6) -ne "<?xml ") {
    try {
        $XMLObject = [XML]$content
    }
    catch {
        throw "Clipboard content does not appear to be a valid XML File (missing all the things)"
    }
    #$XMLObject
    pause

    exit 1
}


$CONTENT_BYTE_COUNT = $CONTENT.Length

Write-Output "Writing $CONTENT_BYTE_COUNT bytes to '$EXPORT_DIR\$EXPORT_FILENAME'."
Write-Output $CONTENT > "$EXPORT_DIR\$EXPORT_FILENAME"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment