get-spweb我怎样才能获得今天创建的项目

时间:2014-05-21 15:10:16

标签: powershell sharepoint scripting ps1

我正在使用下一个Powershell脚本从Sharepoint列表中获取项目并将其导出 如何编辑此脚本以仅获取今天创建的数据或今天输入的数据 这是代码

$MyWeb = Get-SPWeb "http://ilike-eg.suz.itcgr.net/SM"
$MyList = $MyWeb.Lists["SCGC"] 
$exportlist = @()

$Mylist.Items |  ForEach-Object {
$obj =   New-Object PSObject -property @{ 
        "A"="   "+$_["AACCOUNT_ID"]
        "B"="   "+$_["BTRANSACTION_ID"]
        "C"="          "+$_["CDATE"] 
        "D"="      "+$_["DCUSTOMER_ID"]
        "E"="     "+$_["ECUSTOMER_NAME"]
        "F"=" "+$_["FAMOUNT"]
        "G"=" "+$_["GCLASS"] 
}

#Remove unnecessary sort
$exportlist += $obj   
$DateStamp = get-date -uformat "%Y-%m-%d@%H-%M-%S"
$NameOnly = "CDP" 

#Exporting with sorted properties
$exportlist |
Select-Object A,B,C,D,E,F,G |
Export-Csv -Delimiter "`t"-path "$NameOnly.txt"
}

#Removed duplicate get-content line
$a, ${d:CDP.txt} = Get-Content .\CDP.txt
$a, ${d:CDP.txt} = Get-Content .\CDP.txt

(Get-Content D:\CDP.txt) |
Foreach-Object {$_ -replace $([char]34) -replace "`t" -replace '/', '-'} |
Set-Content D:\CDP.txt

谢谢

1 个答案:

答案 0 :(得分:0)

如果您在SPListItems中进行管道传输,请插入查询以获取今天创建的项目

改变这个:

$Mylist.Items |

对此:

$Mylist.Items | where {$_['Created'] -eq Get-Date -format d}