Last active
June 9, 2018 10:00
-
-
Save mikerodionov/881e02e338365d9016d368ba4e2291ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run Install-Module -Name SqlServer if module is not present on your system | |
Import-Module SqlServer | |
# Set up connection and database SMO objects | |
$password = "<replace with your password>" | |
$sqlConnectionString = "Data Source=70-473-sql-server.database.windows.net;Initial Catalog=AZ_DB_TEST_BASIC;User ID=Mikhail;Password=$password;MultipleActiveResultSets=False;Connect Timeout=30;Encrypt=True;TrustServerCertificate=False;Packet Size=4096;Application Name=`"Microsoft SQL Server Management Studio`"" | |
$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].[Subscribers] | |
$encryptionChanges += New-SqlColumnEncryptionSettings -ColumnName dbo.Subscribers.CreditCardNumber -EncryptionType Deterministic -EncryptionKey "CEK_Auto1" | |
Set-SqlColumnEncryption -ColumnEncryptionSettings $encryptionChanges -InputObject $smoDatabase |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment