On Debian 11, I have installed PowerShell 7.3.0. I am testing if I can run commands on a remote Windows computer. This is a simple example to get the remote computer hostname.
#!/usr/bin/env pwsh
$username = "Administrator"
$password = "passgoeshere"
$secureStringPwd = $password | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $user, $secureStringPwd
Invoke-Command -ComputerName 192.168.xxx.xxx -Credential $cred -ScriptBlock { hostname }
My problem is that when I run this script, I still get a prompt to enter a username and password.
PowerShell credential request
Enter your credentials.
User:
It's not a problem with the credentials because when I enter them manually, it gives me the hostname of the remote computer.
I think it has something to do with the way PowerShell on Linux reads the credentials.
What can I do to get the script not to prompt for user/pass?
edit: the issue was a typo