Chapter1: Write a basic powershell script
The following items will be introduced in the following section:
1.Parameters
param ( [string]$price = 100, [string]$ComputerName = $env:computername, [string]$username = $(throw "-username is required."), [string]$password = $( Read-Host -asSecureString "Input password" ) [switch]$SaveData = $false ) write-output "First argument is $price" write-output "Second argument is $ComputerName" write-output "The True/False switch argument is $SaveData".\demo.ps1 -ComputerName "\\server64" -SaveData.\demo.ps1 -ComputerName "\\server64" -SaveData:$false
[Parameter(Mandatory = $true)]
Last updated