这样,我们就声明了一个具有3个成员的数组。查看它的值,使用:复制代码
- $strUsers=@("user1","user2","user3")
复制代码
- $strUsers
PS E:\> $strUsers=@("user1","user2","user3") PS E:\> $strUsers user1 user2 user3 |
查看或者为数组成员单独赋值(需要注意的是,PowerShell与大多数程序语言一样,数组成员下标从0开始计数):复制代码
- $strUsers.Count
复制代码
- $strUsers[0]
也可以使用加号合并数组,如:复制代码
- $strUsers[1]="marui"
PS E:\> $x=@(1,2,3) PS E:\> $y=@(4,5,6) PS E:\> $z=$x+$y PS E:\> $z 1 2 3 4 5 6 |
复制代码
- $age=@{"MaRui"=21;"Lee"=27;"Tom"=53}
PS E:\> $age=@{"MaRui"=21;"Lee"=27;"Tom"=53} PS E:\> $age Name Value ---- ----- MaRui 21 Tom 53 Lee 27 |
这节的内容很简单,就讲到这里。感谢各位花时间来浏览我的博客!复制代码
- # 查询
- $age["MaRui"]
- # 增加(注意,增加的同时一定要赋值,否则不会添加新条目)
- $age["Ma"]=24
- # 修改
- $age["Ma"]=25
- # 删除(注意,使用圆括号)
- $age.remove("Ma")
- # 清除哈希表
- $age.clear()
复制代码
- get-wmiobject -class Win32_BIOS
PS E:\> get-wmiobject -class Win32_BIOS SMBIOSBIOSVersion : 8HET40WW(1.33) Manufacturer : LENOVO Name : Default System BIOS SerialNumber : R6K7H8A Version : LENOVO - 123 |
本文出自 “马睿的技术博客” 博客,请务必保留此出处http://marui.blog.51cto.com/1034148/293506复制代码
- $info = get-wmiobject -class Win32_BIOS -namespace root\CIMV2 -comp .
- foreach ($objItem in $info) {
- write-host "BIOS Characteristics: " $objItem.BiosCharacteristics
- write-host "BIOS Version: " $objItem.BIOSVersion
- write-host "Build Number: " $objItem.BuildNumber
- write-host "Caption: " $objItem.Caption
- write-host "Code Set: " $objItem.CodeSet
- write-host "Current Language: " $objItem.CurrentLanguage
- write-host "Description: " $objItem.Description
- write-host "Identification Code: " $objItem.IdentificationCode
- write-host "Installable Languages: " $objItem.InstallableLanguages
- write-host "Installation Date: " $objItem.InstallDate
- write-host "Language Edition: " $objItem.LanguageEdition
- write-host "List Of Languages: " $objItem.ListOfLanguages
- write-host "Manufacturer: " $objItem.Manufacturer
- write-host "Name: " $objItem.Name
- write-host "Other Target Operating System: " $objItem.OtherTargetOS
- write-host "Primary BIOS: " $objItem.PrimaryBIOS
- write-host "Release Date: " $objItem.ReleaseDate
- write-host "Serial Number: " $objItem.SerialNumber
- write-host "SMBIOS BIOS Version: " $objItem.SMBIOSBIOSVersion
- write-host "SMBIOS Major Version: " $objItem.SMBIOSMajorVersion
- write-host "SMBIOS Minor Version: " $objItem.SMBIOSMinorVersion
- write-host "SMBIOS Present: " $objItem.SMBIOSPresent
- write-host "Software Element ID: " $objItem.SoftwareElementID
- write-host "Software Element State: " $objItem.SoftwareElementState
- write-host "Status: " $objItem.Status
- write-host "Target Operating System: " $objItem.TargetOperatingSystem
- write-host "Version: " $objItem.Version
- write-host
- }
欢迎光临 批处理之家 (http://bathome.net./) | Powered by Discuz! 7.2 |