$Username = 'Administrator'; $Password = 'Mypass123'; $SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force; $Credential = New-Object System.Management.Automation.PSCredential $Username, $SecurePassword; Alternatively: # GUI-only $Credential = Get-Credential