$username = "DOMAIN\User" $password = "Password" $secstr = New-Object -TypeName System.Security.SecureString $password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)} $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr Invoke-Command -FilePath "C:\Script\To\Execute.ps1" -Credential $cred -Computer localhost