Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CLS
- $User = Read-Host "Enter Username"
- $Password = Read-Host -AsSecureString "Please enter your password"
- $Password1 = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password))
- Write-Output "This Script will connect to the SLQ Server on servername"
- Write-Output "you will be prompted to enter a value and that value will be inserted into the"
- Write-Output "AdjType_List table inside of the database"
- Write-Host -NoNewLine 'Press any key to continue...';
- $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
- cls
- $Value = Read-Host "Please enter the value you would like inserted"
- Write-Host "That Value you entered is, $Value"
- $Correct = Read-Host "Is the Value Correct?(Y/N)"
- $Correct = $Correct.ToUpper()
- write-host $Correct
- if ($Correct -eq "Y")
- {write-host "The Value $Value will be inserted"
- $insertquery= "INSERT INTO [dbo].[AdjType_List]
- SELECT
- $Value
- GO"
- Invoke-SQLcmd -ServerInstance 'server\nameofserver,port' -query $insertquery -U $User -P $password1 -Database databasename
- }
- else { write-host "the program will now exit" }
- write-host "The Value $Value was successfully inserted"
- Write-Host -NoNewLine 'Press any key to continue...';
- $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement