Powershell中显示隐藏文件的方法


支持PS3.0及以后版本。
当你使用 Get-ChildItem 检索文件,默认是不显示隐藏文件的。
要包含隐藏文件,请使用 ?Force 参数。

PS> Get-ChildItem -Path $home -Force

如果只需要显示隐藏文件,可以使用参数-Hidden ,但它只支持PS3.0。

PS> Get-ChildItem -Path $home -Hidden

Directory: C:UsersTobias

Mode LastWriteTime Length Name ---- ------------- ------ ---- d--h- 08.01.2012 10:38 AppData d--hs 08.01.2012 10:38 Application Data d--hs 08.01.2012 10:38 Cookies d--hs 08.01.2012 10:38 Local Settings d--hs 08.01.2012 10:38 My Documents d--hs 08.01.2012 10:38 NetHood (...)

Powershell使用C#实现缩写路径
支持2.0及以后版本。某些时候报表中的路径字符串是非常长的。如果需要你也可以缩写它,但是这样路径就失去的使用价值。最好是使用内置的API它可

Powershell截取字符串并添加省略号的例子
限制字符串大小支持所有版本。确保你输出的字符串不会过长,当字符串超过你指定的长度你可以用下面办法将其缩短。if($text.Length-gt$MaxLength){$text.Subst

PowerShell中iso8601格式日期和DateTime对象互转实例
一、iso8601格式转换成DateTime对象这里主要用到datetime的静态方法staticdatetimeParseExact(strings,stringformat,System.IFormatProviderprovider)$dateTimeStr='20141231T23:59:59'$format=