Working the "New" indicator in SharePoint lists

Joined
Jun 7, 2011
Messages
5
Reaction score
0
Hello,

We are using a script in Powershell to produce a list in SharePoint. Each time the script runs it deletes the previous list and then re-loads the updated information (on the active Ad accounts only). This portion works perfectly.

The problem we have is that the "New" indicator keeps showing on all items after we run the script. We've tried turning it off for old items but it turns off completely instead.

Does anyone know how we can get this list to update properly (delete non active accounts while still returning any new listings)? We need the "New" indicator to only show for new items added to the list but not for old listings.

We are currently using the following code:

## Start Configuration
#URL to SharePoint Site
$siteUrl = "http:// Site/URL"
#Site Name
$webName = "URL"
#List Name
$listName = "Test List"
#Active Directory OU / LDAP Query
$ou = " ldap://OU=Unit,DC=Domain,DC=COM "
#ActiveDirectory Filter
$adFilter = get-qaduser -includeallproperties -ldapfilter "(!(userAccountControl:1.2.840.113556.1.4.803:=2))"
## End Configuration
[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[System.Reflection.Assembly]::Load("Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
[System.Reflection.Assembly]::Load("System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

# START Delete List Contents
$site = new-object Microsoft.SharePoint.SPSite ( $siteUrl )
$web = $site.OpenWeb()
$oList = $web.Lists[$listName];
$collListItems = $oList.Items;
$count = $collListItems.Count - 1
for($intIndex = $count; $intIndex -gt -1; $intIndex--)
{
"Deleting : " + $intIndex
$collListItems.Delete($intIndex);
}
## END Delete List Contents
$spSite = new-object Microsoft.SharePoint.SPSite($siteurl)
$spQuery = New-Object Microsoft.SharePoint.SPQuery
$spSite.AllWebs
#$spSite.AllWebs | format-table Url, ID, Name, AllUsers
$spWeb = $spSite.OpenWeb($webName)
$spList = $spWeb.lists[$listName]
$searcher = new-object DirectoryServices.DirectorySearcher([ADSI]"$ou")
$searcher.filter = $adFilter
$groups = $searcher.findall()
@(foreach($group in $groups)
{
[string]$email = $group.properties.mail
$contactQuery = '<Where><Contains><FieldRef Name="Email"/><Value Type="Text">'
$contactQuery += $email
$contactQuery += '</Value></contains></Where>'
$spQuery = New-Object Microsoft.SharePoint.SPQuery
$spQuery.Query = $contactQuery
$spListItems = $null
$spListItems = $spList.GetItems($spQuery)
if((-not $spListItems.Count -gt 0) -and ($email.length -gt 0))
{
Write-Host "Contact Is Not Present - Adding"
[string]$lastname = $group.properties.sn
[string]$firstname = $group.properties.givenname
[string]$fullname = $group.properties.name
[string]$company = $group.properties.company
[string]$jobtitle = $group.properties.title
[string]$phone = $group.properties.telephonenumber
[string]$homephone = $group.properties.homephone
[string]$mphone = $group.properties.mobile
[string]$fax = $group.properties.facsimiletelephonenumber
[string]$address = $group.properties.streetaddress
[string]$city = $group.properties.l
[string]$state = $group.properties.st
[string]$zip = $group.properties.postalcode
[string]$country = $group.properties.c
[string]$webpage = $group.properties.wwwhomepage
[string]$notes = $group.properties.description
[string]$objectclass = $group.properties.objectclass
[string]$distinguishedname = $group.properties.distinguishedname
if (($firstname.length -gt 0) -and ($lastname.length -gt 0))
{
$spitem = $spList.Items.Add()

$spitem["Last Name"] = $lastname
$spitem["First Name"] = $firstname
$spitem["FullName"] = $fullname
$spitem["E-mail Address"] = $email
$spitem["Company"] = $company
$spitem["JobTitle"] = $jobtitle
$spitem["Business Phone"] = $phone
$spitem["Home Phone"] = $homephone
$spitem["Mobile Phone"] = $mphone
$spitem["Fax Number"] = $fax
$spitem["Address"] = $address
$spitem["City"] = $city
$spitem["State/Province"] = $state
$spitem["WorkZip"] = $zip
$spitem["Country/Region"] = $country
$spitem["Web Page"] = $webpage
$spitem["Notes"] = $notes
$spitem.Update()
}
}
}
)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top