Typecast problem RRS feed

  • Question

  • Hi!

    I'm currently working with a PS script that is able to create some folders and views in OpsMgr.

    It's working quite well, except when setting the parentfolder on a folder. 

    In C# I would have done like this

    newFolder.ParentFolder =  mp.GetFolder("Name of Parent Folder")

    In PS I try something like this:

    $NewFolder.ParentFolder = [Microsoft.EnterpriseManagement.Configuration.ManagementPackFolder] $mp.GetFolder('Name of Parent Folder')

    If I try this, it gives me an exception like this:

    Exception setting "ParentFolder": "Cannot convert "Name of Parent folder" to "Microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference`1[Microsoft.EnterpriseManagement.Configuration.ManagementPackFolder]"."

    Is this something PS specific or what?

    Regards Henrik
    Thursday, August 20, 2009 11:53 AM


All replies