Public/Get-P1SampleScripts.ps1

function Get-P1SampleScripts {
    <#
    .Synopsis
    Get sample scripts from PlannerOne Web Site.
 
    .Description
    The sample scripts could be adapted and customized to your need. It should work as-is if you're using Demo envrionment.
 
    .Example
    # Get the sample scripts.
    Get-P1SampleScripts
    #>

    [cmdletbinding()]
    param(
    )
    Process
    {
        $LocalSamplesFolder = "$HOME\Documents\P1Samples"
        if (!(Test-Path $LocalSamplesFolder)) {
            New-Item -Path "$LocalSamplesFolder" -ItemType Directory | Out-Null
            Write-Verbose "Folder $LocalSamplesFolder has been created."
        }

        Write-Verbose "Getting file list from URL $SamplesURL/list.php."
        $FileList = (Invoke-WebRequest -Uri "$SamplesURL/list.php").Content | ConvertFrom-Json

        $FileCount = $FileList.Count
        Write-Verbose "File list contains $FileCount files(s)."
        foreach ($File in $FileList) {
            Write-Verbose "Downloading file $SamplesURL/$File"
            Invoke-WebRequest -Uri "$SamplesURL/$File" -OutFile "$LocalSamplesFolder\$File" -Headers @{"Cache-Control"="no-cache"}
        }
        
        Write-Output "$FileCount sample scripts has been copied to folder $LocalSamplesFolder."
        Write-Output "Run ise to edit, customize and run the script the most adapted to your scenario."
    }
}