2016-12-05 20 views
0

IDictionaryオブジェクトをpowershellでインスタンス化する必要がありますが、正しい構文が何であるかはわかりません。PowerhellでIDictionaryをインスタンス化するにはどうすればよいですか?

Import-module docker 
$config = [Docker.DotNet.Models.Config]::new() 
$dict = new-object 'system.collections.generic.dictionary[string,string]' 
$dict.Add("d:\container\content", "c:\inetpub\wwwrooot\content") 
$config.Volumes = $dict 

Exception setting "Volumes": "Cannot convert the "System.Collections.Generic.Dictionary`2[System.String,System.String]" value of type "System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" to type "System.Collections.Generic.IDictionary`2[System.String,System.Object]"." 
At D:\docker\run-MFEcountainer.ps1:6 char:1 
+ $config.Volumes = $dict 
+ ~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : NotSpecified: (:) [], SetValueInvocationException 
    + FullyQualifiedErrorId : ExceptionWhenSetting 

答えて

1

エラーメッセージは、渡すメッセージと異なるタイプが予想されることを示しています。

$dict = new-object 'system.collections.generic.dictionary[string,object]' 

それはあなたがこれを行うべきであるように見えます

関連する問題