Functions/Private/Start-COVRandomPW.ps1

function Start-COVRandomPW {

    param (
        # User requiring password reset
        [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
        [string]
        $User
    )

    #Add-Type -AssemblyName PresentationFramework
    #[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
    #[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
    #[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")

    # Follow the microsoft random password schema
    $Capital = [char[]] (Get-Random -input $(65..90) -Count 1) -join ""
    $LowerC1 = [char[]] (Get-Random -input $(97..122) -Count 1) -join ""
    $LowerC2 = [char[]] (Get-Random -input $(97..122) -Count 1) -join ""
    $Num1 = [char[]] (Get-Random -input $(48..57) -Count 1) -join ""
    $Num2 = [char[]] (Get-Random -input $(48..57) -Count 1) -join ""
    $Num3 = [char[]] (Get-Random -input $(48..57) -Count 1) -join ""
    $Num4 = [char[]] (Get-Random -input $(48..57) -Count 1) -join ""
    $Num5 = [char[]] (Get-Random -input $(48..57) -Count 1) -join ""

    $Password = $Capital + $LowerC1 + $LowerC2 + $Num1 + $Num2 + $Num3 + $Num4 + $Num5
    $Password
    #[System.Windows.Forms.Clipboard]::SetText($Password)
    #$MsgBoxInput = [System.Windows.MessageBox]::Show('The users new password has been copied to your clipboard.', 'Password', 'Ok')


    #Set-ADAccountPassword -Identity '$User' -NewPassword (ConvertTo-SecureString -String $Password -AsPlainText)

}