The ValidateDrive attribute

ValidateDrive may be used to test the drive letter provided for a parameter that accepts a path. ValidateDrive handles both relative and absolute paths. A relative path is resolved to a full path before it is tested against the supplied drive letters. When using the ValidateDrive attribute, the parameter type must be String. The parameter cannot be omitted:

function Test-ValidateDrive {
[CmdletBinding()]
param (
[ValidateDrive('C')]
[String]$Parameter1
)
}

ValidateDrive cannot act on an array of paths; if the parameter type is an array, an error will be thrown stating the path argument is invalid.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.195.110