随笔分类 - Powershell--Tips
摘要:Get-WmiObject win32_bios -ComputerName server1, server2 | Format-Table ` @{n='Hostname';e={$_.__server}}, @{n='SerialTag';e={$_.SerialNumber}}, @{n='OS';e={Get-WmiObject win32_operatingsystem...
阅读全文
摘要:字符串分割: ‘abc 123 xyz ’.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) #去除字符串间长度不一的”空隙“ ‘abc 123 xyz ’ -split "\s+|\t+" #去除字符串间长度不一的”空隙“ ‘abc
阅读全文
摘要:如何将{}之间的内容逐个输出: Get-Service -Name winmgmt | Select DependentServices | foreach {$_.DependentServices} -OR- Get-Service -Name winmgmt | Select -ExpandP
阅读全文
摘要:file.csv文件如下,然后对其中某些值进行变换操作,刚学Powershell的时候操作起来很麻烦,现在看来其实就是对于哈希表的操作。 col1,col2,col3,col4 text1,text2,text3,text4 text5,text6,text7,text8 text9,text10,
阅读全文
摘要:Get-CimInstance -Classname Win32_NetworkAdapterConfiguration | Where {$_.IPAddress} | select -Property ipaddress-OR-Get-CimInstance -Classname Win32_N...
阅读全文
摘要:在PowerShell中,可以通过Get-Content这个cmdlet来获取文本文件的内容。Get-Content将一个文本文件读取到一个数组中,每一个数组元素就是文件的一行内容。比如一个文本文件内容如下:111222333那么,使用Get-Content获取到一个数组,数组包括三个元素,值分别为...
阅读全文