December 2013
Intermediate to advanced
1872 pages
153h 31m
English
Quite often, as the usage of SQL-PowerShell increases, some efficiencies are gained by using functions. Functions are especially useful when you are creating things that are done on a regular basis either directly in the console or in a script.
Using the earlier example of comparing two strings, this example writes a function named test, so if future comparisons are required, the typing requirements will be greatly reduced:
PS>Function test {>> param($user1,$user2)>> if("$user1" -eq "$user2")>> {>> Write-Host "Equals">> }>> else>> {>> Write-Host "Not equal">> }>> }>>PS>test "userA" "userB"Not equalPS>test "userA" "userA"EqualsPS>
Note
Execute the Get-Help about_function command in PowerShell for more ...