Dela via


DriveCmdletProvider.NewDrive(PSDriveInfo) Method

Definition

Gives the provider an opportunity to validate the drive that is being added. It also allows the provider to modify parts of the PSDriveInfo object. This may be done for performance or reliability reasons or to provide extra data to all calls using the Drive.

protected:
 virtual System::Management::Automation::PSDriveInfo ^ NewDrive(System::Management::Automation::PSDriveInfo ^ drive);
protected virtual System.Management.Automation.PSDriveInfo NewDrive (System.Management.Automation.PSDriveInfo drive);
abstract member NewDrive : System.Management.Automation.PSDriveInfo -> System.Management.Automation.PSDriveInfo
override this.NewDrive : System.Management.Automation.PSDriveInfo -> System.Management.Automation.PSDriveInfo
Protected Overridable Function NewDrive (drive As PSDriveInfo) As PSDriveInfo

Parameters

drive
PSDriveInfo

The proposed new drive.

Returns

The new drive that is to be added to the MSH namespace. This can either be the same drive object that was passed in or a modified version of it.

The default implementation returns the drive that was passed.

Remarks

This method gives the provider an opportunity to associate provider specific data with a drive. This is done by deriving a new class from PSDriveInfo and adding any properties, methods, or fields that are necessary. When this method gets called, the override should create an instance of the derived PSDriveInfo using the passed in PSDriveInfo. The derived PSDriveInfo should then be returned. Each subsequent call into the provider that uses this drive will have access to the derived PSDriveInfo via the PSDriveInfo property provided by the base class.

Any failures should be sent to the WriteError(ErrorRecord) method and null should be returned.

Applies to