Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- COMMAND_LINE = 'powershell'
- powershell = subprocess.Popen(COMMAND_LINE, shell=True,
- stdin=subprocess.PIPE,
- stderr=subprocess.STDOUT,
- stdout=subprocess.PIPE)
- output = powershell.stdout.readline()
- print output.rstrip()
- powershell.stdin.write('$cred = Get-Credentialn')
- powershell.stdin.write('Administratorn')
- powershell.stdin.write('Password')
- output = powershell.stdout.readline()
- print output.rstrip()
- out = powershell.communicate()[0]
- print(out)
- > PS /root> $cred = Get-Credential
- >
- > Windows PowerShell credential request Enter your credentials. User:
- > Administrator Password for user Administrator: PS /root>
- > PasswordPassword : The term 'Password' is not recognized as the name
- > of a cmdlet, function, script file, or operable program. Check the
- > spelling of the name, or if a path was included, verify that the path
- > is correct and try again. At line:1 char:1
- > + Password
- > + ~~~~~~~~
- > + CategoryInfo : ObjectNotFound: (Password:String) [], CommandNot FoundException
- > + FullyQualifiedErrorId : CommandNotFoundException
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement