Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param (
- [string]$price = 100,
- [string]$ComputerName = $env:computername,
- [string]$username = $(throw "-username is required."),
- [System.Security.SecureString]$password = $(Read-Host -asSecureString "Input password"),
- [switch]$SaveData = $false
- )
- #convert it back to plain password
- $plain_password = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($password))
- write-output "First argument is $price"
- write-output "Second argument is $ComputerName"
- write-output "Username is $username"
- write-output "Password is $plain_password"
- write-output "The True/False switch argument is $SaveData"
- #USAGE#
- #PS C:\Users\moha\Desktop> .\args.ps1 -ComputerName "\\server64" -SaveData -username USER1
- #OUTPUT
- #Input password: ******
- #First argument is 100
- #Second argument is \\server64
- #Username is USER1
- #Password is SECRET
- #The True/False switch argument is True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement