And with little additional effort, you can create a hash table that uses these three letters as a key:复制代码
- Get-ChildItem -Path C:\Windows -Directory |
- Group-Object -Property { $_.Name.PadRight(3).Substring(0,3)}
So now it is really trivial to get all folders that, let's say, start with "SYS":复制代码
- $lookup = Get-ChildItem -Path $env:windir -Directory |
- Group-Object -Property { $_.Name.PadRight(3).Substring(0,3).ToUpper()} -AsHashTable -AsString
- $lookup.Keys
PS>powershell -f test.ps1 Directory: C:\Windows Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 11/27/2013 8:36 AM System32 d---- 11/27/2013 8:36 AM SysWOW64 |
欢迎光临 批处理之家 (http://bbs.bathome.net/) | Powered by Discuz! 7.2 |