Printer Friendly Version      Send     
Click to Rate and Give Feedback
DriveCmdletProvider.NewDrive Method
DriveCmdletProvider.NewDrive Method
Creates a new drive based on a specified PSDriveInfo object. Overriding this method gives the provider an opportunity to validate or modify the drive information before the drive is created.


Namespace: System.Management.Automation.Provider
Assembly: System.Management.Automation (in system.management.automation.dll)

Visual Basic
Protected Overridable Function NewDrive ( _
    drive As PSDriveInfo _
) As PSDriveInfo
C#
protected virtual PSDriveInfo NewDrive (
    PSDriveInfo drive
)
C++
protected:
virtual PSDriveInfo^ NewDrive (
    PSDriveInfo^ drive
)
J#
protected PSDriveInfo NewDrive (
    PSDriveInfo drive
)
JScript
protected function NewDrive (
    drive : PSDriveInfo
) : PSDriveInfo

Parameters

drive

A PSDriveInfo object that describes the drive.

Return Value

A PSDriveInfo object that represents the new drive. The returned object can be the same object passed in by the drive parameter or a modified version of it. The default behavior is to return the passed-in PSDriveInfo object. If an error occurs, an error record should be sent to the error pipeline using the WriteError method and null should be returned.

For an example of a Windows PowerShell drive provider that implements this method, see Creating a Windows PowerShell Drive Provider in the Windows PowerShell Programmer's Guide.

This method gives the provider an opportunity to associate provider-specific data with a drive. This is done by deriving a new class from the passed-in PSDriveInfo object and adding any properties, methods, or fields that are necessary.

To do this, the override of this method should first create an instance of a new derived PSDriveInfo class using the passed-in PSDriveInfo object and then return the derived PSDriveInfo object. (Note that the derived PSDriveInfo class should have a constructor that takes a PSDriveInfo object and that calls the PSDriveInfo private constructor.

Each subsequent call into the provider that uses this drive will then have access to the derived PSDriveInfo class via the PSDriveInfo property (which is provided by the base PSDriveInfo class).

For more information about Windows PowerShell providers, see Windows PowerShell Providers in the Windows PowerShell Programmer's Guide.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows Server 2008, Windows Vista, Windows Server 2003, Windows XP

Target Platforms

Windows Server 2008, Windows Server 2003, Windows Vista, Windows XP
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker