Advertisement
Guest User

Get-EmployeeData

a guest
Mar 5th, 2017
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Get-EmployeeData
  2. {
  3.     $employeeID = Read-Host "Please Enter Employee ID"
  4.    
  5.     $firstN = "a.F_N as EI_FN,b.F_N as OI_FN"
  6.     $lastN = "a.L_N as EI_LN,b.L_N as OI_LN"
  7.     $query = "SELECT OFFICE_ID,a.emp_id as EMP_ID,$firstN,$lastN,CITY,STATE,ZIP_CODE "
  8.     $query += "FROM test_org..org_info as a,test_org..emp_info as b "
  9.     $query += "WHERE a.emp_id=$employeeID AND a.emp_id=b.emp_id"
  10.  
  11.     $results = Invoke-SQLCmd -query $query -ServerInstance NSRESQL1
  12.     $empInfoFN = $results.EI_FN
  13.     $offInfoFN = $results.OI_FN
  14.  
  15.     if($empInfoFN -ne $offInfoFN)
  16.     {
  17.         $results | select-object EMP_ID,EI_FN,OI_FN,EI_LN,OI_LN | format-table
  18.         write-host "Data values do not match"
  19.     }
  20.     elseif($empInfoFN -eq $offInfoFN)
  21.     {
  22.         $results | select-object EMP_ID,EI_FN,OI_FN,EI_LN,OI_LN | format-table
  23.         write-host "values match"
  24.     }
  25.     else
  26.     {
  27.         write-host "an error has occurred"
  28.     }
  29. }
  30. Get-EmployeeData
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement