Public/Get-PBVMSnapshot.ps1

function Get-PBVMSnapshot {
    <#
    .SYNOPSIS
        PoshBot command to retrieve VM Snapshot
    .EXAMPLE
        !getvmsnapshot -vm VM01
    #>

    [PoshBot.BotCommand(CommandName = 'getvmsnapshot')]
    [cmdletbinding()]
    param(
        [PoshBot.FromConfig()]
        [parameter(Mandatory)]
        [hashtable]$Connection,
        [parameter(Position = 0, Mandatory = $false, ValueFromRemainingArguments = $true)]
        [string]$vm
    )

    #Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
    $creds = [pscredential]::new($Connection.Username, ($Connection.Password | ConvertTo-SecureString -AsPlainText -Force))
    $null = Connect-VIServer -Server $Connection.Server -Credential $creds

    if ($vm) {
        $objects = Get-Snapshot -VM $vm
    }
    else {
        $objects = Get-VM | Get-Snapshot
    }


    $ResponseSplat = @{
        Text = Format-PBvSphereObject -Object $objects -FunctionName $MyInvocation.MyCommand.Name
        AsCode = $true
    }

    Disconnect-Viserver -Confirm:$false
    New-PoshBotTextResponse @ResponseSplat
}