How to Export and Import sharepoint subsite documnet library in Sharepoint 2013? - powershell

Please help me, for this i'm using power shell command as
Export-SPWeb "http://iicss89:5555" -itemurl "/HelpFiles" -path "c:\helpdocument.cmp" -IncludeVersions All
it is working for main site document library properly but for subsite it is not working.
for subsite i used below command but it shows error
Export-SPWeb -Identity "http://iicss89:5555/Physics" -itemurl "/HelpFiles" -path "c:\helpphydocument.cmp" -IncludeVersions All
Thanks

ItemUrl parameter must be server relative url. You need to remove the leading slash.
So it should be like this;
-itemurl "HelpFiles"

Related

SharePoint Online : manage folder permission with PowerShell

I'm trying to write a Powershell script to grant user permission to a sub-folder in our SharePoint online site. I tried the solutions from the similar questions already open but without success.
I've got an online SharePoint site : https://xxx.sharepoint.com/sites/MySharePoint
In this SharePoint site I've got a library called Test which contains 2 sub-folders Test1 and Test2
I want the user "adtest#x.com" to be granted access to Test1 only in read/write (i.e. contributor).
I used the following code :
Connect-PnPOnline -Url $SiteURL -Credentials $psCred
$folder = Get-PnPFolder -URL "https://xxx.sharepoint.com/sites/MySharePoint/Test/Test1"
Set-PnPfolderPermission -list "Test" -identity $folder -User "adtest#x.com" -AddRole "Contribute"
When I run these commands, on the last step I get an error which translates as : "Impossible to find the level of authorization". My system is in French so I had to translate the message.
I tried the commands found from the other questions on the site but none worked.
Has anybody any idea on the issue ?
Thanks !
Fred
In the pnp documention the identity is always the server relative path.
Try that, just use as identity:
"/Sites/MySharePoint/Test/Test1"
try set the exact name of the permission role. Check it in the advanced permission level.
System need the name in french language resp. in the language of site collection, not english. Example in slovak language which i use

Moving Document Library to a subsite in SharePoint

Currently, we have Document Libraries created in SharePoint Online and would like to move them using Powershell to its own Subsite. The reason we would like to move them is that we would like to keep the version history. Since we are dealing with 1000s of files, I would like to use Powershell to complete this task.
I am currently connecting to my SharePoint site using:
Connect-PnPOnline -Url "Sitename" -UseWebLogin
Here is where I need assistance. I am trying to use Move-PnPFolder but I am not sure how to write a command that would define the source, destination, and move of all files in the document library to a subsite that I have manually created.
Here you need to mix of PnP and CSOM PS script... the normal way how we get the SharePoint list items... we need read the the list items then inside the foreach loop you need to call the below command : Move-PnPFolder -Folder 'Shared Documents/Reports/2016/Templates' -TargetFolder 'Shared Documents/Reports' Something like below :
foreach ($oneFolder in List. Folders) { Move-PnPFolder -Folder 'Shared Documents/Reports/2016/Templates' -TargetFolder 'Shared Documents/Reports' }
Note :
In the above command from the $oneFolder property you will get the source folder URL and you already know the target folder location.
This is just sample code to present the concept.

Error in Export in sharepoint 2013

I am trying to move a subsite of 100Gb by using Export and import commands. But I am getting error when I try this command
Export-SPWeb http://dc/sites/Coms –Path "//servername/W$Backups/cops.cmp" -IncludeVersions ALL -includeusersecurity
In the above command W is the Drive name and Backups is the folder name in that server. Can anyone help? Is this correct or is there any solution? Thanks
Are yo trying to store backup in some other server? In no, then your syntax should be like follow:
Export-SPWeb http://dc/sites/Coms –Path "W:\Backups\cops.cmp" -IncludeVersions ALL -includeusersecurity
Please refer this MSDN link on export web if you want any more guidance on it:
https://technet.microsoft.com/en-us/library/ff607895.aspx

upload site template wsp file powershell

I am using SharePoint 2013 and i want to create some spweb from a site template...
I have created a site and added my desired content and i saved that site as template, then went to solution gallery and downloaded the .wsp file.
Now, i need to create a new site collection with some subsites which are based on that template, and to do so i think need to upload the .wsp file to the solution gallery the way i can find the newly saved template, and i need to do that from PowerShell !
I tried 2 ways,
First,
I tried to add-spsolution and install-spsolution like following
Add-SPSolution -LiteralPath $SPIntranetTemplateFilePath
Install-SPSolution -Identity SPITemplateFile.wsp -CompatibilityLevel 15 -force
but i don't find the .wsp in the solution gallery and the template is not in templates list...
I tried to use Install-SPWebTemplate but this command is not recognized as a cmdlet in my PowerShell (I have added Add-PSSnapin Microsoft.SharePoint.PowerShell)
I have used this too
## SharePoint DLL
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
Can anyone help me to use my WspFile the way i can create subsites based on my template ?
After Add-SPSolution try Install-SPSolution
http://technet.microsoft.com/en-us/library/ff607534(v=office.15).aspx
I think you need to add it as a sandboxed user solution for it to show up in the site collection's solution gallery. This approach worked for me.
$theSite = Get-SPSite "http://server/pathto/site"
# add the solution to the sandbox
Add-SPUserSolution (Resolve-Path .\relativePathTo.wsp) -Site $theSite
# get the user solution and activate it for the site
$customSolution = Get-SPUserSolution -Site $theSite | ? { $_.Title -match "Custom Template Title" }
Install-SPUserSolution $customSolution -Site $theSite
Once you have the sandboxed solution installed, the trick to using it to create a subsite is to use the object model to grab the template.
$localeId = 1033 # or whatever is appropriate for you
$customTemplate = $theSite.RootWeb.GetAvailableWebTemplates($localeId) | ? { $_.Title -match "Custom Template Title" }
Now, you can create a subsite based on NO template at all, and then apply the custom template:
$newSubsite = $New-SPWeb "http://server/pathto/site/subsite" # can also apply options for unique permissions, nav bar, etc.
$newSubsite.ApplyWebTemplate($customTemplate)

Export SPWeb SharePoint 2010 weird dll error

Ik get a weird error when running the following command:
PS C:\> Export-SPWeb -Identity http://dfz-85:81/ -Path "C:\temp.cmp"
This is the error i get, the .dll file keeps changing every time i try the command.
Export-SPWeb : Could not find file 'C:\Users\cmsadmin\AppData\Local\Temp\mlilsk
gt.dll'.
At line:1 char:13
+ Export-SPWeb <<<< -Identity http://dfz-vm85:81/ -Path "C:\tmep.cmp"
+ CategoryInfo : InvalidData: (Microsoft.Share...CmdletExportWeb:
SPCmdletExportWeb) [Export-SPWeb], FileNotFoundException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletExportWeb
Any help is appreciated.
I faced the same error. Could not find the reason but could successfully export from central admin > backup restore option.
Came across this issue and eventually resolved it. Not sure what the actual solution was but the steps I took were:
Add logged in user as SP Shell Admin on the content database you're exporting/importing from/to
Close the SharePoint 2010 Management Shell window
Reopen the SharePoint 2010 Management Shell window with the Import system modules option (right click on the icon in Windows 7)
I ended up avoiding the issue and exporting/importing with SharePoint designer.
This can only be done under "All Files" and on each individual file, afaik.