October 2015
Intermediate to advanced
430 pages
8h 26m
English
Attributes falling under this category define the attributes that we can use to validate the value of a parameter/variable itself. The following is a list of the most commonly used parameters:
AllowNull / AllowEmptyString: This attribute allows a mandatory parameter to accept a NULL value or empty string. Check the following example. When this attribute is not set, the function does not allow us to give an empty string as an input to the $VCName parameter, as it is a mandatory input. When we comment out the AllowEmptyString parameter, it throws an error:Function Get-VC{
[cmdletbinding()]
Param(
[Parameter(Mandatory = $true)]
# [AllowEmptyString()]
[String]$VCName
)
Write-Host "vCenter Name: $VCName"
}Notice ...
Read now
Unlock full access