Guest User

Untitled

a guest
Sep 24th, 2018
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. Get-Credential | %{
  2. $user = $_.UserName
  3. $pass = ConvertFrom-SecureString $_.Password
  4.  
  5. @"
  6. <#
  7. .SYNOPSIS
  8. command with credential
  9. #>
  10. `$user = "$user"
  11. `$pass = ConvertTo-SecureString "$pass"
  12. `$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList `$user,`$pass
  13.  
  14. `$cmd = "cmd"
  15. `$args = "/?"
  16.  
  17. Start-Process `$cmd `$args -Credential `$cred
  18.  
  19. # vim: set ft=ps1 ts=4 sw=4 et:
  20. "@
  21. } | Out-File CommandTemplate.ps1 -Encoding OEM
Add Comment
Please, Sign In to add comment