0

Below is a script that will change the value of URL field from something to something. Script works fine and is safe to run. Now, I would like to output in a txt file the old and new values.. Please help with this.

$webs = Get-SPSite http://<somesitecollection> | get-spweb -limit all | ?{$_.URL -like ‘<somethinghere’}

 

foreach ($web in $webs)

{

                $list = $web.Lists[“<someList>”]

                foreach ($item in $list.Items)

                                {

                        # Iterate HyperLink fields

                        foreach ($field in $fields)

                                                {

                                                # Get field value

                                                $fldValue = $item[“URL”]

                                                # Skip if null

                                                if($fldValue -ne $null)

                                                                                {

                                                                $item[“URL”] = $fldValue -replace “<something>”, “<withSomething>”

                                                                $item.update()

                                        }

                        }

                }

 

}

$webs.Dispose()

(Visited 43 times, 1 visits today)
Add a Comment