Skip to content

Instantly share code, notes, and snippets.

@debold
debold / Test-Winget.ps1
Created April 4, 2023 08:21
Winget test
$appname = "Git.Git"
$Mode = "Install"
$WingetFile = Get-ChildItem "$env:programfiles\WindowsApps" -Recurse -File | Where-Object { $_.name -like "AppInstallerCLI.exe" -or $_.name -like "Winget.exe" } | Select-Object -ExpandProperty fullname
switch ($Mode) {
"Install" {
# Install
try { $response = &"$WingetFile" install --id $appname --silent --log "$($env:Temp)\$($appname).log" --accept-package-agreements --accept-source-agreements --force --disable-interactivity } catch {}
}
@debold
debold / Set-HyperVDedupSchedule.ps1
Created March 8, 2022 14:45
Change the dedup schedule for Hyper-V (clusters) to run outside business hours
# Reference: https://docs.microsoft.com/en-us/windows-server/storage/data-deduplication/advanced-settings
Set-DedupSchedule -Name BackgroundOptimization -Enabled $false
Set-DedupSchedule -Name PriorityOptimization -Enabled $false
Get-DedupSchedule -Type GarbageCollection | ForEach-Object { Remove-DedupSchedule -InputObject $_ }
Get-DedupSchedule -Type Scrubbing | ForEach-Object { Remove-DedupSchedule -InputObject $_ }
New-DedupSchedule -Name "NightlyOptimization" -Type Optimization -DurationHours 11 -Memory 100 -Cores 100 -Priority High -Days @(1, 2, 3, 4, 5) -Start (Get-Date "2016-08-08 19:00:00")
New-DedupSchedule -Name "WeeklyGarbageCollection" -Type GarbageCollection -DurationHours 23 -Memory 100 -Cores 100 -Priority High -Days @(6) -Start (Get-Date "2016-08-13 07:00:00")
New-DedupSchedule -Name "WeeklyIntegrityScrubbing" -Type Scrubbing -DurationHours 23 -Memory 100 -Cores 100 -Priority High -Days @(0) -Start (Get-Date "2016-08-14 07:00:00")
@debold
debold / Get-MgUserLicenseLogonReport.ps1
Last active February 25, 2022 16:26
Quick Office 365 user export with license details and last logon
# Warning: PowerShell ternary operator (a ? b : c) in use. Needs PowerShell 7+!
# Install Microsoft Graph API module if not already there
# Install-Module Microsoft.Graph
# Need to select beta profile in order to get logon statistics
Select-MgProfile -Name "beta"
# You'll need auditlog read access for logon statistics
Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All", "AuditLog.Read.All"
# Load SKU list
@debold
debold / Get-ServerSoftwareInventory.ps1
Created September 24, 2020 12:31
Collect a quick software inventory from all domain servers
$Servers = Get-ADComputer -Filter { OperatingSystem -like "*server*" -and Enabled -eq $true } -Properties OperatingSystem
$Results = @()
foreach ($Server in $Servers) {
Write-Host $Server.Name -NoNewline
try {
Test-Connection -ComputerName $Server.DnsHostName -Count 1 -ErrorAction Stop | Out-Null
$found = $true
Write-Host "`tfound`t" -NoNewline -ForegroundColor Green
} catch {
$found = $false
@debold
debold / Enable-IE-TLS1.1-1.2.reg
Last active May 25, 2020 13:49
Enable TLS 1.1 and 1.2 in Internet Explorer
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings]
"SecureProtocols"=dword:00000a80
@debold
debold / Enable-NET-TLS12.reg
Created December 22, 2019 13:27
Enable TLS 1.2 for .NET Framework
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\.NETFramework\v2.0.50727]
"SystemDefaultTlsVersions"=dword:00000001
"SchUseStrongCrypto"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\.NETFramework\v4.0.30319]
"SystemDefaultTlsVersions"=dword:00000001
"SchUseStrongCrypto"=dword:00000001
@debold
debold / Enable-WinHttp-TLS1.1-1.2.reg
Created December 22, 2019 13:23
Enable TLS 1.1 and 1.2 for WinHttp applications
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp]
"DefaultSecureProtocols"=dword:00000A00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp]
"DefaultSecureProtocols"=dword:00000A00
@debold
debold / Enable-TLS1.2.reg
Created December 22, 2019 13:07
Enable TLS 1.2 for Windows
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2]
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisabledByDefault"=dword:00000000
"Enabled"=dword:00000001
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"DisabledByDefault"=dword:00000000