ContainerCmdletProvider.NewItem(String, String, Object) ContainerCmdletProvider.NewItem(String, String, Object) ContainerCmdletProvider.NewItem(String, String, Object) ContainerCmdletProvider.NewItem(String, String, Object) ContainerCmdletProvider.NewItem(String, String, Object) ContainerCmdletProvider.NewItem(String, String, Object) Method

Definition

Creates a new item at the specified path.

protected:
 virtual void NewItem(System::String ^ path, System::String ^ itemTypeName, System::Object ^ newItemValue);
protected:
 virtual void NewItem(Platform::String ^ path, Platform::String ^ itemTypeName, Platform::Object ^ newItemValue);
 virtual void NewItem(std::wstring const & path, std::wstring const & itemTypeName, winrt::Windows::Foundation::IInspectable const & newItemValue);
protected virtual void NewItem (string path, string itemTypeName, object newItemValue);
abstract member NewItem : string * string * obj -> unit
override this.NewItem : string * string * obj -> unit
Protected Overridable Sub NewItem (path As String, itemTypeName As String, newItemValue As Object)

Parameters

path
String String String String String String

The path to the item to create.

itemTypeName
String String String String String String

The provider defined type for the object to create.

newItemValue
Object Object Object Object Object 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 itemTypeName 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 type 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 itemTypeName refers to a type the provider cannot create, the provider should produce an ArgumentException with a message indicating the types the provider can create.

The newItemValue 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. ConvertTo(Object, Type) can be used to convert some types to the desired type.

The default implementation of this method throws an PSNotSupportedException.

Applies to