New-PSOneQRCodeVCard.ps1

function New-PSOneQRCodeVCard
{
    <#
            .SYNOPSIS
            Creates a QR code graphic containing person data
 
            .DESCRIPTION
            Creates a QR code graphic in png format that - when scanned by a smart device - adds a contact to the address book.
 
            .PARAMETER FirstName
            Person first name
 
            .PARAMETER LastName
            Person last name
 
            .PARAMETER Company
            Company name
 
            .PARAMETER Email
            email address
 
            .PARAMETER Width
            Height and Width of generated graphics (in pixels). Default is 100.
 
            .PARAMETER Show
            Opens the generated QR code in associated program
 
            .PARAMETER OutPath
            Path to generated png file. When omitted, a temporary file name is used.
 
            .EXAMPLE
            New-PSOneQRCodeVCard -FirstName Tom -LastName Sawyer -Company "Huckle Inc." -Email t.sawyer@huckle.com -Width 200 -Show -OutPath "$home\Desktop\qr.png"
            Creates a QR code png graphics on your desktop, and opens it with the associated program
 
            .NOTES
            Compatible with all PowerShell versions including PowerShell 6/Core
            Uses binaries from https://github.com/codebude/QRCoder/wiki
 
            .LINK
            https://github.com/TobiasPSP/Modules.QRCodeGenerator
    #>



    param
    (
        [Parameter(Mandatory)]
        [string]
        $FirstName,

        [Parameter(Mandatory)]
        [string]
        $LastName,

        [Parameter(Mandatory)]
        [string]
        $Company,

        [Parameter(Mandatory)]
        [AllowEmptyString()]
        [string]
        $Email,
        
        [ValidateRange(10,2000)]
        [int]
        $Width = 100,

        [Switch]
        $Show,

        [string]
        $OutPath = "$env:temp\qrcode.png"
    )

    $Name = "$FirstName $LastName"

    $vcard = @"
BEGIN:VCARD
VERSION:3.0
KIND:individual
N:$LastName;$FirstName
FN:$Name
ORG:$Company
EMAIL;TYPE=INTERNET:$Email
END:VCARD
"@

    
    $generator = New-Object -TypeName QRCoder.QRCodeGenerator
    $data = $generator.CreateQrCode($vcard, 'Q')
    $code = new-object -TypeName QRCoder.PngByteQRCode -ArgumentList ($data)
    $byteArray = $code.GetGraphic($Width)
    [System.IO.File]::WriteAllBytes($outPath, $byteArray)

    if ($Show) { Invoke-Item -Path $outPath }
}


# SIG # Beg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