我可以在一个窗体,将搜索所有连接的驱动器的PST文件。填充datagridview
我可以得到它使用以下命令工作: -
Get-PSDrive -PSProvider "filesystem"|%{get-childitem $_.root -include *.pst -r}|select name, directoryname, @{name="Size (GB)";expression ={"{0:N2}" -f ($_.length/1GB)}}
唯一的问题是它需要大约45分钟通过所有驱动器运行并完成搜索。我想通过使用Windows搜索索引来加快速度。
我有这个....
function Searchindex{
$query="SELECT System.ItemName, system.ItemPathDisplay, System.ItemTypeText, System.Size FROM SystemIndex where system.itemtypetext = 'outlook data file'"
$objConnection = New-Object -ComObject adodb.connection
$objrecordset = New-Object -ComObject adodb.recordset
$objconnection.open("Provider=Search.CollatorDSO;Extended Properties='Application=Windows';")
$objrecordset.open($query, $objConnection)
[email protected]()
Try { $objrecordset.MoveFirst() }
Catch [system.exception] { "no records returned" }
do
{
Write-host ($objrecordset.Fields.Item("System.ItemName")).value `
($objrecordset.Fields.Item("System.ItemPathDisplay")).value `
($objrecordset.Fields.Item("System.ITemTypeText")).value `
($objrecordset.Fields.Item("System.Size")).value
if(-not($objrecordset.EOF)) {$objrecordset.MoveNext()}
} Until ($objrecordset.EOF)
$objrecordset.Close()
$objConnection.Close()
$objrecordset = $null
$objConnection = $null
[gc]::collect()
}
这个输出在几秒钟这是完美的细节画面,但我不能工作,如何在数据网格视图中显示它。
我正在使用原始表单来创建表单。
一旦数据被填充在我希望能够选择记录并将它们复制到新的位置
谁能帮助DataGridView的?
TIA
安迪
这工作得很好谢谢。我怎样才能得到输出显示在列中? – 2015-02-08 16:34:59
你是在谈论'DataGridView'还是'Out-GridView'?原因'Out-GridView'默认显示列? – Matt 2015-02-08 16:59:06
Datagridview理想情况下 – 2015-02-08 17:41:11