Create Page
Open your SharePoint site and create a list from the Tasks template.
Name it My Tasks as shown in the following:
You will get the tasks list as shown in the following:
Copy the URL of the list. We will need it in the next step.
Note: Please note that we require %20 also to denote the space character.
Copy HelloWorld.js
Now create a HelloWorld.js file and copy it to the Site Assets library.
Create PowerShell Script
Now you can open the PowerShell ISE editor and add the following code.
- # Add Snapin
- if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
- {
- Add-PSSnapin "Microsoft.SharePoint.PowerShell"
- }
- # Update Page
- $web = Get-SPWeb http://sharepoint
- $page = "/Lists/My%20Tasks/AllItems.aspx"
- $file = $web.GetFile($page)
- $file.CheckOut();
- $manager = $web.GetLimitedWebPartManager($page, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
- $webpart = $manager.WebParts[0]
- $webpart.JSLink = "/siteassets/helloworld.js"
- $manager.SaveChanges($webpart);
- $file.CheckIn("JS Link updated");
Verification
You can verify the page update by opening the page in edit mode. Go to the web part properties and you can see that the JavaScript link was updated there.

This concludes the JavaScript Link updating using PowerShell.
Note: Please note that the preferred way of update is using CSOM code. In this way we can use the same code base for both SharePoint On-Premise and Online.
References
Summary
In this article we saw how to update the JavaScript Link of a site using PowerShell. You can get the code as an attachment.


keera chinnuPosted Aug 14, 2015, 3:50 AM EDT
Thanks for sharing..Good One. Can U please give Some Overview on People Picker how it works.
Jean PaulTOP 100Posted Aug 5, 2015, 2:01 PM EDT
Thank You Dear SharePointers! :)
Neeraj KumarPosted Aug 5, 2015, 1:53 PM EDT
Good One
Rajeesh MenothPosted Aug 4, 2015, 1:24 AM EDT
Good One
Debasis SahaTOP 100Posted Aug 3, 2015, 8:53 PM EDT
Good One...
Nilesh JadavPosted Aug 3, 2015, 8:27 PM EDT
Nice share sir
Chervine BhiwooPosted Aug 3, 2015, 7:24 PM EDT
Good one
Santhakumar MunuswamyPosted Aug 3, 2015, 10:39 AM EDT
Nice article. Thanks for sharing
Prasham SabadraPosted Aug 3, 2015, 10:32 AM EDT
Thanks sir for sharing !
RakeshPosted Aug 3, 2015, 6:55 AM EDT
Good sharing sir
Gopi ChandPosted Aug 3, 2015, 6:54 AM EDT
Good work
Abhay ShankerPosted Aug 3, 2015, 6:46 AM EDT
Nice One.
Sibeesh VenuTOP 100Posted Aug 3, 2015, 4:48 AM EDT
Nice share
Neeraj KumarPosted Aug 3, 2015, 4:45 AM EDT
Good one
Rajeesh MenothPosted Aug 3, 2015, 4:40 AM EDT
Nice one sir