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
        }

        $FileList = (Invoke-WebRequest -Uri "$SamplesURL/list.php").Content | ConvertFrom-Json
        foreach ($File in $FileList) {
            Write-Output "Downloading file $SamplesURL/$File"
            Invoke-WebRequest -Uri "$SamplesURL/$File" -OutFile "$LocalSamplesFolder\$File"            
        }

        dir $LocalSamplesFolder
        Write-Output "The sample script has been copied to folder $LocalSamplesFolder. Run ise to edit, customize and run the scripts."
    }
}