Skip to content

Instantly share code, notes, and snippets.

View potatoqualitee's full-sized avatar
big permz energy

Chrissy LeMaire potatoqualitee

big permz energy
View GitHub Profile
@potatoqualitee
potatoqualitee / CSVSQL.ps1
Created May 6, 2015 04:11
Query CSV with SQL
# See PowerShell Magazine article at .....
$jet = (New-Object System.Data.OleDb.OleDbEnumerator).GetElements() | Where-Object { $_.SOURCES_NAME -eq "Microsoft.Jet.OLEDB.4.0" }
if ($jet -eq $null) {
if ($env:Processor_Architecture -ne "x86") {
&"$env:windir\syswow64\windowspowershell\v1.0\powershell.exe"
}
}
$csv = "$env:TEMP\top-tracks.csv"
Invoke-WebRequest http://git.io/vvzxA | Set-Content -Path $csv
$firstRowColumnNames = "Yes"
@potatoqualitee
potatoqualitee / java final
Created December 31, 2015 20:42
Java final
/**
Convert to Roman Numerals
Author: Chrissy LeMaire
Cohort: M0706
FINAL PROJECT
Last Changed: March 10, 2007.
*/
import java.*;
import java.util.*;
@potatoqualitee
potatoqualitee / Upvote this connect item.txt
Created March 7, 2016 13:32
Help get SQLPS Open Sourced and on GitHub
https://connect.microsoft.com/SQLServer/feedback/details/2442788/open-source-sqlps-and-publish-code-on-github
@potatoqualitee
potatoqualitee / apache-likewise-beyondtrust-sso.txt
Last active April 11, 2016 11:13
Apache with BeyondTrust/Likewise Kerberos SSO on Ubuntu
apt-get -y install apache2 libapache2-mod-auth-kerb ntp ntpdate
# make sure time is synced. If behind a fw, use local time server like a DC
service ntp stop
ntpdate -s ntp.ubuntu.com
service ntp start
# Go get the beyondtrust (formerly Likewise) package
wget http://download.beyondtrust.com/PBISO/8.3/pbis-open-8.3.0.3287.linux.x86_64.deb.sh
chmod +x pbis-open-8.3.0.3287.linux.x86_64.deb.sh
@potatoqualitee
potatoqualitee / sssd-kerberos-smb-active-directory-ubuntu.txt
Last active April 26, 2016 07:49
Join Ubuntu 15.10 to a Windows Active Directory Domain
<#
Detailed blog: https://blog.netnerds.net/2016/04/joining-ubuntu-to-an-active-directory-domain/
In this example:
1. Fresh install of Ubuntu 15.10 Server
2. DNS is set to AD’s DNS servers
3. The Active Directory domain is base.local
4. The test user is base\adadmin, which has domain admin privs on AD
#>
@potatoqualitee
potatoqualitee / test-user.ps1
Last active May 8, 2016 10:05
test if user exists
# Local user
$account = New-Object System.Security.Principal.NTAccount('WorkstationX\Administrator')
$sid = $account.Translate([System.Security.Principal.SecurityIdentifier])
# Domain User
$account = New-Object System.Security.Principal.NTAccount('base\ctrlb')
$sid = $account.Translate([System.Security.Principal.SecurityIdentifier])
# This too, but dang is it slow
Get-CimInstance -ClassName Win32_UserAccount -Filter "Caption='base\\ctrlb'"
@potatoqualitee
potatoqualitee / bulkcopy.ps1
Created January 1, 2016 01:32
sql-to-sql powershell bulkcopy import speedtest
# Setup runspace pool and the scriptblock that runs inside each runspace
$pool = [RunspaceFactory]::CreateRunspacePool(1,5)
$pool.Open()
$jobs = @()
# This is the workhorse.
$scriptblock = {
$source = "Data Source=sqlserver;Integrated Security=True;Connection Timeout=3;Initial Catalog=pssqlbulkcopy"
$dest = "Data Source=sql2016;Integrated Security=True;Connection Timeout=3;Initial Catalog=pssqlbulkcopy"
$conn = New-Object System.Data.SqlClient.SqlConnection
@potatoqualitee
potatoqualitee / LoginReport.ps1
Last active May 11, 2016 15:19
SQL Login Report in PowerShell
# Solution for http://powershell.com/cs/forums/t/23737.aspx
[void][Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO")
$server = New-Object Microsoft.SqlServer.Management.Smo.Server "sqlserver"
$servername = $server.netname
$sqlinstancename = $server.DomainInstanceName
$dbs = $server.databases | Where-Object { 'tempdb','Pubs','Northwind','model' -notcontains $_.Name }
$loginreport = @()
foreach ($db in $dbs) {
$users = $db.users | Where-Object { 'guest','sys','INFORMATION_SCHEMA'-notcontains $_.Name -and $_.Name -notlike '*##*' -and $_.Name -notlike '*$*' -and $_.Name -ne $null }
@potatoqualitee
potatoqualitee / sp_help_revlogin2.ps1
Created August 15, 2014 08:20
sp_help_revlogin2.ps1
$source = "sqlserver"
$destination = "sqlcluster"
$smo = [Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO")
$smoext = [Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMOExtended")
$sourceserver = New-Object Microsoft.SqlServer.Management.Smo.Server $source
$destserver = New-Object Microsoft.SqlServer.Management.Smo.Server $destination
foreach ($sourcelogin in $sourceserver.logins) {
@potatoqualitee
potatoqualitee / dbatools-startmigration-transcript.txt
Created May 16, 2016 20:47
SQL Server Instance Migration Transcript from Start-SqlMigration (dbatools.io)
**********************
Windows PowerShell transcript start
Start time: 20160516223036
Username: BASE\ctrlb
RunAs User: BASE\ctrlb
Machine: NIMY (Microsoft Windows NT 10.0.14328.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Process ID: 6208
PSVersion: 5.1.14328.1000
PSEdition: Desktop