Link to home
Start Free TrialLog in
Avatar of WeTi
WeTi

asked on

Powershell scripting

Dear Expert

I need help with reading and understanding the Powershell if statement, please read the statement below.

What I understand is:
If $months is 1 do this {
I dont understand the -gt? what is -gt?
$months +1
This I understand, variable months +1
0..$months | % {
This I dont understand 0..? Something and do follow.
$dateQuery = ( get-date (get-date $dateFilter).AddMonths( -1 ) )
This I understand partly, variable $dateQuery will get, get-date as command in PS, and () inside here I don't understand, and it addmonths -1 means it minus 1
if ( (get-date $dateQuery) -le (get-date) ) {
This I understand mostly but what is -le?
$sqlArr += f_sqlquery $dateQuery $SQLDBName
This I understand.
} else {
      $sqlArr += f_sqlquery $dateFilter $SQLDBName
This I understand.

if ($months -gt 1) {
      $months++
      0..$months | % {
            $dateQuery = ( get-date (get-date $dateFilter).AddMonths( -1 ) )
            if ( (get-date $dateQuery) -le (get-date) ) {
                  $sqlArr += f_sqlquery $dateQuery $SQLDBName
            }
      }
} else {
      $sqlArr += f_sqlquery $dateFilter $SQLDBName
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
Avatar of WeTi
WeTi

ASKER

great explained thanks