tags:

views:

44

answers:

1

Hi,

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 , ComObject64, 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?

+1  A: 

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

Roman Kuzmin
Hmm, perhaps the question was edited and my answer is not relevant anymore. There is "apphostConfig" now in the code. It's a good idea, too. Now you have to remove parens and commas and call your function like this: Sync-Provider `"apphostConfig" "D:\NerdDinner_2.0\NerdDinner" "c:\inetpub\wwwroot"`
Roman Kuzmin
right, that worked
gapo
However, I have another error.EXCEPTION THROWN::[ Exception calling "CreateObject" with "2" argument(s): "Object of type 'appHostConfig' and path 'D:\NerdDinner_2.0\NerdDinner' cannot be created." ].Any ideas?Thank you
gapo
I think that wrong `CreateObject(string, string)` is called because now you pass strings in. Restore the original version with the enum parameter and try again.
Roman Kuzmin