mardi 30 août 2016

Greater than issue

I am trying to create a function that asks the user to input the size of a drive and if the drive size is greater then 100 then ask the user to input it again. My script just keeps saying "Cannot ask for more then 100gb" even if the user inputs 50.

Here is my script param ( [string]$MaxC = "100" )

function cDrive {

$C_DiskGB = Read-Host "C: Drive - Disk Size in GB"
    if ($C_DiskGB -gt $MaxC) {

            Write-Host "Cannot ask for more then 100gb of disk space.  Please re-enter how much disk space you need for the c: drive" 
            cDrive 

         }
    else {

        Write-Host "C: Drive is $C_DiskGB GB" 

         } 

}

The output when i put anything less is: C: Drive - Disk Size in GB: 50 Cannot ask for more then 100gb of disk space. Please re-enter how much disk space you need for the c: drive C: Drive - Disk Size in GB:

Any help is greatly appreciated. Thanks!

Aucun commentaire:

Enregistrer un commentaire