Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
 C:\Script\SPSiteCreator.ps1

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.To.Add("admin@sp.lab")
  $message.From = "sharepoint@sp.lab"     
  $client = New-Object System.Net.Mail.SMTPClient -ArgumentList "sp-exch.sp.lab"
  $client.Send($message)
} 
$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"
$web.Update()
} Else{
SendMail -Tipic "SP Error" -msg "SharePoint Site $Number error"
}

I used

Enable-PSRemoting 

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="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" 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.

or

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
   MemoryException
    + 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
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.