Instead of passing username and password as parameters, use Get-Credentials within the function to prompt the user for credentials.  See this script as an example that used Get-Credentials.