开发者

PowerShell webdeploy

I'm trying to use PowerShell with web deployment based on this article

This is how my script looks like

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Deployment") 
function Sync-Provider($provider, $sourceLocation, $destLocation)  
{   
    $destBaseOptions   = new-object Microsoft.Web.Deployment.DeploymentBaseOptions   
    $syncOptions       = new-object Microsoft.Web.Deployment.DeploymentSyncOptions   
    Try  
    {  
      $deploymentObject =                [Microsoft.Web.Deployment.DeploymentManager]::CreateObject($provider, $sourceLocation)     
      $deploymentObject.SyncTo($provider,$destLocation,$destBaseOptions,$syncOptions)  
    }  
    Catch  
    {  
      echo "EXCEPTION THROWN::[ $_ ] "  
      #throw $_  
    }  
}  
Sync-Provider   ("apphostConfig","D:\NerdDinner_2.0\NerdDinner","c:\inetpub\wwwroot") 

Running this gives the following exception

EXCEPTION THROWN::[ Cannot convert argument "0", with value: "System.Object[]",
 for "CreateObject" to type "Microsoft.Web.Deployment.DeploymentWellKnownProvid
er": "Cannot convert value "apphostConfig,D:\NerdDinner_2.0\Ne
rdDinner,c:\inetpub\wwwroot" to type "Microsoft.Web.Deployment.DeploymentWellKn
ownProvider" due to invalid enumeration values. Specify one of the following en
umeration values and try again. The possible enumeration values are "Unknown, A
ppHostConfig, AppHostSchema, AppPoolConfig, ArchiveDir, Auto, Cert, ComObject32
, ComObject6开发者_如何学Python4, ContentPath, CreateApp, DirPath, DBFullSql, DBMySql, FilePath, G
acAssembly, IisApp, MachineConfig32, MachineConfig64, Manifest, MetaKey, Packag
e, RecycleApp, RegKey, RegValue, RootWebConfig32, RootWebConfig64, RunCommand, 
SetAcl, WebServer, WebServer60"." ] 

Could you give me some hints on this, please?


Try to enclose the first parameter [Microsoft.Web.Deployment]::DeploymentWellKnownProvider.AppHostConfig with a pair of extra parenthesis: ([Microsoft.Web.Deployment]::DeploymentWellKnownProvider.AppHostConfig).


In my case I had the same problem, just opened the powershell console as Administrator and it worked.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜