I have a PowerShell script, in which I have the commands:
$Username = 'user'
$Password = 'pass'
$SecureString = ConvertTo-SecureString -AsPlainText $Password -Force
$MySecureCreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $SecureString
$name= $args[0]
$cmd= $args[1]
$s= New-PSSession -VMName $name-Credential $MySecureCreds
Invoke-Command -Session $s -Command {$cmd}
Remove-PSSession -Session $s
And I want to run it from python with open using these commands:
sp = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
(out, err) = sp.communicate()
My PowerShell command that I created in python is this
powershell_cmd = Start-Process -NoNewWindow -FilePath path_to_installer.exe -ArgumentList /S, --accept_license_agreement, --license_validation_file=path_to_license.bat
but when I try to run it, nothing happens on the virtual machine.
Can you help me with a hint, or what other technology can I use with python to run this command on the virtual machine?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…