Skip to content

Instantly share code, notes, and snippets.

View lennybacon's full-sized avatar
🏠
Working from home

Daniel Fisher lennybacon

🏠
Working from home
View GitHub Profile
@lennybacon
lennybacon / RemoveFiddlerCertificates.ps1
Last active April 26, 2020 21:17
Remove Fiddler Certificates
Get-ChildItem Cert:\CurrentUser\My
| Where-Object {$_.Issuer -eq 'CN=DO_NOT_TRUST_FiddlerRoot, O=DO_NOT_TRUST, OU=Created by http://www.fiddler2.com'}
| Remove-Item;
# Requires user interaction
#Get-ChildItem Cert:\CurrentUser\Root
#| Where-Object {$_.Issuer -eq 'CN=DO_NOT_TRUST_FiddlerRoot, O=DO_NOT_TRUST, OU=Created by http://www.fiddler2.com'}
#| Remove-Item;
# Requires user interaction
@lennybacon
lennybacon / RemoveFiddlerCertificatesOnStartUpTask.xml
Last active April 26, 2020 21:16
Remove Fiddler Certificates on Start Up Task
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2018-02-17T10:29:54.0880708</Date>
<Author>.\Administrator</Author>
<URI>\CleanUp\Remove Fiddler Certificates on StartUp</URI>
</RegistrationInfo>
<Triggers>
<LogonTrigger>
<Enabled>true</Enabled>
@lennybacon
lennybacon / Customize-Windows.ps1
Last active March 9, 2020 08:13
Customize Windows after First Start
Write-Host "Disable Telemetry" -ForegroundColor Cyan;
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name AllowTelemetry -PropertyType DWord -Value 0 -force | Out-Null;
Stop-Service DiagTrack | Out-Null;
Set-Service DiagTrack -startupType Disabled | Out-Null;
Stop-Service dmwappushservice | Out-Null;
Set-Service dmwappushservice -startupType Disabled | Out-Null;
Write-Host "Add Developer Exclusions For Windows Defender" -ForegroundColor Cyan;
Add-MpPreference -ExclusionProcess "light.exe" | Out-Null;
Add-MpPreference -ExclusionProcess "candel.exe" | Out-Null;
@lennybacon
lennybacon / update-visualstudio.ps1
Last active January 16, 2020 10:50
Update all visual studio editions and instances equal or above 2017
$EventLogSourceName = "Visual Studio Updater"
if([System.Diagnostics.EventLog]::SourceExists($EventLogSourceName) -eq $false){
New-EventLog –LogName Application –Source $EventLogSourceName
}
$cacheDirs = @(
"C:\Program Files (x86)\Microsoft Visual Studio\Installer"
#"C:\ProgramData\Microsoft\VisualStudio\Packages",
#"C:\ProgramData\Microsoft\VisualStudio\Setup"
);
@lennybacon
lennybacon / Reboot-IfNecessary.ps1
Created January 16, 2020 10:38
Detect a pending reboot and restart computer
$registryKey = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired");
if ($null -ne $registryKey){
if ($registryKey.GetValueNames().Length -ne 0) {
Write-Host "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired indicates a pending reboot.";
Write-EventLog –LogName Application –Source $EventLogSourceName –EntryType Information –EventID 99 –Message "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired indicates a pending reboot.";
Restart-Computer -Force
}
}
$registryKey = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Updates");
@lennybacon
lennybacon / sql_2019_unattended.ps1
Last active November 7, 2019 08:31
Install Microsoft SQL Server 2019 unattended
$setupPath = ".\Setup.exe";
$productKey = "XXX";
$instanceName = "MSSQLSERVER";
$version = "2019";
$collation = "Latin1_General_CI_AS";
$serviceAccount = "";
$serviceAccountPassword = "";
$currentUser = [System.Environment]::UserDomainName + "\" + [System.Environment]::UserName;
$sqlAdminAccount = "";
$sqlAdminGroup = "";
@lennybacon
lennybacon / Install-VsixExtension.ps1
Last active October 17, 2019 15:24
Unattended install of Wix Toolset Visual Studio 2017 Extension
$extensionDisplayName = "Wix Toolset Visual Studio 2017 Extension";
$extensionApiVersion = "api-version=3.2-preview.1"
$marketplaceQueryUrl = "https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery";
$extensionQuery = "{`"flags`":`"262`"," +
"`"filters`":[" +
"{" +
"`"criteria`":" +
"[" +
"{`"filterType`":`"14`",`"value`":`"1033`"}," +
@lennybacon
lennybacon / Set-LnkToRunAsAdmin.ps1
Created June 28, 2019 06:51
Modify Link to run as admin
$linkFilePath = "C:\Users\$([Environment]::UserName)\Desktop\WindowsTerminal.lnk"
$bytes = [System.IO.File]::ReadAllBytes($linkFilePath)
$bytes[0x15] = $bytes[0x15] -bor 0x20 #set byte 21 (0x15) bit 6 (0x20) ON
[System.IO.File]::WriteAllBytes($linkFilePath, $bytes)
@lennybacon
lennybacon / GenerateMachineKey.targets
Last active October 16, 2019 09:04
Machine Key Section validation and decryption key rotation on build
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask
TaskName="GenerateMachineKey"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
<ParameterGroup />
<Task>
<Reference Include="System.Xml"/>
<Using Namespace="System"/>
@lennybacon
lennybacon / Add-Windowes DefenderExclusionsForVisualStudio.ps1
Last active September 18, 2019 08:11
Windowes Defender Exclusions for Visual Studio and DevOps Build Agents
# .NET
Add-MpPreference -ExclusionPath "%WINDIR%\Microsoft.NET\"
Add-MpPreference -ExclusionPath "%WINDIR%\assembly"
# Visual Studio
Add-MpPreference -ExclusionProcess "devenv.exe"
Add-MpPreference -ExclusionProcess "msbuild.exe"
Add-MpPreference -ExclusionProcess "VBCSCompiler.exe"
Add-MpPreference -ExclusionPath "%ProgramFiles(x86)%\Microsoft SDKs\"
Add-MpPreference -ExclusionPath "%ProgramFiles(x86)%\Microsoft Visual Studio\"