February 2019
Intermediate to advanced
626 pages
15h 51m
English
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.
Read now
Unlock full access