Get-Variable [[-Name] <String[]>] [-ValueOnly] [-Include <String[]>] [-Exclude <String[]>] [-Scope <String>] [<CommonParameters>]说明Get-Variable cmdlet 获取当前控制台中的 PowerShell 变量。可以通过指定 ValueOnly 参数来仅检索变量的值
不能够显示它的其它信息,如果想查看一个变量的其它保留信息,就需要变量的基类PSVariable对象,这个可以通过Get-Variable命令得到,下面的例子演示如何查看一个变量的全部信息。 1、修改变量的选项设置 Powershell处理一个变量的PSVariable对象,主要是为了能够更新变量的选项设置。既可以使用命令Set-Variable,也可以在获取PSva...
GetRandomCommandBase GetRunspaceCommand GetRunspaceDebugCommand GetSecureRandomCommand GetServiceCommand GetTimeZoneCommand GetTraceSourceCommand GetTypeDataCommand GetUICultureCommand GetUniqueCommand GetUptimeCommand GetVariableCommand GetVariableCommand Constructors Properties Exclude Include Name V...
变量的幕后管理 创建一个变量后,会生成一个PSVariable对象,这个对象不仅存储了变量的值,还存储了变量的其他信息,比如描述($var.Description)等 https://www.pstips.net/powershell-variable-management-behind-the-scenes.html 查看这个PSVariable对象 Get-Variablevar| fl *或者 $var| fl *...
与Get-Variable不同,Get-Command不支持作用域参数。一旦在当前作用域中覆盖,则无法从父作用域中得到函数。另外,可以在函数名前使用global、script、local或private作用域标识符。下例在global和local作用域中声明同名函数,然后用命名空间前缀区别二者:展开表
PowerShell实战:Get-Content命令使用详解 一、Get-Content介绍 Get-Content 主要作用是获取路径指定位置的项(文本类文件)的内容,例如文件中的文本或函数的内容。 对于文件,内容一次读取一行,并返回对象的集合,每个对象表示一行内容。 支持的格式主要包括: 文本:txt 等...
此命令演示模块中私有变量的行为。 该模块包含Get-Countercmdlet,该 cmdlet 具有名为 Counter 的私有变量。 该命令使用Visibility参数和私有值来创建变量。 PowerShell PS C:\>New-Variable-Namecounter-VisibilityPrivate#Effect of private variable in a module.PS C:\>Get-Variablec* Name Value --- --- Cult...
New-Variable -Name 'TestVariable' -Value 'Test Value' -Option AllScope,Constant此示例创建一个变量,并分配 AllScope 和Constant 选项,以使该变量在当前作用域和创建的任何新作用域内可用,并且无法更改或删除。示例5:创建私有变量此命令演示了模块中的私有变量的行为。 该模块包含 Get-Counter cmdlet,...
Get-Item Get-ItemProperty Get-ItemPropertyValue Get-Location Get-Process Get-PSDrive Get-PSProvider Get-Service Get-TimeZone Invoke-Item Join-Path Move-Item Move-ItemProperty New-Item New-ItemProperty New-PSDrive New-Service Pop-Location Push-Location ...
Get-WinEvent 参考 反馈 模块: Microsoft.PowerShell.Diagnostics 获取本地和远程计算机上的事件日志和事件跟踪日志文件中的事件。 语法 PowerShell复制 Get-WinEvent[[-LogName] <String[]>] [-MaxEvents <Int64>] [-ComputerName <String>] [-Credential <PSCredential>] [-FilterXPath <String>] [-Force] [...