隐藏文件时 Powershell 中的文件属性
File Attributes in Powershell when the file is Hidden
$writetime = Get-ChildItem "\$computer$searchpath$searchfile" | Foreach {$_.LastWriteTime}
使用上面的代码,我尝试获取文件的 LastWriteTime,但如果文件被隐藏:
然后return LastWriteTime 失败。有什么办法可以强制它得到我想要的,而不管它在系统上的隐藏状态如何?
在 Get-ChildItem
上使用 -Force
参数:
Get-ChildItem "\$computer$searchpath$searchfile" -Force
$writetime = Get-ChildItem "\$computer$searchpath$searchfile" | Foreach {$_.LastWriteTime}
使用上面的代码,我尝试获取文件的 LastWriteTime,但如果文件被隐藏:
然后return LastWriteTime 失败。有什么办法可以强制它得到我想要的,而不管它在系统上的隐藏状态如何?
在 Get-ChildItem
上使用 -Force
参数:
Get-ChildItem "\$computer$searchpath$searchfile" -Force