Skip to content

Instantly share code, notes, and snippets.

View SQLvariant's full-sized avatar

Aaron Nelson SQLvariant

View GitHub Profile
@Jaykul
Jaykul / Measure-CommandEx.ps1
Last active June 22, 2022 05:29
We need a better Measure-Command which can show averages
function Measure-CommandEx {
<#
.SYNOPSIS
A from-scratch approach to timing command execution using Stopwatch
#>
[CmdletBinding()]
param(
# The command to test (accepts value from pipeline)
[Parameter(ValueFromPipeline)]
[ScriptBlock[]]$Command,
-- TRANSLATE() and STRING_SPLIT() work with SQL Server 2016+, STRING_AGG() with 2017+.
-- language_id=1033 is English (simplified)
SELECT STRING_AGG(REPLACE(TRANSLATE(s.[value] COLLATE database_default, '():.,-/='';', '**********'), '*', ''), ' ')
FROM sys.messages AS msg
CROSS APPLY STRING_SPLIT(msg.[text], ' ') AS s
WHERE msg.language_id=1033
--AND s.[value] COLLATE database_default NOT IN ('the', 'is', 'to', 'not', 'a', 'for', 'in', 'be', 'of', 'or', 'cannot', 'and')
AND s.[value] COLLATE database_default NOT LIKE '%[%@=]%'
GROUP BY msg.message_id
#------------------------------------------------------------------------
# Source File Information (DO NOT MODIFY)
# Source ID: 9ad32074-7adb-4822-a049-93600f966aa9
# Source File: ..\Documents\SAPIEN\Projects\Gui-SSRS-Deploy\Gui-SSRS-Deploy.psproj
#------------------------------------------------------------------------
#region Project Recovery Data (DO NOT MODIFY)
<#RecoveryData:
CAIAAB+LCAAAAAAABACNkV1rgzAUhu8L/Q/ifepHxU6IuVhdyy72QS27Had6HBkxkUTH/PeLU4dl
MHb5JO95XnJCT1ioD9R9Bi2w9cpx6LNW71i032DxBbXhSrJgE1BvhunuwAXeZyyBchv6u4jsoLyQ
6CYMCfhRQpJt7PtVEscACfWm8DQ6tZz7BplPvSXOciVKW+d4yzYzwYTOCSvUKAt8hBpT13VuOy7K
# USE THIS SCRIPT TO UPLOAD LARGE .PBIX FILES TO POWER BI REPORT SERVER
#
# I needed to manually construct the form-data as PowerShell doesn't appear to have full support for
# this yet, though it appears to be coming soon.
#CREDENTIALS
[string]$userName = 'BIWIN\MS'
[string]$userPassword = 'xxxxxxxxxxxxx'
[securestring]$secStringPassword = ConvertTo-SecureString $userPassword -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($userName, $secStringPassword)
@halkyon
halkyon / cleanup-win10.ps1
Last active February 6, 2024 09:09
Cleanup Windows 10 Powershell script
##
## Windows 10 cleanup script.
## Remove dodgy tracking settings, unneeded services, all apps, and optional features that come with Windows 10. Make it more like Windows 7.
## NOTE: this was tested on Creators Update (1703) and Fall Creators Update (1709). Some of this may not work as expected on newer versions.
##
## Instructions
## 1. Run this script (under Powershell as Administrator):
## powershell -ExectionPolicy Bypass .\cleanup-win10.ps1
## 2. Let it run through, you may see a few errors, this is normal
## 3. Reboot
@NickCraver
NickCraver / Windows10-Setup.ps1
Last active April 1, 2024 10:52
(In Progress) PowerShell Script I use to customize my machines in the same way for privacy, search, UI, etc.
##################
# Privacy Settings
##################
# Privacy: Let apps use my advertising ID: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0
# To Restore:
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 1
# Privacy: SmartScreen Filter for Store Apps: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 0