SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have server 1 (application that the script) (dax-sp) and server 2 (sharepoint) (sp-sp)

Script on server 1 (ScriptStart.ps1)

 Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 2000
 $pwd = Get-Content C:\crd-sharepoint.txt | ConvertTo-SecureString
 $crd = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "spadmin",$pwd
 Enter-PSSession -ComputerName ssi-sp -Authentication CredSSP -Credential $crd
 Add-PsSnapin Microsoft.SharePoint.PowerShell

Script on server 2 (SPSiteCreator.ps1)

$dax = Import-Csv C:\dax2.csv
    ForEach ( $dax2 in $dax ) {
    $Number = $dax2.Number
    $Descrip = $dax2.Descrip
function SendMail($Tipic, $msg) {
  $message = New-Object System.Net.Mail.MailMessage
  $message.Subject = $Tipic
  $message.Body = $msg
  $message.From = "sharepoint@sp.lab"     
  $client = New-Object System.Net.Mail.SMTPClient -ArgumentList "sp-exch.sp.lab"
$test = (Get-SPWeb http://ssi-sp/projects/$Number -ErrorAction SilentlyContinue) -ne $null
If ($test -ne "True") {
New-SPWeb -url http://ssi-sp/projects/$Number -template OFFILE#1 -name "$Number"
Import-SPWeb http://ssi-sp/projects/$Number -Path C:\Backup\ssi-sp-projects-project_05-11-2012.bak
Get-SPWeb http://ssi-sp/projects/$Number | Set-SPWeb -Description "$Descrip"
$web = (get-spweb http://ssi-sp/projects/$Number)
$web.Title = "$Number"
} Else{
SendMail -Tipic "SP Error" -msg "SharePoint Site $Number error"

I used


on both servers and

Enable-WSManCredSSP –Role Server
Enable-WSManCredSSP -Role client -DelegateComputer sp-sp
Read-Host -AsSecureString | ConvertFrom-SecureString | out-file C:\crd-sharepoint.txt

on server 1

Errora with i recive

Processing data for a remote command failed with the following error message: <f:WSManFault xmlns:f="" Code="3762507597" Machine="sp-sp"><f:Message><f:ProviderFault provider="microsoft.powershell" path="C:\Windows\system32\pwrshplugin.dll"></f:ProviderFault></f:Message></f:WSManFault> For more information, see the about_Remote_Troubleshooting Help topic.


New-SPWeb : Reported an exception of type 'System.OutOfMemoryException'.
At C:\Script\SPSiteCreator.ps1:8 char:10
+ New-SPWeb <<<<  -url http://sp-sp/projects/$Number -template OFFILE#1 -name "$Number"
    + CategoryInfo          : InvalidData: (Microsoft.Share....SPCmdletNewWeb:SPCmdletNewWeb) [New-SPWeb], SPException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletNewWeb

Import-SPWeb : Reported an exception of type 'System.OutOfMemoryException'.
At C:\Script\SPSiteCreator.ps1:10 char:13
+ Import-SPWeb <<<<  http://sp-sp/projects/$Number -Path C:\Backup\sp-projects-project_05-11-2012.bak
    + CategoryInfo          : InvalidData: (Microsoft.Share...CmdletImportWeb:SPCmdletImportWeb) [Import-SPWeb], OutOf
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletImportWeb

The idea of all this is that I have from one server to execute script to create pages based on the backup site.

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.