Skip to content

Instantly share code, notes, and snippets.

Avatar
🎉
powershell and chill

Chrissy LeMaire potatoqualitee

🎉
powershell and chill
View GitHub Profile
View swagger.json
{
"openapi": "3.0.0",
"info": {
"title": "Mastodon API",
"description": "This an attempt to document Mastodon's API based on the code in https://github.com/mastodon/mastodon",
"contact": {
"name": "Malcolm VanOrder",
"email": "mvanorder1390@gmail.com"
},
"license": {
View dbatools-getting-started.ps1
# Set some vars
$new = "localhost\sql2016"
$old = $instance = "localhost"
$allservers = $old, $new
# Alternatively, use Registered Servers?
Get-DbaCmsRegServer -SqlInstance $instance | Out-GridView
# Quick overview of commands
Start-Process https://dbatools.io/commands
@potatoqualitee
potatoqualitee / Save-KBFile.ps1
Last active Nov 21, 2022
Download Windows patch files / KB (patchid like KBxxxxx) and save them to disk using PowerShell
View Save-KBFile.ps1
function Save-KBFile {
<#
.SYNOPSIS
Downloads patches from Microsoft
.DESCRIPTION
Downloads patches from Microsoft
.PARAMETER Name
The KB name or number. For example, KB4057119 or 4057119.
View encryption-commands.md

Thanks for attending the session! Here are all of our related security commands:

Add-DbaComputerCertificate              
Backup-DbaComputerCertificate           
Backup-DbaDbCertificate                 
Backup-DbaDbMasterKey                   
Backup-DbaServiceMasterKey              
Disable-DbaDbEncryption                 
Disable-DbaForceNetworkEncryption       
View profile.ps1
function Prompt
{
Write-Host "[" -NoNewline
Write-Host (Get-Date -Format "HH:mm:ss") -ForegroundColor Gray -NoNewline
try
{
$history = Get-History -ErrorAction Ignore
if ($history)
{
@potatoqualitee
potatoqualitee / dbcombobox.ps1
Created Nov 27, 2015
Classic Forms Get-DBComboBox example
View dbcombobox.ps1
$sqlserver = "sqlserver2014a"
Function Get-SqlDatabases {
param(
[Parameter(Mandatory=$true)]
[string]$SqlServer,
[object]$Credential
)
$paramconn = New-Object System.Data.SqlClient.SqlConnection
@potatoqualitee
potatoqualitee / Show-WPFIconExample.ps1
Last active Sep 26, 2022
Toolbar Icons for PowerShell WPF GUI - Updated Jan 7 to support keyboard interaction.
View Show-WPFIconExample.ps1
# THIS CODE CANNOT BE COPY/PASTED INTO THE CONSOLE. PLEASE SAVE IT AS A FILE AND EXECUTE.
# Add required assemblies
Add-Type -AssemblyName PresentationFramework, System.Drawing, System.Windows.Forms, WindowsFormsIntegration
# Setup the XAML
[xml]$script:xaml = '<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="Acadiana (Cajun) Flag" Height="240" Width="320" Background="Gray">
<Window.TaskbarItemInfo>
View winterm.json
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command":
{
"action": "copy",
"singleLine": false
@potatoqualitee
potatoqualitee / lowerright.ps1
Last active Sep 12, 2022
PowerShell WPF popup in lower right corner of the screen
View lowerright.ps1
[xml]$xaml = '<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStyle="None" ResizeMode="NoResize" ShowInTaskbar="False"
Height="0" Width="0" Background="Transparent">
<Popup Name="popup" Placement="AbsolutePoint" StaysOpen="False">
<Grid Name="grid" Height="400" Width="390" Background="DarkGray">
<Label Name="label" Content="Double-click to close" Foreground="White" FontSize="18"/>
</Grid>
</Popup>
View Invoke-Program.ps1
function Invoke-Program {
[CmdletBinding()]
[OutputType([System.Management.Automation.PSObject])]
param
(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$FilePath,
[Parameter()]