All i'm using this code to get data from SharePoint List and export it to txt file as you see i'm using New-Object PSObject to get this
my question is how can i sort the the properties by the name i gave or how to export this items sorted by those name Thanks in advance
$MyWeb = Get-SPWeb "http://ilike-eg.suz.itcgr.net/SM"
$MyList = $MyWeb.Lists["SCGC"]
$exportlist = @()
$Mylist.Items | foreach {
$obj = New-Object PSObject -property @{
"A"=" "+$_["AACCOUNT_ID"]
"B"=" "+$_["BTRANSACTION_ID"]
"C"=" "+$_["CDATE"]
"D"=" "+$_["DCUSTOMER_ID"]
"E"=" "+$_["ECUSTOMER_NAME"]
"F"=" "+$_["FAMOUNT"]
"G"=$_["GCLASS"]
}
$exportlist += $obj | Sort-Object -descending
$DateStamp = get-date -uformat "%Y-%m-%d@%H-%M-%S"
$NameOnly = "CDP"
$exportlist | Export-Csv -Delimiter "`t"-path "$NameOnly.txt"
}
$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), ""} |
Set-Content D:\CDP.txt
(Get-Content D:\CDP.txt) |
Foreach-Object {$_ -replace "/", "-"} |
Set-Content D:\CDP.txt
(Get-Content D:\CDP.txt) |
Foreach-Object {$_ -replace "`t", ""} |
Set-Content D:\CDP.txt