Skip to content

Instantly share code, notes, and snippets.

big permz energy

Chrissy LeMaire potatoqualitee

big permz energy
View GitHub Profile
potatoqualitee / sap_help_revlogin.sql
Last active August 29, 2015 14:04
View sap_help_revlogin.sql
-- Downloaded from
EXEC('IF OBJECT_ID (''sp_hexadecimal'') IS NOT NULL DROP PROCEDURE sp_hexadecimal')
@binvalue varbinary(256),
@hexvalue varchar (514) OUTPUT
DECLARE @charvalue varchar (514)
DECLARE @i int
DECLARE @length int
potatoqualitee / Restore-HallengrenBackups.ps1
Last active August 29, 2015 14:06
View Restore-HallengrenBackups.ps1
Restores SQL Server databases from the backup directory structure created by Ola Hallengren's database maintenance scripts.
Many SQL Server database administrators use Ola Hallengren's SQL Server Maintenance Solution which can be found at
Hallengren uses a predictable backup structure which made it relatively easy to create a script that can restore an entire SQL Server database instance, down to the master database (next version), to a new server. This script is intended to be used in the event that the originating SQL Server becomes unavailable, thus rendering my other SQL restore script ( ineffective.
Required. The SQL Server to which you will be restoring the databases.
View gist:7fbfbd0976bace497838
1. Took note at the exact version of SQL Server, down to the build number
2. Made backups of all databases, including the system databases
3. Stopped the SQL server role within the Failover Cluster Manager
4. Once the disks went offline within Windows, took a storage-level snapshot of the shared disks. I named this snap “ent version”.
5. Copied the system databases, and their logs (mdfs and ldfs) to backup directories just in case the snapshot didn’t work (one can never be too safe)
6. Used VMware to snapshot both Windows nodes (alternatively, you can shut them down and snap them at the storage level)
7. Uninstalled SQL Server from both nodes using the Remove Node from Cluster option. This will delete the system dbs, but not the user dbs.
8. Deleted templog.ldf from my system directory (it was the only one that the uninstall didn’t get rid of)
9. Reinstalled SQL Server Standard exactly as Enterprise was before on both nodes – down to the IP, service account, name, directory structure, filestream share etc.
potatoqualitee / SQL Server ISO 3166.sql
Created October 15, 2014 12:23
SQL Server ISO 3166
View SQL Server ISO 3166.sql
CREATE TABLE countries (
code char(2) PRIMARY KEY NOT NULL,
name_en nvarchar(255),
name_fr nvarchar(255),
INSERT INTO countries VALUES ('AD','Andorra','Andorre'),('AE','United Arab Emirates','Émirats arabes unis'),('AF','Afghanistan','Afghanistan'),('AG','Antigua and Barbuda','Antigua-et-Barbuda'),('AI','Anguilla','Anguilla'),('AL','Albania','Albanie'),('AM','Armenia','Arménie'),('AO','Angola','Angola'),('AQ','Antarctica','Antarctique'),('AR','Argentina','Argentine'),('AS','American Samoa','Samoa américaine'),('AT','Austria','Autriche'),('AU','Australia','Australie'),('AW','Aruba','Aruba'),('AX','Åland Islands','Îles d''Åland'),('AZ','Azerbaijan','Azerbaïdjan'),('BA','Bosnia and Herzegovina','Bosnie-Herzégovine'),('BB','Barbados','Barbade'),('BD','Bangladesh','Bangladesh'),('BE','Belgium','Belgique'),('BF','Burkina Faso','Burkina Faso'),('BG','Bulgaria','Bulgarie'),('BH','Bahrain','Bahreïn'),('BI','Burundi','Burundi'),('BJ','Benin','Bénin'),('BL','Saint Barthélemy','Saint-Barthélemy'),('BM','Bermud
View csvtodt.csv
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
$csvfile = "C:\perf\bigperf.csv"
$csvfile = "C:\perf\tab.csv"
$csvdelimiter = "`t" # `t for tab
$firstrowcolumnnames = $false
Write-Output "Script started..."
$elapsed = [System.Diagnostics.Stopwatch]::StartNew()
$csv = New-Object Microsoft.VisualBasic.FileIO.TextFieldParser($csvfile)
potatoqualitee / Get-LocateLite.ps1
Created January 23, 2015 12:55
View Get-LocateLite.ps1
$GetDll = $true
if ($PSScriptRoot) { $location = $PSScriptRoot } else { $location = (Get-Location).Path }
$dll = "$location\System.Data.SQLite.dll"
if ($GetDll) {
$wc = New-Object System.Net.WebClient
$url = ""
View Join-AdminUNC.ps1
Function Join-AdminUNC {
Parses a path to make it an admin UNC.
Join-AdminUNC sqlserver C:\windows\system32
Output: \\sqlserver\c$\windows\system32
potatoqualitee / New-TextIcon.ps1
Created September 14, 2015 15:09
Creates Text Icon. Useful for NotifyIcons.
View New-TextIcon.ps1
Function New-TextIcon {
[int]$Height = 16,
[int]$Width = 16,
[int]$FontSize = 9
potatoqualitee / Show-SystemColors.ps1
Last active September 16, 2015 10:25
PowerShell function Show-SystemColor to get GUI list of System.Windows.SystemColors
View Show-SystemColors.ps1
Function Show-SystemColors {
Shows a visual representation (grid with color block, name, and hex code)) of system colors.
Author : Chrissy LeMaire
Requires: PowerShell 3.0
Version: 1.0
DateUpdated: 2015-Sep-16
potatoqualitee / Show-WPFExample.ps1
Created November 27, 2015 11:29
WPF + PowerShell + SQL super simple example
View Show-WPFExample.ps1
# Load WPF Assemblies
Add-Type -AssemblyName PresentationFramework
# Get the info you need from SQL Server
$sqlserver = "sqlserver2014a"
$query = "select name from master.dbo.sysdatabases order by name"
$conn = New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = "Data Source=$sqlserver;Integrated Security=True;Connection Timeout=3"