Link to home
Start Free TrialLog in
Avatar of computerstreber
computerstreberFlag for United States of America

asked on

PowerShell Verify if Paramater Substring is Between A and Z

I am trying to build a PowerShell script that checks the 5th character in a paramter and checks to see if it is letter in the alphabet between A and Z. However, I am not sure how to check for that.

This is what I have so far... but it doesn't work...
# Check for Alpha
 
$nameone = P1234W1054 
 
IF ($nameone.Substring(5,1) -eq "[a-z]"
{
  "Is in the alphabet"
}
else
{
  "Not in the Alphabet"
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Aard Vark
Aard Vark
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also there's a syntax error on the end of line 5, add a closing ).
Avatar of computerstreber

ASKER

Worked Perfectly!