omega
omega

Reputation: 43843

What does the vertical line character mean in powershell?

I am using a script from here

http://blog.kuppens-switsers.net/sharepoint/finding-cewps-with-script-in-your-sharepoint-sites/

And there is a specific part of the script that I don't understand. In this part

   # Libraries and lists have views and forms which can contain webparts... let's get them also
   $lists = $web.GetListsOfType("DocumentLibrary") | ? {$_.IsCatalog -eq $false}

What exactly does | ? {$_.IsCatalog -eq $false} mean? And if possible does anyone know why this person chose to only check document libraries?

What the point of the script is, it scans all content editor web parts and checks if their contents have any script tags.

Thanks

Upvotes: 0

Views: 6194

Answers (1)

Peter Hahndorf
Peter Hahndorf

Reputation: 11222

PowerShell heavily relies on the concept of the pipeline. You execute a command which returns a collection of objects and you pipe those into another command which does something with it.

| also known as the pipe character or pipe operator is used to connect the various parts of the pipeline.

In your case, you get all DocumentLibraries in a SharePoint website and pipe (pass) them into a Where-Object cmdlet (? for short) to apply a filter. The result is then assign to a variable.

Upvotes: 2

Related Questions