Is using the WebDAV share an available option?
e.g.
$file = '\\server\site\library\filename.htm'
Get-Content $file |% { $_ -replace 'String1','String2' } | Set-Content $file
If you're changing multiple files you could even map the site as a drive
temporarily:
New-PsDrive -Name SiteDocs -Root http://server/site/library -PsProvider
FileSystem
cd SiteDocs:\
ls *.htm
Cheers,
Tony
On 20/02/2015 12:03, Salonen, Marko J wrote:
Hi all
I am trying to get html file from SharePoint, do some changes to a
string, and then move it back into SharePoint. Everything works ok
until I upload the file back to SharePoint.
This is what I have so far. The error I get is some random numbers to
the console and nothing in the library.
$fromfile= 'Server/site/library/filename.htm'
$tofile= 'c:\temp\ filename .htm'
$temp= 'c:\temp\ filename2.htm'
$weblient= New-Object System.Net.WebClient
$weblient.UseDefaultCredentials = $true
$weblient.DownloadFile($fromfile, $tofile)
Get-Content$tofile | ForEach-Object{$_ -replace "String1", "String2"}
| Set-Content $temp
$weblient.UploadFile($fromfile, $temp)
Eventually I would delete $tofile, and rename $temp and upload that.
Cheers
Marko
_______________________________________________
Sponsored by Infotext - Amazing Search for Microsoft SharePoint -
http://www.infotext.com/
ozmoss mailing list
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss
_______________________________________________
Sponsored by Infotext - Amazing Search for Microsoft SharePoint -
http://www.infotext.com/
ozmoss mailing list
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss