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 / 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 / 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 / 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)