Run Command on Remote Machine with Credentials
$Credential = Get-Credential Invoke-Command -ComputerName $Computer -ScriptBlock {Stop-Service -Name Bits} -Credential $Credential
Create PS Credential from Strings
$Username = 'Username' $Password = 'Password' $SecureString = ConvertTo-SecureString $Password -AsPlainText -Force $Credential = New-Object System.Management.Automation.PSCredential $Username, $SecureString