Link to home
Start Free TrialLog in
Avatar of sirbounty
sirbountyFlag for United States of America

asked on

Powershell - determining provided file size from customers

I'm expecting end-users to send an email with a request containing a file size limitation.  My script reads the email then dumps those values into a file that gets read in by another script.

The field I'm checking is simply called size (so the file contains a single line that reads size:xxx)

I'd like to capture as many scenarios as possible with powershell, so that I don't have to force the customer to fit a single mold.
What kind of logic could I have that would take as many values as possible and ensure everything is configured as a KB?

Example - if the user simply supplies an integer, I'm fine with assuming that's in KB.
But if the user supplies a trailing 'k' or 'kb', I'd want to 'only' gather the numeric value (500k or 500kb)
If the user supplies a trailing 'm' or 'mb', I'd want to gather the numeric value and convert it to kb (10m or 10mb).

I'm not sure if there are any easy methods for this type of conditional logic in powershell?
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

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