$windows = $env:windir “Windows Folder: $windows”
PS> $windows="Hellow" PS> .\test.ps1 Windows Folder: C:\Windows PS> $windows Hellow
PS> $windows="Hellow" PS> . .\test.ps1 Windows Folder: C:\Windows PS> $windows C:Windows
New-Variable a -value 1 -option Constant "Value: $a"PS> .\test.ps1 Value: 1 PS> .\test.ps1 Value: 1
PS> . .\test.ps1 Value: 1 PS> . .\test.ps1 New-Variable : A variable with name 'a' already exists. Attest.ps1:1 char:13 + New-Variable <<<< a -value 1 -option Constant + CategoryInfo : ResourceExists: (a:String) [New-Variable], SessionStateException + FullyQualifiedErrorId : VariableAlreadyExists,Microsoft.PowerShell.Commands.NewVariableCommand
PS> $logo="www.1sucai.cn" PS> $logo www.1sucai.cn PS> $private:logo www.1sucai.cn PS> $script:logo www.1sucai.cn PS> $private:logo www.1sucai.cn PS> $global:logo www.1sucai.cn
PS> function f(){ "var=$var";$var="function inner";$var }
PS> $var="I am in console."
PS> $var
I am in console.
PS> f
var=I am in console.
function inner
PS> $var
I am in console.
PS> function f(){ "var=$var";$var="function inner";$var }
PS> $private:var="i am a private variable in console,other scope can not access me."
PS> f
var=
function inner
PS> $private:var
i am a private variable in console,other scope can not access me.
PS> Function f(){ "var=$var";$global:var=" Try to change variable in function"}
PS> $private:var="I am a private variable"
PS> $private:var
I am a private variable
PS> $var
I am a private variable
PS> f
var=
PS> $private:var
PS> $var
PS>
PS> $private -eq $null
True
PS> Function f(){ "var=$var";$global:var=" Try to change variable in function"}
PS> $var="I am a local variable."
PS> $var
I am a local variable.
PS> $private:var
I am a local variable.
PS> f
var=I am a local variable.
PS> $var
Try to change variable in function
PS> $local:var
Try to change variable in function
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有