Functions/Get-Puppeteer_TakeScreenshot.ps1

<#
.SYNOPSIS
    This function returns the Node JS Puppeteer code for taking a screenshot of a browser page.
#>

function Get-Puppeteer_TakeScreenshot {
    [CmdletBinding(PositionalBinding=$true)]
    [OutputType([String])]
    param (
        # The path to save the screenshot.
        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [String]$filePath
    )

    # Generate the code
    $code = "await page.screenshot({ 'path': '%filepath%', 'quality': 50 })"
    $code = $code -replace "%filepath%", $filePath

    # Return the code
    return $code
}