Programming Fundamentals/Variables/PowerShell: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
Creating |
(No difference)
|
Revision as of 01:54, 21 November 2016
variables.ps1
Write-Host "Variables and Data Types"
$i = 12345
$f = 1.23456789012345
$s = "string"
Write-Host "i: $i"
Write-Host "f: $f"
Write-Host "s: $s"
Write-Host
Write-Host "Constants"
New-Variable -Name 'PI' -Value 3.14159 -Option Constant
New-Variable -Name C -Value "Constant" -Option Constant
Write-Host $PI " " $C
Write-Host
Write-Host "Arithmetic Operators"
$a = 3
$b = 2
Write-Host "a = $a"
Write-Host "b = $b"
Write-Host "a + b =" ($a + $b)
Write-Host "a - b =" ($a - $b)
Write-Host "a * b =" ($a * $b)
Write-Host "a / b =" ($a / $b)
Write-Host
Write-Host "Assignment Operators"
$a += $b
Write-Host "a += b is $a"
$a -= $b
Write-Host "a -= b is $a"
$a *= $b
Write-Host "a *= b is $a"
$a /= $b
Write-Host "a /= b is $a"
Write-Host
Write-Host "String Concatenation"
$s1="Hello"
$s2="world"
Write-Host $s1 $s2"!"
Write-Host
Write-Host "User Input"
$name = Read-Host "Enter your name"
Write-Host "Hello" $name"!"
Try It
Copy and paste the code above into one of the following free online development environments or use your own PowerShell compiler / interpreter / IDE.
Online
- TutorialsPoint
- Type the following as the first two commands to access the PowerShell console:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lib64
powershell
- Type the following as the first two commands to access the PowerShell console: