ContainerCmdletProvider.NewItem Method

Definition

Creates a new item at the specified path.

protected virtual void NewItem (string path, string itemTypeName, object newItemValue);
Parameters
path
String

The path to the item to create.

itemTypeName
String

The provider defined type for the object to create.

newItemValue
Object

This is a provider specific type that the provider can use to create a new instance of an item at the specified path.

Remarks

Providers override this method to give the user the ability to create new provider objects using the new-item cmdlet.

         The <code data-dev-comment-type="paramref">itemTypeName</code> parameter is a provider specific string that the user specifies to tell
         the provider what type of object to create.  For instance, in the FileSystem provider the <code data-dev-comment-type="paramref">type</code>
         parameter can take a value of "file" or "directory". The comparison of this string should be 
         case-insensitive and you should also allow for least ambiguous matches. So if the provider allows
         for the types "file" and "directory", only the first letter is required to disambiguate.
         If <code data-dev-comment-type="paramref">itemTypeName</code> refers to a type the provider cannot create, the provider should produce
         an <xref href="System.ArgumentException"></xref> with a message indicating the types the provider can create.

         The <code data-dev-comment-type="paramref">newItemValue</code> parameter can be any type of object that the provider can use
         to create the item. It is recommended that the provider accept at a minimum strings, and an instance
         of the type of object that would be returned from GetItem() for this path. <xref href="System.Management.Automation.LanguagePrimitives.ConvertTo(System.Object,System.Type)"></xref>
         can be used to convert some types to the desired type.

         The default implementation of this method throws an <xref href="System.Management.Automation.PSNotSupportedException"></xref>.