-= How to import a custom aspx-page in SharePoint using PowerShell? =-
-
Monday, June 18, 2012 11:50 AM
How to import a custom aspx-page in SharePoint using PowerShell?
Regards, Oleg
- Edited by Delmar74 Monday, June 18, 2012 12:26 PM
All Replies
-
Monday, June 18, 2012 12:31 PM
Hello,
I don't exactly understand your requirement like import aspx pages...from where it is imported???
If you want to create aspx page using powershell then follow the links,
Let me know outcome of this.
-Saumil
-
Monday, June 18, 2012 12:53 PM
I have already working aspx-page on SharePoint site.
I want to copy the page to other SharePoint sites.
Regards, Oleg
-
Monday, June 18, 2012 1:08 PM
Hello Again,
Please try following powershell commands
export-spweb -identity [Source Server URl] -ItemUrl [Library relative url] -path [drive:\backup_pages.cmp] Import-spweb –identity [Target Server URl] -path [drive:\backup_pages.cmp] -updateversion ignore
-Saumil
[Note: please change the parameters accordingly.]
-
Monday, June 18, 2012 1:41 PM
I tried this commands, and I got error.
I think, the command is for list/library, but not for aspx-page.export-spweb -identity "http://sharepointserv" -ItemUrl "/default.aspx" -path "c:\default.aspx"
Export-SPWeb : At line:13 char:13+ export-spweb <<<< -identity $site -ItemUrl "/default.aspx" -path $path + CategoryInfo : InvalidData: (Microsoft.Share...CmdletExportWeb:SPCmdle tExportWeb) [Export-SPWeb], SPException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletExportWeb
-
Monday, June 18, 2012 1:54 PM
Hello Delmar,
export-spweb -identity "http://sharepointserv" -ItemUrl "/Pages/default.aspx" -path "c:\Pages_Backup.cmp"
Please try this.
It will take back up of all pages in "Pages" Library.
-Saumil
-
Monday, June 18, 2012 2:01 PM
I got error:
Export-SPWeb : The URL provided is invalid. Only valid URLs that are site collections
or sites are allowed to be exported using stsadm.exe.
At line:14 char:13
+ export-spweb <<<< -identity $site -ItemUrl "/Pages/default.aspx" -path "c:\Pages_B
ackup.cmp"
+ CategoryInfo : InvalidData: (Microsoft.Share...CmdletExportWeb:SPCmdle
tExportWeb) [Export-SPWeb], SPException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletExportWeb -
Monday, June 18, 2012 2:11 PM
Hello Delmar,
Check out the forum http://social.technet.microsoft.com/Forums/en-US/sharepoint2010setup/thread/a1f48e70-9360-440f-b160-525fbf2b8412
-
Tuesday, June 19, 2012 7:09 AM
Hi Siva_Reddy,
this topic has not helped solve the problem.
Regards, Oleg
-
Tuesday, June 19, 2012 7:15 AM
Hello,
Is it possible for you to provide web url and library url?
-Saumil
-
Saturday, June 30, 2012 4:09 PM
I am also trying to acheive the same thing . Trying to copy default.aspx present in 1 Site collection :
EG : Copying http://firstsite.test.com/sites/test1/subtes1/default.aspx to http://firstsite.test.com/sites/test2/subtes2/default.aspxMy objective is to copy default.aspx from 1st site and overwrite it with the one present in second subsite
Tried Powershell Script :
$web1 = Get-Spweb http://firstsite.test.com/sites/test1/subtes1 $web2 = Get-SpWeb http://firstsite.test.com/sites/test1/subtes2 $folder1 = $web1.Rootfolder $collfiles1 = $folder1.Files for($i = 0 ; $i -lt $collfiles1.Count ; $i++) { if($collfiles1[$i].Name -eq "default.aspx") { $str = $web2.Url + "/default.aspx" $collfiles1[$i].CopyTo($str,$true) } } Write-Host "Script Completed"This works and copies pages fine if tried on same subsite ( In my case subtes1 )
However the moment I try to copy the page to subsite present in different site collection
, it throws me error :Exception calling "CopyTo" with "2" argument(s): "Value does not fall within th e expected range." At E:\scripts\TlacCopyPage.ps1:20 char:25 + $collfiles1[$i].CopyTo <<<< ($str,$true) + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
Any help would be much appreciated....
Regards
Frankie

