[array],[bool],[byte],[char],[datetime],[decimal],[double],[guid],[hashtable],[int16],[int32],[int],[int64],[long],[nullable],[psobject],[regex],[sbyte].[scriptblock],[single],[float],[string],[switch],[timespan],[type],[uint16],[uint32],[uint64],[ XML ] 变量的幕后...
-Examples [-Functionality <System.String[]>] [-Path <System.String>] [-Role <System.String[]>] [<CommonParameters>] Get-Help [[-Name] <System.String>] [-Category {Alias | Cmdlet | Provider | General | FAQ | Glossary | HelpFile | ScriptCommand | Function | Filter | ExternalScript ...
# Start of script $x = 2; $y = 3 Get-Power $x $y # Function defined in script function Get-Power([int]$x, [int]$y) { if ($y -gt 0) { return $x * (Get-Power $x (--$y)) } else { return 1 } } # End of script 腳本中建立的變數範圍 $x 和$y 是該腳本的主體,...
$ExecutionContext.SessionState.Drive.GetAll() | ft 如果你的只想关注特定的驱动器,可以使用下面的方法: 路径操作 SessionState的Path包含几个特殊的方法,基本可以覆盖各种常用的路径操作了
This little script can easily create the Snap-In assembly. The first thing that I need to do is create an alias for the C# compiler, once that is established I find the location of the System.Management.Automation.dll and compile the assembly:...
查看示例:AttributeMapping.psd file for CSV2SCIM script。 例如:powershell $AttributeMapping = Import-PowerShellDataFile '.\Samples\AttributeMapping.psd1'`-AttributeMapping $AttributeMapping必须:是 唯一不需要指定的情况是在使用UpdateSchema开关时。
<# .SYNOPSIS This is a test script that has a parameter with a default value. #> function TestDefaultValue { param( [PSDefaultValue(Help='Current directory')] [string]$Name = $PWD.Path ) $Name } 기본값 정보를 확인하는 데 사용합니다 Get-Help ...
Select-String -Pattern Help -Path $PSHOME\en-US\*.txt $PSItem 与$_ 相同。 包含管道对象中的当前对象。 可以在对管道中每个对象执行操作的命令中使用此变量。 有关详细信息,请参阅 about_PSItem。 $PSScriptRoot 包含执行脚本的父目录的完整路径。 在PowerShell 2.0 中,此变量仅在脚本模块 (.psm1)...
Start-Job使用Name参数指定友好作业名称,GetMappingFiles。初始化Script参数运行一个脚本块,该脚本块导入MapFunctions模块。ScriptBlock参数Get-Map运行,Set-Content将数据保存在Path参数指定的位置。 示例8:将输入传递到后台作业 此示例使用$input自动变量来处理输入对象。 使用Receive-Job查看作业的输出。
Get-WinEvent -Path 'C:\Test\PowerShellCore Operational.evtx' -MaxEvents 100 ProviderName: PowerShellCore TimeCreated Id LevelDisplayName Message --- -- --- --- 3/15/2019 09:54:54 4104 Warning Creating Scriptblock text (1 of 1):... 3/15/2019 09:37:13 40962 Information PowerShell c...