Skip to content

Instantly share code, notes, and snippets.

@chenbojian
chenbojian / TDE.sql
Last active September 29, 2020 09:18
TDE
USE master;
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '<UseStrongPasswordHere>';
go
CREATE CERTIFICATE TDECert WITH SUBJECT = 'TDE Certificate';
go
----------------
USE [DB-local];
GO
CREATE DATABASE ENCRYPTION KEY
# ref: https://docs.microsoft.com/en-us/iis/configuration/system.applicationhost/sites/site/logfile/
# ref: https://forums.iis.net/t/1205491.aspx?Add+IIS+8+5+Custom+Logging+Fields+with+Powershell
function Set-WebSiteIISLogFormat {
param (
$Site
)
$logExtFileFlags = 'Date,Time,ClientIP,UserName,ServerIP,Method,UriStem,UriQuery,HttpStatus,Win32Status,TimeTaken,ServerPort,UserAgent,Referer,Host,HttpSubStatus'
Set-ItemProperty -Path "IIS:\Sites\$Site" -Name logfile.logExtFileFlags -Value $logExtFileFlags
--https://dba.stackexchange.com/questions/20355/generate-create-script-for-all-indexes
declare @SchemaName varchar(100)declare @TableName varchar(256)
declare @IndexName varchar(256)
declare @ColumnName varchar(100)
declare @is_unique varchar(100)
declare @IndexTypeDesc varchar(100)
declare @FileGroupName varchar(100)
declare @is_disabled varchar(100)
declare @IndexOptions varchar(max)
declare @IndexColumnId int
--https://dba.stackexchange.com/questions/20355/generate-create-script-for-all-indexes
DECLARE @SchemaName VARCHAR(256)DECLARE @TableName VARCHAR(256)
DECLARE @IndexName VARCHAR(256)
DECLARE @TSQLDropIndex VARCHAR(MAX)
DECLARE CursorIndexes CURSOR FOR
SELECT schema_name(t.schema_id), t.name, i.name
FROM sys.indexes i
INNER JOIN sys.tables t ON t.object_id= i.object_id
WHERE i.type>0 and t.is_ms_shipped=0 and t.name<>'sysdiagrams'

Get windows installed applications with powershell

$x86Path = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
$installedItemsX86 = Get-ItemProperty -Path $x86Path | Select-Object -Property DisplayName, PSChildName
$x64Path = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
$installedItemsX64 = Get-ItemProperty -Path $x64Path | Select-Object -Property DisplayName, PSChildName
$installedItems = $installedItemsX86 + $installedItemsX64
$installedItems | Where-Object -FilterScript { $_.DisplayName -like "Microsoft SQL Server Management Studio*" } | Sort-Object -Property DisplayName | fl
USE [master]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
SELECT
msp.publication AS PublicationName,
msa.publisher_db AS DatabaseName,
msa.article AS ArticleName,
msa.source_owner AS SchemaName,
msa.source_object AS TableName
FROM distribution.dbo.MSarticles msa
JOIN distribution.dbo.MSpublications msp ON msa.publication_id = msp.publication_id
ORDER BY
msp.publication,
taskkill /F /FI "SERVICES eq tomcat8"
Add-Type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}