forked from cloudfoundry-samples/spring-music
/
encrypt.ps1
25 lines (16 loc) · 1.26 KB
/
encrypt.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Generated by SQL Server Management Studio at 7:08 PM on 6/18/2018
Import-Module SqlServer
# Set up connection and database SMO objects
$password = "<replace with your password>"
$sqlConnectionString = "Data Source=u91038d43430.database.windows.net;Initial Catalog=u3b3afa7779b;User ID=ue0282ace92d;Password=$password;MultipleActiveResultSets=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;Packet Size=4096;Application Name=`"Microsoft SQL Server Management Studio`";Column Encryption Setting=Enabled"
$smoDatabase = Get-SqlDatabase -ConnectionString $sqlConnectionString
# If your encryption changes involve keys in Azure Key Vault, uncomment one of the lines below in order to authenticate:
# * Prompt for a username and password:
#Add-SqlAzureAuthenticationContext -Interactive
# * Enter a Client ID, Secret, and Tenant ID:
#Add-SqlAzureAuthenticationContext -ClientID '<Client ID>' -Secret '<Secret>' -Tenant '<Tenant ID>'
# Change encryption schema
$encryptionChanges = @()
# Add changes for table [dbo].[album]
$encryptionChanges += New-SqlColumnEncryptionSettings -ColumnName dbo.album.release_year -EncryptionType Deterministic -EncryptionKey "CEK_Auto1"
Set-SqlColumnEncryption -ColumnEncryptionSettings $encryptionChanges -InputObject $smoDatabase