以自定义的规则来对元素分组

  

$lookup=ls -dir|group -p {$_.Name.PadRight(2).Substring(0,2)} -AsHashTable -AsString
$lookup.sy
# 以目录名称的前2个字母分组 并转换为hashtable 
# 然后将hashtable的键转换为String类型

  

# 找出sy开头的文件夹

  

原文地址:https://www.cnblogs.com/feiyucha/p/10584912.html