Skip to content

Instantly share code, notes, and snippets.

@chenbojian
chenbojian / UserRights.psm1
Created September 1, 2020 08:45
UserRights.psm1
<# -- UserRights.psm1 --
The latest version of this script is available at https://gallery.technet.microsoft.com/Grant-Revoke-Query-user-26e259b0
VERSION DATE AUTHOR
1.0 2015-03-10 Tony Pombo
- Initial Release
1.1 2015-03-11 Tony Pombo
- Added enum Rights, and configured functions to use it
USE [master]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================

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
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"
function Set-TrustAllCertsPolicy {
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;
}
@chenbojian
chenbojian / openssl-cert-chain.sh
Last active March 25, 2023 02:31
Certificate Chain
#Generate CA Certificate
#Generate private Key
openssl genrsa -out CA.key 2048
#Generate CA CSR
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.chenbojian.jupyter</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/jupyter</string>
<string>notebook</string>
@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