$a=12# System.Int32$a="Word"# System.String$a=12,"Word"# array of System.Int32, System.String$a=Get-ChildItemC:\Windows# FileInfo and DirectoryInfo types 可以使用类型属性和强制转换表示法来确保变量只能包含可转换为该类型的特定对象类型或对象。 如果尝试分配另一种类型的值,PowerShell 会尝试将...
NAME Get-HotFix SYNOPSIS Gets the hotfixes that are installed on local or remote computers. SYNTAX Get-HotFix [-ComputerName <System.String[]>] [-Credential <System.Management.Automation.PSCredential>] [-Description <System.String[]>] [<CommonParameters>] Get-HotFix [[-Id] <System.String[]>...
[-Path] <String[]> [-Filter <String>] [-Include <String[]>] [-Exclude <String[]>] [-Force] [-Credential <PSCredential>] [-Delimiter <String>] [-Wait] [-Raw] [-Encoding <Encoding>] [-AsByteStream] [-Stream <String>] [<CommonParameters>] 三、参数详解 -ReadCount:设置每次通过管道...
[Environment]::SetEnvironmentVariable('Foo','Bar') [Environment]::GetEnvironmentVariable('Foo') Output复制 Bar 可以通过为变量的值指定空字符串,使用SetEnvironmentVariable()方法删除环境变量。 例如,若要删除环境变量,请执行以下操作Foo: PowerShell复制 [Environment]::SetEnvironmentVariable('Foo','') [...
CmdletOut-String3.1.0.0Microsoft.PowerShell.Utility Out-Host: 将内容直接输出到屏幕上。所有命令执行的时候,都是默认将命令Pipeline到out-host的InputObject参数。 Out-host的Paging开关参数可以让输出进行分页和分行显示。 Out-host-InputObject (Get-Service)-Paging ...
private string _name = "PowerShellIsolatedStore"; /// name of store [Parameter] public string Name { get { return _name; } set { _name = value; } } When you create a parameter, you should choose whether it is positional or named. With a positional parameter you don't need to prov...
可以在脚本的 Data 部分安全地使用 ConvertFrom-StringData cmdlet,并且可以将其与 Import-LocalizedData cmdlet 配合使用,以当前用户的用户界面 (UI) 区域性显示用户消息。 当包含引号中的 hashtable 值时,此处字符串特别有用。 有关 here-string 的详细信息,请参阅 about_Quoting_Rules。 以下示例演示如何在上一...
Get-WinEvent [-MaxEvents <Int64>] [-ComputerName <String>] [-Credential <PSCredential>] [-FilterXml] <XmlDocument> [-Oldest] [<CommonParameters>]说明此cmdlet 仅在 Windows 平台上可用。 Get-WinEvent cmdlet 从事件日志(包括经典日志)获取事件,例如系统和应用程序日志。 该 cmdlet 从 Windows Vista ...
<String> -replace <regular-expression>, {<Script-block>} Within the script block, use the $_ automatic variable to access the input text being replaced and other useful information. This variable's class type is System.Text.RegularExpressions.Match. The following example replaces each seq...
Set-PSReadLineOption[-EditMode <EditMode>] [-ContinuationPrompt <string>] [-HistoryNoDuplicates] [-AddToHistoryHandler <Func[string,Object]>] [-CommandValidationHandler <Action[CommandAst]>] [-HistorySearchCursorMovesToEnd] [-MaximumHistoryCount <int>] [-MaximumKillRingCount <int>] [-ShowToolTip...