title: Powershell Workflows
body: <p>I wrote a PowerShell workflow that analyses the Excel data and triggers a mail based on the values in Excel.</p>
  
  <p>I have developed a workflow which triggers mail but I'm having trouble in analysing the Excel data, where I couldn’t call the <code>Send-Mail</code> workflow.</p>
  
  <p>Note: column “E-remainder 1” and “F-remainder 2” contains the date of the remainder mail to be sent.</p>
  
  <pre><code>Workflow test {
      $worksheet = InlineScript {
          $objExcel = New-Object -ComObject Excel.Application
          $objExcel.Visible = $false
          $WorkBook = $objExcel.Workbooks.Open(#filepath)
          $worksheet = $workbook.Sheets.Item(#sheetname)
          $currentdate = (Get-Date).ToString()
  
          $rownumber = #contains rownumber from excel whose details has to be mailed
  
          foreach ($i in $rownumbers) {
              if ($worksheet.Range("B$i").Text -eq $currentdate) {
                  $output = [PSCustomObject][ordered]@{
                      ComputerName = $WorkSheet.Range("C$i").Text
                      Fromaddress = $WorkSheet.Range("D$i").Text
                      Toaddress = $WorkSheet.Range("E$i").Text
                  }
                  # I need to call a workflow which sends a mail
                  # (workflow which I have to trigger mail)
                  Send-Mail -To $output.Toaddress -From $output.Fromaddress -Name $output.ComputerName
              } elseif ($worksheet.Range("F$i").Text -eq $currentdate) {
                  $output = [pscustomobject][ordered]@{
                      ComputerName = $WorkSheet.Range("C$i").Text
                      Fromaddress = $WorkSheet.Range("D$i").Text
                      Toaddress = $WorkSheet.Range("E$i").Text
                  }
                  # I need to call a workflow which sends a mail
                  # (Based on my knowledge I know that we couldn't call a workflow inside the inline script)
                  Send-Mail -To $output.Toaddress -From $output.Fromaddress -Name $output.ComputerName
              }
          } # foreach ends
      } # Inline ends
  } # workflow ends
  </code></pre>
  
  <p>Im getting the following error:</p>
  
  <blockquote>
    <p>ERROR:The term "Send-Mail" is not recognized as the name of the cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.</p>
  </blockquote>