2

I had written the below code to ignore the statements based on if condition, But find no luck. Can any one do let me know what's wrong in my below code

$myListColl = $eachWeb.Lists; $mylistsToIgnore=101 foreach ($eachList in $oListColl) { if($mylistsToIgnore==$eachList.TempladID) { //Ignore statement } else { //Other Statement } } 

2 Answers 2

5

For starters, you compare on the wrong property (and you are not using a PowerShell compare operator):

Change

if($mylistsToIgnore==$eachList.TempladID) 

to

if($mylistsToIgnore -eq $eachList.TemplateID) 

Also, another typo:

Change

foreach ($eachList in $oListColl) 

to

foreach ($eachList in $myListColl) 
1
  • On Break point I don't get any value of below line , But it is showing condition as right $templateid= $eachList.TemplateID Commented Jul 21, 2017 at 10:52
3

There is no TemplateId property in SPList object. You have to find it by TemplateFeatureId in SPWeb.ListTemplates.

$myListColl = $eachWeb.Lists $mylistsToIgnore = @(101) foreach ($eachList in $myListColl) { $listTemplate = $eachWeb.ListTemplates | ? {$_.FeatureId -eq $eachList.TemplateFeatureId} if ($mylistsToIgnore.Contains($listTemplate.Type_Client)) { # Ignore statement } else { # Other Statement } } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.