有关详细信息、列表和首选项变量的说明,请参阅about_Preference_Variables。 使用变量 若要创建新变量,请使用赋值语句为变量赋值。 在使用变量之前,无需声明变量。 所有变量的默认值为$null。 若要获取 PowerShell 会话中所有变量的列表,请键入Get-Variable。 显示的变量名称不带前面的美元 ($用于引用变量的) 符号...
下列範例使用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,...
TypeName: System.String Name MemberType Definition --- --- --- Length Property int Length {get;} 有关PowerShell 中的变量的详细信息,请参阅about_Variables。 使用环境提供程序和项 cmdlet PowerShell的环境提供程序提供了一个接口,用于以类似于文件系统驱动器的格式与环境变量交互。 它允许你在 PowerSh...
使用命令中的 Cmdlet 觸發模組的自動匯入、Get-Command針對不含通配符的 Cmdlet 執行,或針對不含通配符的 Cmdlet 執行Get-Help。 您可以使用$PSModuleAutoLoadingPreference喜好設定變數來啟用、停用及設定模組的自動匯入。 如需詳細資訊,請參閱about_Modules、about_Preference_Variables及Get-Command與Import-ModuleCmdlet...
统的System.Globalization.CultureInfo.CurrentCulture.Name 属性的值。要获取系统 的System.Globalization.CultureInfo 对象,请使用 Get-Culture cmdlet。 $PSDebugContext 在调试期间,此变量包含有关调试环境的信息。在其他时间,此变量包含 NULL 值。因此,可以使 ...
First, I'm opening the files in create mode, which is a system change, so I should wrap that code in a ShouldProcess block. That means I will have an opportunity to tell the user what I'm going to do before I actually do it. (This is done when the user uses either Confirm or ...
若要仅获取对象的属性,而不获取方法的属性,请使用值为Property的 cmdlet 的Get-MemberMemberType参数,如以下示例所示。 PowerShell Get-ChildItem$PSHOME\pwsh.exe |Get-Member-MemberTypeProperty Output TypeName: System.IO.FileInfo Name MemberType Definition --- --- --- Attributes Property System.IO.File...
Get-Module查找由$Env:PSModulePath环境变量指定的路径中的可用模块。 有关PSModulePath的详细信息,请参阅about_Modules和about_Environment_Variables。 示例3:获取所有导出的文件 PowerShell Get-Module-ListAvailable-All 此命令获取所有可用模块的所有导出文件。
Get-ChildItem 使用Path 参数指定 C:\Windows\System32*.txt。 Recurse 参数包括子目录。 对象将向下发送到管道以 Select-String。 Select-String 使用Pattern 参数,并指定字符串 Microsoft。 CaseSensitive 参数用于匹配字符串的确切大小写。 Select-String PowerShell 控制台中显示输出。 备注 根据你的权限,你可能会...
Enable completion of scoped variables without specifying scope (#20340) (Thanks @MartinGC94!) Fix issue with incomplete results when completing paths with wildcards in non-filesystem providers (#24757) (Thanks @MartinGC94!) Allow DSC parsing through OS architecture translation layers (#24852) (...