Skip to content

Commit cc46e22

Browse files
sethvsSean Wheeler
authored andcommitted
Add ValidateDrive and ValidateUserDrive attributes information. (MicrosoftDocs#2114)
1 parent d4b7ee1 commit cc46e22

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

reference/5.1/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,43 @@ Param
605605
)
606606
```
607607

608+
## ValidateDrive Validation Attribute
609+
610+
The ValidateDrive attribute specifies that the parameter value must represent
611+
the path, that is referring to allowed drives only. PowerShell generates
612+
an error if the parameter value refers to drives other than the allowed.
613+
Existence of the path, except for the drive itself, is not verified.
614+
615+
If you use relative path, the current drive must be in the allowed drive list.
616+
617+
```powershell
618+
Param
619+
(
620+
[ValidateDrive("C","D","Variable","Function")]
621+
[string]$Path
622+
)
623+
```
624+
625+
## ValidateUserDrive Validation Attribute
626+
627+
The ValidateUserDrive attribute specifies that the parameter value
628+
must represent the path, that is referring to `User` drive.
629+
PowerShell generates an error if the path refers to other drives.
630+
Existence of the path, except for the drive itself, is not verified.
631+
632+
If you use relative path, the current drive must be `User`.
633+
634+
You can define `User` drive in Just Enough Administration (JEA)
635+
session configurations.
636+
637+
638+
```powershell
639+
Param
640+
(
641+
[ValidateUserDrive()]
642+
[string]$Path
643+
)
644+
```
608645

609646
## Dynamic Parameters
610647

reference/6/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,43 @@ Param
605605
)
606606
```
607607

608+
## ValidateDrive Validation Attribute
609+
610+
The ValidateDrive attribute specifies that the parameter value must represent
611+
the path, that is referring to allowed drives only. PowerShell generates
612+
an error if the parameter value refers to drives other than the allowed.
613+
Existence of the path, except for the drive itself, is not verified.
614+
615+
If you use relative path, the current drive must be in the allowed drive list.
616+
617+
```powershell
618+
Param
619+
(
620+
[ValidateDrive("C","D","Variable","Function")]
621+
[string]$Path
622+
)
623+
```
624+
625+
## ValidateUserDrive Validation Attribute
626+
627+
The ValidateUserDrive attribute specifies that the parameter value
628+
must represent the path, that is referring to `User` drive.
629+
PowerShell generates an error if the path refers to other drives.
630+
Existence of the path, except for the drive itself, is not verified.
631+
632+
If you use relative path, the current drive must be `User`.
633+
634+
You can define `User` drive in Just Enough Administration (JEA)
635+
session configurations.
636+
637+
638+
```powershell
639+
Param
640+
(
641+
[ValidateUserDrive()]
642+
[string]$Path
643+
)
644+
```
608645

609646
## Dynamic Parameters
610647

0 commit comments

Comments
 (0)