Sync-WDSite Web应用程序物理路径参数

时间:2016-08-17 08:23:18

标签: powershell iis

我编写了一个脚本,用于同步IIS服务器之间的站点。我的所有网站都没有错误地同步,但是一个网站(当然是最重要的网站)得到了一个奇怪的错误。

以下代码部分同步网站:

$spp = $path.Get_Item($Name)
$publishsettings = Get-WDPublishSettings -FileName $_.FullName
$sync = Sync-WDSite $Name $Name -sitephysicalpath $spp `
                                        -SourcePublishSettings $publishsettings `
                                        -IncludeApppool `
                                        -WarningAction Continue `
                                        -sourcesettings $settings `
                                        -ErrorAction Continue `
                                        -destinationsettings $settings `
                                        -debug

我得到的错误如下(错误是德语,但我试图将其翻译成英语):

Sync-WDSite : The parameter 'Web Application Physical Path Parameter' was already defined.
In C:\Users\Administrator\desktop\wdeploy.ps1:236 Zeichen:17
+         $sync = Sync-WDSite $Name $Name -sitephysicalpath $spp `
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Sync-WDSite], DeploymentException
    + FullyQualifiedErrorId : Microsoft.Web.Deployment.PowerShell.SyncSite

我完全不知道它来自何处。

请注意,我使用-debug参数查看cmdlet执行的每个步骤。错误发生在其他站点收集有关站点的信息的阶段(哪个站点是它,它使用哪个apppool等)。

谢谢!

编辑:

其他信息: 每个站点的发布设置文件具有完全相同的结构,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<publishData>
  <publishProfile
    publishUrl="https://server:port/msdeploy.axd"
    msdeploySite="Sitename"
    destinationAppUrl="http://anysiteurl.domain.com:port/"
    mySQLDBConnectionString=""
    SQLServerDBConnectionString=""
    profileName="Default Settings"
    publishMethod="MSDeploy"
    userName="server\wdeployadmin"
    userPWD="***"
    msdeployAllowUntrustedCertificate="True"
    agentType="wmsvc"
    useNTLM="False"/>
</publishData>

编辑:

Martin要求的完整错误消息:

writeErrorStream      : True
PSMessageDetails      :
Exception             : Microsoft.Web.Deployment.DeploymentException: Der Parameter 'Web Application Physical Path
                        Parameter' wurde bereits definiert.
                           bei Microsoft.Web.Deployment.DeploymentSyncParameterCollection.Add(DeploymentSyncParameter
                        parameter)
                           bei Microsoft.Web.Deployment.PowerShell.WDeployCmdletBase.ProcessUserCmd()
TargetObject          :
CategoryInfo          : InvalidOperation: (:) [Sync-WDSite], DeploymentException
FullyQualifiedErrorId : Microsoft.Web.Deployment.PowerShell.SyncSite
ErrorDetails          : Der Parameter 'Web Application Physical Path Parameter' wurde bereits definiert.

InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : bei <ScriptBlock>, C:\Users\Administrator\desktop\wdeploy.ps1: Zeile 245
                        bei <ScriptBlock>, C:\Users\Administrator\desktop\wdeploy.ps1: Zeile 232
                        bei <ScriptBlock>, <Keine Datei>: Zeile 1
PipelineIterationInfo : {0, 1}

2 个答案:

答案 0 :(得分:2)

您可以使用msdeploy.exe -verb:sync代替Sync-WDSite作为解决方法。

答案 1 :(得分:1)

正如Martin在评论中指出的那样,这是sync-wdsite cmdlet本身内部的一个错误。我向微软报告并希望他们能解决这个问题(即使我对它没有那么多的信心)。随意投票支持我的问题! https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/15756139-web-deploy-snap-in-bug-report

使用此命令部署站点时没有任何错误:

msdeploy.exe -verb=sync 
             -source:contentpath="Sitename",
                     computerName=https://Server:Port/msdeploy.axd?site=SITENAME,
                     userName=deploy,
                     password=PASSWORD,
                     authType=basic
             -dest:contentpath="D:\inetpub\path",computerName=localhost 
             -allowUntrusted

如果您想在PowerShell中执行此操作,请执行以下操作:

$msdeployPath = 'C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe'

[string[]]$msdeployFolderSyncArgs = @(
    "-verb:sync",
     "-source:contentpath='Sitename',
                     computerName=https://Server:Port/msdeploy.axd?site=SITENAME,
                     userName=deploy,
                     password=PASSWORD,
                     authType=basic"
     "-dest:contentpath='D:\inetpub\path',computerName=localhost 
      -allowUntrusted"
)

$iex = Invoke-Expression "$msdeployPath $msdeployFolderSyncArgs"
相关问题