I am holding responsive CSS file. And I would like it to apply my CSS file for my site collection and its subsites, so that lists and document libraries also get responsive.

Can anyone help me in knowing how can I achieve it using PowerShell.

  • why would you use PowerShell? just use SharePoint Designer and edit the masterpage of the SiteCollection in order to add the new CSS-File. Its that simple...
    – Snickbrack
    Jun 12 '17 at 13:20

Instead of ruining MasterPages or running PS scripts, you can do it all ClientSide (with a little help of a Chrome Extension)

You can load a CSS file as UserCustomAction for the whole Site Collection (or one Web)

Note: Your CSS could be loaded before SharePoint CSS, so you need to set your CSS Specificity right on all selectors so they overrule the later loaded CSS files

This is also the best way to load any JS Library


You can try the below powershell script:

Ensure that css path is valid and everybody has permission to access it.

$site = Get-SPSite https://sitecollectionurl
foreach ($web in $site.AllWebs)

    $web.AlternateCssUrl  = $site.Url + "/SiteAssets/custom.css"
    Write-Host "applied responsive css at - " + $web.Url

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.