PowerShell - Variables
PowerShell - Variables
# variables are limited to Scope in which they are created
$Console_Ctreated = 1
Invoke-Command -ScriptBlock {$Script_Created =5;$Script_Created}
Invoke-Command -ScriptBlock {$Global:Script_Created =5;$Script_Created}
$Console_Ctreated
$Script_Created
# Data declaration requirement for Variables
[int]$NumberOne = Read-Host "Write First Number"
[int]$NumberTwo = Read-Host "Write Second Number"
$AdditionOfNumber = $NumberOne +$NumberTwo
$AdditionOfNumber
# Double and Single Quotation Marks
$Test_Var = 2
Write-host "The Value of Variable is $Test_Var"
Write-host 'The Value of Variable is $Test_var'
# Automatic Variables
$$
$?
$_
$PID
$PsCulture
$PWD
1..8|foreach{Write-Host $_}
# Preference variable
$MaximumHistoryCount
$MaximumHistoryCount = 10
相信未来 - 该面对的绝不逃避,该执著的永不怨悔,该舍弃的不再留念,该珍惜的好好把握。