Public/SmartClientProfiles/Reset-SmartClientProfile.ps1

#Requires -Modules 'MilestonePSTools'

function Reset-SmartClientProfile {
    [CmdletBinding(SupportsShouldProcess, ConfirmImpact='High')]
    param (
        # Specifies the Smart Client Profile to reset with the contents of the default Smart Client Profile SettingsXml
        [Parameter(Mandatory, ValueFromPipeline)]
        [VideoOS.Management.VmoClient.SmartClientProfile]
        $SmartClientProfile,

        # Pass the Smart Client Profile back into the pipeline
        [Parameter()]
        [switch]
        $PassThru
    )

    begin {
        $vmo = Get-VmoClient
    }

    process {
        try {
            $defaultProfile = Get-SmartClientProfile | Where-Object IsDefaultProfile
            if ($PSCmdlet.ShouldProcess("Smart Client Profile '$($SmartClientProfile.Name)'",'Reset')) {
                $SmartClientProfile.SettingsXml = $defaultProfile.SettingsXml
                $SmartClientProfile.Update()
            }

            if ($PassThru) {
                Write-Output $SmartClientProfile
            }
        }
        catch {
            $vmo.Dispose()
            throw
        }
    }

    end {
        $vmo.Dispose()
    }
}