Advertisement
Guest User

Untitled

a guest
Sep 27th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. Function MyFunction{
  2. Param
  3. (
  4. [string]$S = "MyServer",
  5. [string]$U,
  6. [string]$P
  7. )
  8. # Find the SQL Engine version
  9. $Q = "select serverproperty('ProductVersion')"
  10.  
  11. if($U)
  12. {
  13. $R = Invoke-Sqlcmd -ServerInstance $S -Query $Q -Username $U -Password $P -Verbose
  14. Write-Host "SQL Athenticated"
  15. }
  16. else
  17. {
  18. $R = Invoke-Sqlcmd -ServerInstance $S -Query $Q -Verbose
  19. Write-Host "Windows Athenticated"
  20. }
  21. return $R.column1
  22. }
  23.  
  24. Invoke-Expression "$R = Invoke-Sqlcmd -ServerInstance $S -Query $Q $(if($true){""-Username $U -Password $P""})"
  25.  
  26. Function MyFunction{
  27. Param
  28. (
  29. [string]$S = "xps15",
  30. [string]$U,
  31. [string]$P
  32. )
  33. # Find the SQL Engine version
  34. $Q = "select serverproperty('ProductVersion')"
  35. $auth=@{}
  36. if($U){$auth=@{UserName=$U;Password=$P}}
  37. $R = Invoke-Sqlcmd -ServerInstance $S -Query $Q -Verbose @Auth
  38. return $R.column1
  39. }
  40.  
  41. Function MyFunction{
  42. Param
  43. (
  44. [string]$S = "MyServer",
  45. [string]$U,
  46. [string]$P
  47. )
  48. # Find the SQL Engine version
  49. $Q = "select serverproperty('ProductVersion')"
  50.  
  51. if($U)
  52. {
  53. $auth=@{UserName=$u;Password=$p}
  54. Write-Host "SQL Authenticated"
  55. }
  56. else
  57. {
  58. $auth=@{}
  59. Write-Host "Windows Authenticated"
  60. }
  61. $R = Invoke-Sqlcmd -ServerInstance $S -Query $Q -Verbose @Auth
  62. return $R.column1
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement