Private/CFN/Get-StackDrift.ps1

function Get-StackDrift
{
    param
    (
        [Amazon.CloudFormation.Model.Stack]$Stack
    )

    if ($null -eq (Get-Command -Name Start-CFNStackDriftDetection -ErrorAction SilentlyContinue))
    {
        Write-Warning 'Upgrade your version of AWSPowerShell to see drift information'
        return $null
    }

    # Initiate drift detection
    Write-Host "Initiating drift detection"
    $detectionId = Start-CFNStackDriftDetection -StackName $stack.StackId

    # Wait for it to complete
    $status = New-Object Amazon.CloudFormation.Model.DescribeStackDriftDetectionStatusResponse
    $status.DetectionStatus = 'DETECTION_IN_PROGRESS'

    while ($status.DetectionStatus -eq 'DETECTION_IN_PROGRESS')
    {
        Start-Sleep -Seconds 1
        $status = Get-CFNStackDriftDetectionStatus -StackDriftDetectionId $detectionId
    }

    $status.StackDriftStatus
}