private/set/Set-Profile.ps1

function Set-Profile
{
    [CmdletBinding(SupportsShouldProcess, PositionalBinding = $true)]
    param(
        [Parameter(Mandatory = $false)]
        [string] $ProfileName
    )

    if ($ProfileName)
    {
        if ($PSCmdlet.ShouldProcess($ProfileName))
        {
            Set-AWSCredential -ProfileName $ProfileName -Scope Script
        }
    }
    elseif ($env:AWS_PROFILE)
    {
        if ($PSCmdlet.ShouldProcess("$env:AWS_PROFILE"))
        {
            Set-AWSCredential -ProfileName "$env:AWS_PROFILE" -Scope Script
        }
    }
    else
    {
        if ($PSCmdlet.ShouldProcess('default'))
        {
            Clear-AWSCredential -Scope Script
        }
    }
}