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

When i try to add a masterpage to a web application using the following code :

$MasterPage = "C:\test.master"
$MasterPageName = [System.IO.Path]::GetFileName($masterpage);
$SpWebApp = Get-SpWebApplication $Url
$Spsite = $spWebApp.sites[0]
$web = $spSite.OpenWeb();

#Check if the page is already there. 
$MasterPagelist = ($web).Lists |? {$_.Title -eq "Galerie met basispagina's"}
$item = $MasterPagelist.items |? {$_.Name -eq $MasterPageName}
$BaseMasterItem = $MasterPagelist.items |? {$_.Name -eq $BaseMasterPageName}

if($item -ne $null)
{
    Delete-MasterPage $MasterPageName $spSite
}

$MasterPagelist.RootFolder.Files.Add($MasterPageName, [System.IO.File]::ReadAllBytes($MasterPage)) | out-null; 

i get the following error:

Exception calling "Add" with "2" argument(s): ""
At line:1 char:37
+ $MasterPagelist.RootFolder.Files.Add <<<< ("test", $MasterPageBytes)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

The weird thing is that the error does not actually contain any usefull information. On my development farm this code works just fine, on my production farm it does not.

Any ideas on what could cause this behaviour?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

It turns out that this error is being caused by Microsoft Forefront Security, when I go to Central admin -> Security -> Manage antivirus settings, and from there I turn of the virus scan on uploaded documents this error no longer occurs.

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.