我在下面的代碼中遇到了一些問題。我想弄清楚如何讓輸出適用於所有用戶配置文件,而不僅僅是當前用戶。如果我使用$ shell.NameSpace(34)代碼工作(這兩行註釋掉)。但是,當我嘗試重寫shell.namespace並手動添加路徑時,我得到一個錯誤,方法項不存在。想知道解決或解決此問題的最佳方法是。方法調用失敗方法命名項目
實際的錯誤消息:方法調用失敗,因爲[System.String]不包含名爲'Items'的方法。
感謝您的幫助。
$shell = New-Object -ComObject Shell.Application
$colProfiles = Get-ChildItem "C:\Users\" -Name
#$hist = $shell.NameSpace(34)
#Write-Host $hist
foreach ($userProfile in $colProfiles)
{
[string]$hist = "C:\Users\$userProfile\AppData\Local\Microsoft\Windows\History"
$date = ""
$url = ""
$hist.Items() | foreach {
""; "";
if ($_.IsFolder)
{
$siteFolder = $_.GetFolder
$siteFolder.Items() | foreach {
$site = $_
"";
if ($site.IsFolder)
{
$pageFolder = $site.GetFolder
Write-Host $pageFolder
$pageFolder.Items() | foreach {
$url = $pageFolder.GetDetailsOf($_,0)
$date = $pageFolder.GetDetailsOf($_,2)
echo "$date $url"
}
}
}
}
}
}
非常感謝!那就是這個伎倆 – user1048209