Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. import subprocess
  2. COMMAND_LINE = 'powershell'
  3. powershell = subprocess.Popen(COMMAND_LINE, shell=True,
  4. stdin=subprocess.PIPE,
  5. stderr=subprocess.STDOUT,
  6. stdout=subprocess.PIPE)
  7. output = powershell.stdout.readline()
  8. print output.rstrip()
  9. powershell.stdin.write('$cred = Get-Credentialn')
  10. powershell.stdin.write('Administratorn')
  11. powershell.stdin.write('Password')
  12. output = powershell.stdout.readline()
  13. print output.rstrip()
  14. out = powershell.communicate()[0]
  15. print(out)
  16.  
  17. > PS /root> $cred = Get-Credential
  18. >
  19. > Windows PowerShell credential request Enter your credentials. User:
  20. > Administrator Password for user Administrator: PS /root>
  21. > PasswordPassword : The term 'Password' is not recognized as the name
  22. > of a cmdlet, function, script file, or operable program. Check the
  23. > spelling of the name, or if a path was included, verify that the path
  24. > is correct and try again. At line:1 char:1
  25. > + Password
  26. > + ~~~~~~~~
  27. > + CategoryInfo : ObjectNotFound: (Password:String) [], CommandNot FoundException
  28. > + FullyQualifiedErrorId : CommandNotFoundException
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement