PowerShell 技能连载 - 创建新对象
原始链接:[url=http://blog.vichamp.com/powershell/tip/2014/10/21/creating-newobjects/]PowerShell 技能连载 - 创建新对象[/url]发表日期:2014-10-21
[hr]
[i]适用于 PowerShell 3.0 或以上版本[/i]
这是一个创建自定义对象的简单有效的方法:[code]
$object = [PSCustomObject]@{
Name = 'Weltner'
ID = 123
Active = $true
}
[/code]这将创建一个包含预设属性值的完整功能的 PowerShell 对象:[code]
PS> $object
Name ID Active
---- -- ------
Weltner 123 True
PS> $object.Name
Weltner
PS> $object.Active
True
PS>
[/code]本文国际来源:[url=http://powershell.com/cs/blogs/tips/archive/2014/10/21/creating-newobjects.aspx]Creating New Objects[/url]
页:
[1]