Can someone tell me how to use this in a PowerShell Custom workflow?

I have all i need to send a random passcode from the SDK example although I don't know how to force them in this workflow to update Q&A profile.

Here is my code all works but the force Q&A profile.


function PostExecuting($workflow, $activity)
#Passcode length

#Passcode lifetime in minutes
$PASSCODE_LIFETIME = 1440 #(1 day)

#Parse request parameters - domain and user name
$domain = ""
$connection = $global.GetDirectoryConnectionByName($domain)
$userId = $Workflow.UserInfo.AccountInfo.objectGUID
$firstname = $Workflow.UserInfo.AccountInfo.givenname
$lastname = $

#Generate a passcode for a user
$PASSCODE= $global.GeneratePasscode($PASSCODE_LENGTH)

#Assign passcode to a user
$global.QAProfileAssignPasscode($connection, $userId, $passcode, $PASSCODE_LIFETIME)

#replace items in HTML file
$html = Get-Content "E:\Email\PasscodeEXT3.html"
$html = $html -replace "~passcode", $passcode
$html = $html -replace "~firstname", $firstname
$html = $html -replace "~lastname", $lastname

# generate email information
$subject = "Random Passcode generated"
$email = $Workflow.UserInfo.AccountInfo.mail

$global.EmailUserHtml($email, $subject, $html)