When I ssh to the windows machine it will not be in powershell prompt and I don't know how I'm going to execute the powershell script I have.
I tried the following code without success.
ssh_connect(ip1, " powershell.exe <mtu-read.ps1")
def ssh_connect(address, script):
#key_filename1 = 'id_rsa' #no authentication for now testing
host_user = "Administrator"
try:
process1 = subprocess.Popen("ssh -oStrictHostKeyChecking=no " + host_user + "@" + address + script, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output1 = process1.stdout.readlines()
print(output1)
return output1
except Exception as er2:
print(str(er2) + ' connection issue ')
return "0"
The result I get is that it does not recognize the command in the powershell.
Invoke-Expressionshould be for very select use-cases. The issue is OP's use of<