Learning note(7) for windows powershell Tips
来源:互联网 发布:金融数据分析发展方向 编辑:程序博客网 时间:2024/06/05 00:36
- Windows PowerShell每周提示(18):读取文本文件
Get-Content C:/Scripts/Test.txt
2. Get-Content读取文本文件并在变量中储存内容时,数据是作为数组储存的,文件内的每一行(由一个回车换行符决定)代表了数组中的每一个项
a. 查看变量类型
$a = Get-Content C:/Scripts/Test.txt
$a.GetType()
3. 只看文本文件的前三行
(Get-Content C:/Scripts/Test.txt)[0..2]
4. 另一个显示开始的x行的方法是使用–totalcount参数
Get-Content C:/Scripts/Test.txt -totalcount 3
如果你正在处理一个大文件的话,这是一个更好的方式来显示前三行,因为Get-Content将只会提取前三行。我们刚才向你呈现的那个命令,将提取整个文件,但是仅显示前三项
(Get-Content C:/Scripts/Test.txt)[-1..-3]
6. 打开这个文件,对内容排序,然后显示排序后的内容
- Windows PowerShell每周提示(19):对多台计算机运行Windows PowerShell脚本
{"$i`n=========================="; Get-WMIObject Win32_BIOS -computername $i}
2. 从文本文件中读取计算机名
$a = Get-Content "C:/Scripts/Test.txt"
foreach ($i in $a)
{$i + "`n" + "=========================="; Get-WMIObject Win32_BIOS -computername $i}
foreach ($i in Get-Content "C:/Scripts/Test.txt")
{$i + "`n" + "=========================="; get-wmiobject win32_bios -computername $i}
3. 提示用户输入计算机名
do
{
$a = Read-Host "Please enter the computer name"
if ($a -ne "")
{$a + "`n" + "=========================="; Get-WMIObject Win32_BIOS -computername $a}
}
while ($a -ne "")
- Learning note(7) 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(5) for windows powershell Tips
- Learning note(6) for windows powershell Tips
- Learning note(8) for windows powershell Tips
- PowerShell learning note
- 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)
- Windows Azure Learning Note (5)
- 【Deep Learning】笔记:Tips for deep learning
- Image Tips for Windows Phone 7
- WinPcap基础知识(第五课:过滤信息)
- vi常用操作及记忆方法
- c++ 内联函数
- 节俭的3个锦囊妙计
- YC2440-F移植blueZ
- Learning note(7) for windows powershell Tips
- 跨平台GUI开发库(转)
- WinPcap基础知识(第六课:翻译数据包)
- Flex中如何隐藏一个组件
- 巧用代码追女程序员之四:超时处理
- Axis入门教程
- C++类库介绍
- 一个客户端的完整程序
- ARM7TDMI-S里S的含义