I am writing a script to create a content type with two variables, a group which is selected from Managed Metadata that mimics our SharePoint Groups, and a user field.
I get the following error (note the second line which checks the type of the argument being passed):
PS C:\Users\facspqadmin> D:\PowerShell\Create-SiteColumns-and-ContentType-SingleProject.ps1 Here we have rootweb Farm Test 3 - the Submittal monster with type Microsoft.SharePoint.SPWeb Continue (Y/N): y y Create-ContentType : Cannot process argument transformation on parameter 'myWeb'. Cannot convert the "System.Object[]" value of type "System.Object[]" to type "Microsoft.SharePoint.SPWeb". At D:\PowerShell\Create-SiteColumns-and-ContentType-SingleProject.ps1:194 char:36+ $ctypeTeam = Create-ContentType($web,$ctypeParentName,$ctypeName,$ctypeGroup ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : InvalidData: (:) [Create-ContentType], ParameterBindingArgumentTransformationException+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Create-ContentType
...and here is a snip of the failing code...
...which is calling the following function...
function Create-ContentType(
[Microsoft.SharePoint.SPWeb]$myWeb,
[string]$myParentName,
[string]$myCtypeName,
[string]$myCtypeGroup
)
{
$cTypeParent = $myWeb.AvailableContentTypes[$myParentName]
$newContentType = New-Object Microsoft.SharePoint.SPContentType($cTypeParent, $myWeb.ContentTypes, $myCtypeName)
$newContentType.Group = $myCtypeGroup
$myContentType = $myWeb.ContentTypes.Add($newContentType)
return $myContentType
}...any ideas would be most welcome. Baffled as to why it would be trying a transformation from system.object[] which means that it is not understanding the type to begin with; except it is, based on the check prior to passing the argument.