I am trying to write a PowerShell script for my SharePoint 2013. The idea is that I what to select all the links that are referencing /documents/
folder, and that ends with either .doc
.docx
or .pdf
. in other words I want all the links that are referencing /documents/
folder and that are either Word
or PDF
. so I wrote the following If statement :-
$links = $file.ForwardLinks;
foreach($link in $links){
if($link.url -like '*/Documents/*' -and ($link.url -like '.doc' -or $link.url -like '.docx' -or $link.url -like '.pdf') ){
But this will not select any links. Although there are link that contain both /documents/
& .pdf
.
Can anyone advice on this please?