$session = Invoke-Command -ScriptBlock {
New-PSSession -HostName ${REMOTE_SERVER} -UserName '${REMOTE_USER}' -KeyFilePath '${SSH_KEY_PATH}' -Verbose 4>&1
}
this script runs smoothly on my pc where i user powershell 7 & but when i use the same script in gitlab ci/cd the job hangs up. I guess this is due to the interactive mode. is there any work around for this. I want to store the session in the $session variable and uses that variable further to invoke other script in remote server.[enter image description here](https://i.sstatic.net/cwmlOepg.png)
pwsh -Command "
$session = Invoke-Command -ScriptBlock {
New-PSSession -HostName ${REMOTE_SERVER} -UserName ${REMOTE_USER} -KeyFilePath ${SSH_KEY_PATH} -Verbose 4>&1
};"
i tried the above script but its giving me error given below :
The term ‘=’ is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I even tried escaping character but its not working
Manik Shrestha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.