PSC:\WINDOWS\system32>$myStr="this is string variables"PSC:\WINDOWS\system32>$youStr="your want to display the$myStr"PSC:\WINDOWS\system32>$youStryour want to display the this is string variables 注意上边的变量的定义使
若要取得 PowerShell 工作階段中所有變數的清單,請輸入 Get-Variable。 變數名稱會顯示,而沒有用來參考變數的前一個貨幣符號($) 符號。 例如: PowerShell 複製 $MyVariable = 1, 2, 3 $Path = "C:\Windows\System32" 變數可用於儲存命令的結果。 例如: PowerShell 複製 $Processes = Get-Process $To...
下列範例使用help函式與參數參數,從的Get-Help名稱的說明文章中傳回資訊。 PowerShell helpGet-Help-ParameterName 說明信息顯示Name參數是位置參數,且在使用時,必須在第一個位置(位置零)指定。 Output -Name <System.String> Gets help about the specified command or concept. Enter the name of a cmdlet, fun...
Get-Variable[[-Name] <String[]>] [-ValueOnly] [-Include <String[]>] [-Exclude <String[]>] [-Scope <String>] [<CommonParameters>] Description TheGet-Variablecmdlet gets the PowerShell variables in the current console. You can retrieve just the values of the variables by specifying theVa...
统的System.Globalization.CultureInfo.CurrentCulture.Name 属性的值。要获取系统 的System.Globalization.CultureInfo 对象,请使用 Get-Culture cmdlet。 $PSDebugContext 在调试期间,此变量包含有关调试环境的信息。在其他时间,此变量包含 NULL 值。因此,可以使 ...
有关ErrorAction 参数的详细信息,请参阅 about_CommonParameters。 有关 $ErrorActionPreference 变量的详细信息,请参阅 about_Preference_Variables。Try/CatchPowerShell(以及许多其他语言)中的异常处理方式是,先对一部分代码执行 try,如果引发错误,则对其执行 catch。 下面是一个简单的例子。
System.Management.Automation.Internal.Host.InternalHost 此cmdlet 返回一个 InternalHost 对象。 备注 $Host 自动变量包含 Get-Host 返回的同一对象,你可以以相同的方式使用它。 同样,$PSCulture 和$PSUICulture 自动变量包含主机对象的 CurrentCulture 和 CurrentUICulture 属性包含的相同对象。 可以互换使用这些功能。
%SystemRoot%\System32\Winevt\Logs\Setup.evtx MaximumSizeInBytes :1052672LogMode : Circular OwningProviderName :Microsoft-Windows-Eventlog ProviderNames : {Microsoft-Windows-WUSA,Microsoft-Windows-ActionQueue... ProviderLevel : ProviderKeywords : ProviderBufferSize :64ProviderMinimumNumberOfBuffers :0Provider...
系统环境变量:是在Windows操作系统启动时就加载的环境变量,对所有用户和所有进程都可见。可以在控制面板的“系统”窗口中设置系统环境变量,或者在注册表中的“HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment”键下设置系统环境变量。
使用命令中的 Cmdlet 觸發模組的自動匯入、Get-Command針對不含通配符的 Cmdlet 執行,或針對不含通配符的 Cmdlet 執行Get-Help。 您可以使用$PSModuleAutoLoadingPreference喜好設定變數來啟用、停用及設定模組的自動匯入。 如需詳細資訊,請參閱about_Modules、about_Preference_Variables及Get-Command與Import-ModuleCmdlet ...