Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

PowerShell Validation

$
0
0

I have a script that will update computer Description in Active Directory. I would like to validate the AD description with the following information:

BLDG #402, Rm GH123-1, GH1001-D234, 987-9876, SN C0T4021

I would like to force the users of the script to use the pattern above; that way we can keep everything uniformed in Active Directory. Is there a way to validate this input?

[CmdletBinding()]

    param(

       [Parameter(Mandatory=$True,HelpMessage="Type a computer name as in PAOWK39399")]

       [string]$computername,

 

       [ValidateCount(1,53)]

       [ValidatePattern("[BLDG, ]")]

       [Parameter(Mandatory=$True,HelpMessage="Type a Description, EXAMPLE: BLDG, Rm GH123-1, GH1001-D234, 987-9876 SN C0T41M2")]

       [string]$ADDescription

       )


Viewing all articles
Browse latest Browse all 6937

Trending Articles