How to Upload a .css file on the folder within the Style Library of my site collection using PowerShell. I am having a style file called style_bg.css. How to get the folder within the style library through powershell.I have written the below line of code.
[System.Reflection.Assembly]::LoadWithPartialName
("Microsoft.SharePoint")
if((Get-PSSnapin | Where {$_.Name -eq
"Microsoft.SharePoint.PowerShell"}) -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
#Site Collection where you want to upload files
$siteCollUrl = "http://srvr1:123/sites/Geology/"
$libraryName = "Style Library" # can i enter folder name here ?
#Physical/Network location of files
$reportFilesLocation = "C:\Maddy\Scripts\Styles"
$spSourceWeb = Get-SPWeb $siteCollUrl;
$spSourceList = $spSourceWeb.Lists[$libraryName];
if($spSourceList -eq $null)
{
Write-Host "The Library $libraryName could not be found."
return;
}
$files = ([System.IO.DirectoryInfo] (Get-Item
$reportFilesLocation)).GetFiles()
foreach($file in $files)
{
#Open file
$fileStream = ([System.IO.FileInfo] (Get-Item
$file.FullName)).OpenRead()
#Add file
$folder = $spSourceWeb.getfolder($libraryName)
Write-Host "Copying file $file to $libraryName..."
But i am not able to insert into the particular sub folder within the style library using the above. I am stuck with where I am missing. And if its checked out after insert , how to check in and publish.