Advertisement
Guest User

Untitled

a guest
Jun 15th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. param (
  2. [string]$price = 100,
  3. [string]$ComputerName = $env:computername,
  4. [string]$username = $(throw "-username is required."),
  5. [System.Security.SecureString]$password = $(Read-Host -asSecureString "Input password"),
  6. [switch]$SaveData = $false
  7. )
  8.  
  9. #convert it back to plain password
  10. $plain_password = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($password))
  11.  
  12. write-output "First argument is $price"
  13. write-output "Second argument is $ComputerName"
  14. write-output "Username is $username"
  15. write-output "Password is $plain_password"
  16. write-output "The True/False switch argument is $SaveData"
  17.  
  18. #USAGE#
  19. #PS C:\Users\moha\Desktop> .\args.ps1 -ComputerName "\\server64" -SaveData -username USER1
  20. #OUTPUT
  21. #Input password: ******
  22. #First argument is 100
  23. #Second argument is \\server64
  24. #Username is USER1
  25. #Password is SECRET
  26. #The True/False switch argument is True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement