我有这个获取最新的内部或在哪里位置对象
$web = Get-SPWeb "http://sharepoint/mysubsite"
$list=$web.Lists["Scanned Documents"]
foreach ($item in $list.Items | where {$_.Indicator -ne "Expired"}) {
write-host $item[“Expiry Date”];
$olddate = Get-Date -Date $item[“Expiry Date”]
$Now = Get-Date
if ($olddate -lt $Now) {
$item[“Indicator”] = "Expired";
} else {
$item[“Indicator”] = " ";
}
$item.SystemUpdate();
}
工作正常 - 但名单可能是真的真的很大,所以希望更多的东西像这样的位。
foreach ($item in $list.Items | Where-Object { ($_.Indicator -ne "Expired") -and (Get-Date -Date $_."Expiry Date" -lt $Now) }) {
#you get the idea
}
但我无法得到它的工作 - 抱怨使用Get-Date
的Where-Object
内。
我试图
foreach ($item in $list.Items | Where-Object { ($_.Indicator -ne "Expired") -and $_."Expiry Date" -lt $Now }) {
#you get the idea
}
其执行,但带回的所有项目不只是过期的日期。
错位的括号。在那里使用'Get-Date'没什么问题,但你需要它是'...和(Get-Date -Date $ _。“Expiry Date”)-lt $ Now'。 –
我得到这个Get-Date:无法将参数'Date'绑定到目标'对象引用未设置为对象实例 – DaGeezah