1

In the code below, I want to pass current web object to function Remove-CT(), How I do that?

site | Get-SPWeb -Limit all | ForEach-Object {
     $currentWeb = $_.SPWeb // please correct this line if wrong
     $Pages_Library = $_.Lists[$lookForList]

     Remove-CT($Pages_Library, $currentWeb)
    }
3

$_ is your SPWeb object. Your script should look like this:

$site | Get-SPWeb -Limit all | ForEach-Object {
     $Pages_Library = $_.Lists[$lookForList]
     Remove-CT $Pages_Library $_
    }

Or an even shorter version:

$site | Get-SPWeb -Limit all | % { Remove-CT $_.Lists[$lookForList] $_ }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.