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
$tablename = 'BeardTable'
$ColumnMap = @()
$int = New-Object Microsoft.SqlServer.Management.Smo.DataType("Int")
$varchar = New-Object Microsoft.SqlServer.Management.Smo.DataType("varchar")
$datetime = New-Object Microsoft.SqlServer.Management.Smo.DataType("datetime")
$identityColumn = New-Object Microsoft.SqlServer.Management.Smo.Column($table, "Id", $int)
$identityColumn.Nullable = $false
$identityColumn.Identity = $true
@SQLDBAWithABeard
SQLDBAWithABeard / meta.ps1
Last active November 14, 2019 16:05
meta powershell notebook
## This PowerShell will create a PowerShell Notebook which will create a PowerShell Notebook!
# This serves no useful purpose :-)
$introCelltext = "# This notebook will create a notebook"
$SecondCelltext = "### Installation
You can install ADSNotebook from the PowerShell Gallery using `Install-Module ADSNotebook` "
$thirdcelltext = " `$introCelltext = ' # This notebook was created by a notebook '
`$SecondCelltext = '### Installation
You can install ADSNotebook from the PowerShell Gallery using `Install-Module ADSNotebook` '
`$thirdcelltext = 'Install-Module dbatools'
@SQLDBAWithABeard
SQLDBAWithABeard / Creating Notebooks.ps1
Last active November 21, 2019 16:19
Notebooks Creation
$NotebookDirectory = "C:\temp\Notebooks"
$targetfilename = "ADSNotebookIndex.ipynb"
$outputLocation = 'C:\temp\Work'
$NotebookPath = "$($NotebookDirectory)\$targetfilename"
$IntroCellText = "# Notebook Index
Click on the code below the workbook you require to generate your custom version to save results in"
$IntroCell = New-ADSWorkBookCell -Text $IntroCellText -Type Text
#check output path exists
@SQLDBAWithABeard
SQLDBAWithABeard / nuget download.ps1
Created November 26, 2019 14:43
Fixing Azure DevOps Deployment
$Profilepowershellget = "$env:userprofile\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet\"
if(-Not(Test-Path $Profilepowershellget)){
New-Item $Profilepowershellget -ItemType Directory
}
$Url = 'https://dist.nuget.org/win-x86-commandline/v5.1.0/nuget.exe'
$OutputFile = "$Profilepowershellget\nuget.exe"
$StartTime = Get-Date
@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
}
}
@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 / luhn.ipynb
Created January 30, 2020 20:46
Because Bob is awesome - Even my wife says so
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
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
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.