Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. CLS
  2. $User = Read-Host "Enter Username"
  3. $Password = Read-Host -AsSecureString "Please enter your password"
  4. $Password1 = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password))
  5.  
  6. Write-Output "This Script will connect to the SLQ Server on servername"
  7. Write-Output "you will be prompted to enter a value and that value will be inserted into the"
  8. Write-Output "AdjType_List table inside of the database"
  9. Write-Host -NoNewLine 'Press any key to continue...';
  10. $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
  11. cls
  12. $Value = Read-Host "Please enter the value you would like inserted"
  13. Write-Host "That Value you entered is, $Value"
  14. $Correct = Read-Host "Is the Value Correct?(Y/N)"
  15. $Correct = $Correct.ToUpper()
  16. write-host $Correct
  17. if ($Correct -eq "Y")
  18. {write-host "The Value $Value will be inserted"
  19. $insertquery= "INSERT INTO [dbo].[AdjType_List]
  20. SELECT
  21. $Value
  22. GO"
  23. Invoke-SQLcmd -ServerInstance 'server\nameofserver,port' -query $insertquery -U $User -P $password1 -Database databasename
  24. }
  25. else { write-host "the program will now exit" }
  26. write-host "The Value $Value was successfully inserted"
  27. Write-Host -NoNewLine 'Press any key to continue...';
  28. $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement