I am writing a Powershell 7 script that connects from a Windows 10 device to multiple Linux hosts via SSH. I want to enter the credentials once using Get-Credentials, however when I run the script, I get the following error:
Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or insufficient number of parameters were provided.
I dug through the documentation for Get-Credentials and New-PSSession but can't find any reference to this. Can -Credentials be passed through to New-PSSession for SSH connections?
Here is snippet of some of the script:
$credentials = Get-Credentials
New-PSSession -Hostname [hostname] -Credentials $credentials