Stop-XboxProfiling.ps1

function Stop-XboxProfiling {
    <#
    .Synopsis
        Aborts collection of profiling data
    .Description
        Aborts collection of profiling data.
        Abandons any buffered data and log file specified in the prior call to Start-XboxProfiling
    .Example
        Stop-XboxProfiling
    #>

    param()
    
    begin {
        if (-not (Test-Path Variable:\XapDmAbortProfiling)) {
            $script:XapDmAbortProfiling = 
                Add-Type -Name "DmAbortXapProfiling$(Get-Random)" -MemberDefinition '
                [DllImport("xbdm.dll")]
                public static extern int DmAbortProfiling();
                '

        }
    }
    
    process {
        ($script:XapDmAbortProfiling)::DmAbortProfiling()
    }
    end {
    
    }
}