Skip to content

Instantly share code, notes, and snippets.

View aev-mambro2's full-sized avatar

André E. Veltstra aev-mambro2

View GitHub Profile
@aev-mambro2
aev-mambro2 / mssqlserver-tsql-save-varbinary-to-file.sql
Last active April 19, 2024 14:19
MSSqlServer TSQL save varbinary to file
DECLARE @local_target_path varchar(50) = 'c:\must\be\local\path'
, @adodb_file_stream int
, @create_instance_error int
, @error int
, @i bigint
, @data varbinary(max)
, @error_count int
, @error_description varchar(255)
, @error_source varchar(255)
, @file_path varchar(max)
@aev-mambro2
aev-mambro2 / let-powershell-install-package-managers-and-nuget-modules-when-it-complains-about-unable-to-download-from-uri.ps1
Last active June 1, 2022 15:06
Get Powershell NuGet to install modules if it complains it’s offline: set a better TLS cipher version
<# Assuming your computing device is online and can get through the firewall,
it is possible (because that was the problem in my case), that Powershell
chose an internet security cipher that is outdated or not available.
Errors typically include:
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
WARNING: Unable to download the list of available providers. Check your internet connection.
Install-PackageProvider : No match was found for the specified search criteria for the provider 'NuGet'.
The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified
package has the tags.
@aev-mambro2
aev-mambro2 / powershell-compress-zip-files-in-folder-based-on-age.ps1
Created May 18, 2022 13:32
Powershell how to compress/zip the files in a folder based on age
# Get all log files older than 1 day in the logs folder.
$subjects = Get-ChildItem -Path "D:\logs" -Filter "*.log" -file | Where-Object {$_.LastWriteTime -le ((get-date).AddDays(-1))}
# Compress them into a zip file, overwriting ones with the same name.
$subjects | Compress-Archive -DestinationPath "A:\archives\logs.zip" -Force
# Remove the originals. Note that if compressing fails, items will not get removed.
$subjects | Remove-Item
@aev-mambro2
aev-mambro2 / start-windows-taskschd-as-system.bat
Created March 28, 2022 17:43
How to start Windows Task Scheduler as System
psexec -accepteula -i -d -s mmc taskschd.msc
@aev-mambro2
aev-mambro2 / gradle-deploy-multiple-projects-to-multiple-targets.gradle
Created March 10, 2022 13:41
How to deploy from multiple projects to multiple target servers using Gradle CDCI
["server-1", "server-2", "server-3"].each { server ->
task "deploy-to-$server" (type: Copy) {
description: "Copies the project executables to $server"
enabled: true
group: "distribution"
afterEvaluate { Project project ->
from: "$distDir/$distZip"
into: "\\\\$server\\share\\${project.name}\\"
}
}
@aev-mambro2
aev-mambro2 / excel-vba-convert-image-link-to-image.vbs
Created March 2, 2022 15:38
Excel VBA: convert an image link into an actual image
@aev-mambro2
aev-mambro2 / powershell-get-20-largest-folders-in-current-location.ps
Last active January 3, 2022 14:14
powershell-get-20-largest-folders-in-current-location
Function Get-FolderSize {
BEGIN { $fso = New-Object -ComObject Scripting.FileSystemObject }
PROCESS {
$path = $input.fullname
$folder = $fso.GetFolder($path)
@aev-mambro2
aev-mambro2 / powershell-send-email-via-ms-outlook-365.ps
Created January 3, 2022 13:44
powershell-send-email-via-ms-outlook-365-with-attachments
$who = New-Object System.Management.Automation.PSCredential(
"account@domain.there",
(ConvertTo-SecureString "TheSecret" -AsPlainText -Force)
) -ErrorAction Stop;
#NOTE: this version of Send-MailMessage does NOT have a -ReplyTo parameter.
Send-MailMessage `
-From account@domain.there `
-Subject $("{0} Reports, dd. {1}" -f $files_count, $now) `
-To undisclosed recipients `
-Body $([System.String]::Concat(
@aev-mambro2
aev-mambro2 / gist:a10e55c94b76392914ef26e51610aa36
Created October 21, 2021 18:59
Start a remote console connection to a remote Windows server with admin privileges
mstsc -v:server.domain.edu /admin /F -console
@aev-mambro2
aev-mambro2 / multi-analyze-task-run-durations.ps1
Created September 30, 2021 18:06
Multithreaded Analyze Scheduled Task Run Durations (Windows Powershell, DevOps)
<# Analyze normal run duration of scheduled tasks.
# Gathers insight into how long tasks run, analyzes
# which tasks run shorter or longer than normal,
# reports back to console, and writes out its report
# as a CSV (spreadsheet).
#
# The script assumes that the user account running it
# has access to the computer and is allowed to read
# its event log.
#