Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Get-Credential | %{
- $user = $_.UserName
- $pass = ConvertFrom-SecureString $_.Password
- @"
- <#
- .SYNOPSIS
- command with credential
- #>
- `$user = "$user"
- `$pass = ConvertTo-SecureString "$pass"
- `$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList `$user,`$pass
- `$cmd = "cmd"
- `$args = "/?"
- Start-Process `$cmd `$args -Credential `$cred
- # vim: set ft=ps1 ts=4 sw=4 et:
- "@
- } | Out-File CommandTemplate.ps1 -Encoding OEM
Add Comment
Please, Sign In to add comment