Learning note(5) for windows powershell Tips
来源:互联网 发布:杨百万软件下载 编辑:程序博客网 时间:2024/06/07 17:15
- Windows PowerShell每周提示(14):从数组中移除项目
1. 内建在Windows PowerShell中的数组至少有一个弱点:添加新项目进数组也许很容易,但是没有相对简单的方法从一个数组中移除已存在项目。
2. 可以使用System.Collections.ArrayList
a. 添加数组项目
$a = New-Object System.Collections.ArrayList
$a.Add("red")
$a.Add("yellow")
$a.Add("orange")
$a.Add("green")
$a.Add("blue")
$a.Add("purple")
b. 删除
$a.Remove("yellow")
$a.RemoveRange(3,3)
c. 删除所有项目
$a.Clear()
- Windows PowerShell每周提示(15):与哈希表共事
1. 创建哈希表
$states = @{"Washington" = "Olympia"; "Oregon" = "Salem"; California = "Sacramento"}
输出:
Name Value
---- -----
California Sacramento
Washington Olympia
Oregon Salem
2. 添加新项目
$states.Add("Alaska", "Fairbanks")
3. 删除项目
$states.Remove("Alaska")
4. 给上面的key赋值
$states.Set_Item("Alaska","Juneau")
5. Get value for specified key
$states.Get_Item("Oregon")
6. Search in hash table
a. $states.ContainsKey("Oregon") // 这个方法返回True如果在哈希表内找到名为Oregon的项,如果没有找到则返回False。
b. $states.ContainsValue("Salem")
7. 对哈希表排序-如果我们想要对哈希表进行排序我们需要使用GetEnumerator方法,这将有效的穿过管道符发送哈希表内的每一个条目,使每个条目作为独立的对象
a.升序- $states.GetEnumerator() | Sort-Object Name
b.降序- states.GetEnumerator() | Sort-Object Value -descending
- Learning note(5) for windows powershell Tips
- Learning note(1) for Windows PowerShell Tips
- Learning note(2) for windows powershell Tips
- Learning note(3) for Windows powershell Tips
- Learning note(4) for windows powershell Tips
- Learning note(6) for windows powershell Tips
- Learning note(7) for windows powershell Tips
- Learning note(8) for windows powershell Tips
- PowerShell learning note
- Windows Azure Learning Note (5)
- Stady notes: Windows powershell tips
- Windows powershell tips:Conditional Operators
- Tips for learning ActionScript 3.0
- Windows Azure Learning Note (1)
- Windows Azure Learning Note (2)
- Windows Azure Learning Note (3)
- 【Deep Learning】笔记:Tips for deep learning
- 10 Tips for Learning a New Technology
- 硬盘数据恢复技术
- ASP.NET页面之间传递值的几种方法
- my new blog is ok
- LINK4022
- COGNOS 8.3如何通过本地文件系统导入导出报表
- Learning note(5) for windows powershell Tips
- 探索笔记3
- 定制android启动界面
- August, 12(R)
- oracle 菜鸟问题
- 使用qmake工具构建QT应用程序
- POI实现java从Word中读取数据
- Oracle EBS 11i 表结构--我工作中常用(PO and OM Module)
- LED基础知识