Skip to content

Instantly share code, notes, and snippets.

View SQLDBAWithABeard's full-sized avatar
🦄
Generally bearding

Rob Sewell SQLDBAWithABeard

🦄
Generally bearding
View GitHub Profile
CREATE EVENT SESSION [MonitorWindowsLogins] ON SERVER
ADD EVENT sqlserver.login(
ACTION(sqlserver.client_hostname,sqlserver.database_name,sqlserver.session_id,sqlserver.session_nt_username,sqlserver.session_server_principal_name)
WHERE ([sqlserver].[not_equal_i_sql_unicode_string]([sqlserver].[session_nt_user],N'')
AND [sqlserver].[not_equal_i_sql_unicode_string]([sqlserver].[session_server_principal_name],N'THEBEARD\gsartori')
AND [sqlserver].[not_equal_i_sql_unicode_string]([sqlserver].[session_server_principal_name],N'THEBEARD\wdurkin')
AND [sqlserver].[not_equal_i_sql_unicode_string]([sqlserver].[session_server_principal_name],N'THEBEARD\Rob')
AND [sqlserver].[session_nt_user]<>N'THEBEARD\gfritchey'
AND [sqlserver].[session_server_principal_name]<>N'THEBEARD\SQL_SVC'
AND [sqlserver].[session_server_principal_name]<>N'THEBEARD\SQL2014SER12R2$'))
function Calm {
for ($i = 0; $i -le 4; $i++) {
$x = 1
while ($x -le 4) {
"In through the nose - $x"
Start-Sleep -Seconds 1
$x ++
}
$x = 1
while ($x -le 7) {
@SQLDBAWithABeard
SQLDBAWithABeard / DMA PowerShell notebook.ipynb
Last active June 29, 2022 01:46
DMA PowerShell and Azure Data Studio Notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLDBAWithABeard
SQLDBAWithABeard / pesterwontrun.ipynb
Last active February 22, 2020 13:18
Pester wont run
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLDBAWithABeard
SQLDBAWithABeard / dbatools.ipynb
Created February 7, 2020 10:41
.NET Notebooks
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLDBAWithABeard
SQLDBAWithABeard / fail.ipynb
Created February 7, 2020 09:09
Failing .NET POwerShell Notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLDBAWithABeard
SQLDBAWithABeard / weird.ipynb
Last active January 30, 2020 21:19
strange behaviour in PowerShell Notebook with function and comment code
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLDBAWithABeard
SQLDBAWithABeard / luhn.ipynb
Created January 30, 2020 20:46
Because Bob is awesome - Even my wife says so
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLDBAWithABeard
SQLDBAWithABeard / task.ps1
Created January 12, 2020 19:52
cert code
$ErrorActionPreference = 'Stop'
# read in the certificate from a pre-existing PFX file
# I have checked this with IISResetMe and this does not go in the store only memory
$cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new("$(Agent.WorkFolder)\_temp\dbatools-code-signing-cert.pfx","$(CertPassword)")
try {
Write-Output "Signing Files"
# find all scripts in your module...
Get-ChildItem -Filter *.ps1 -Include *.ps1 -Recurse -ErrorAction SilentlyContinue |
# ...that do not have a signature yet...
@SQLDBAWithABeard
SQLDBAWithABeard / odd.ps1
Last active January 8, 2020 16:25
For Mathias's poor eyes
$Pattern = 'SPN'
$script:localapp = Get-DbcConfigValue -Name app.localapp
if ($Pattern) {
if ($Pattern -notmatch '\*') {
@(Get-Content "$script:localapp\checks.json" | Out-String | ConvertFrom-Json).ForEach{
$output = $psitem | Where-Object {
$_.Group -match $Pattern -or $_.Description -match $Pattern -or
$_.UniqueTag -match $Pattern -or $_.AllTags -match $Pattern -or $_.Type -match $Pattern
}
}