Skip to content

Instantly share code, notes, and snippets.

@ml4den
ml4den / s3-upload-for-scaleway.js
Created May 1, 2022 10:56
Using aws-sdk to upload to a Scaleway S3 bucket in Node.js
const fs = require('fs');
import path from 'path';
const AWS = require('aws-sdk');
const BUCKET_NAME = 'my-bucket';
const awsConfig = new AWS.Config({
accessKeyId: process.env['SCALEWAY_ACCESS_KEY'],
secretAccessKey: process.env['SCALEWAY_SECRET_KEY'],
region: 'fr-par', // Not actually required to work
//s3BucketEndpoint: true, // Required if configuring for a single bucket endpoint like https://my-bucket.s3.fr-par.scw.cloud
@ml4den
ml4den / Fix-Warzone.ps1
Last active April 11, 2020 12:56
Easy Fix for Call of Duty Warzone Crashing in PowerShell
# Set path to game:
$game = "X:\Games\Warzone\Call of Duty Modern Warfare\ModernWarfare.exe"
Write-Host "Please start the game if not already running." -ForegroundColor Yellow
Write-Host "$(Get-Date)`tChecking for game process..."
Do {
$process = Get-Process -Name "ModernWarfare" -ErrorAction SilentlyContinue
Start-Sleep 5
@ml4den
ml4den / Compare-Lists.ps1
Created January 20, 2020 20:02
Find the unique values in the second list with PowerShell
$a=@(1,2,3,4,5,8)
$b=@(1,2,3,4,5,6,9,"ten")
$c = $b | where { -not ($a -contains $_) }
Write-Host $c
@ml4den
ml4den / Get-FileHash.ps1
Created January 12, 2020 23:10
Hash a file easily with PowerShell
function FileSelector {
# Define a function that allows the user to select files.
# Credit: https://4sysops.com/archives/how-to-create-an-open-file-folder-dialog-box-with-powershell/
$FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
InitialDirectory = [Environment]::GetFolderPath('Desktop')
}
$null = $FileBrowser.ShowDialog()
return $FileBrowser
}

Keybase proof

I hereby claim:

  • I am ml4den on github.
  • I am ml4den (https://keybase.io/ml4den) on keybase.
  • I have a public key whose fingerprint is CDBC C75A 5608 2E1B 8848 4D90 A685 01A0 EA4F 14CD

To claim this, I am signing this object:

@ml4den
ml4den / dnsResolve.js
Created March 16, 2019 10:47
Resolve DNS Resords in JavaScript
const dns = require('dns');
var callback = function (err, data) {
if (err) return console.error(err);
console.log(data);
};
dns.resolveTxt("example.com",callback)
@ml4den
ml4den / Get-HostCertificateGrade.ps1
Created October 15, 2018 16:11
Rudimentary PowerShell function for checking host certificate grades using the SSL Labs API
Function Get-HostCertificateGrade ($hostname) {
# Rudimentary function for checking host certificate grades using the SSL Labs API
# https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs-v3.md
Do {
$apiCall = Invoke-RestMethod -Uri "https://api.ssllabs.com/api/v3/analyze?host=$hostname&fromCache=on"
Write-Host $hostname "status:" $apiCall.status
if ($apiCall.status -eq "DNS") {Start-Sleep -Seconds 5}
@ml4den
ml4den / SearchMacDHCP.ps1
Last active January 16, 2025 15:41
A quick and dirty PowerShell script to search for a particular MAC address on Windows DHCP servers across all scopes.
# A quick and dirty PowerShell script to search for a particular MAC address on Windows DHCP servers across all scopes.
$dhcpServers = @("dhcp-server-01","dhcp-server-02") # Define your servers here
$results = @()
$clientId = Read-Host -Prompt "Input the MAC address you want to search for"
foreach ($dhcpServer in $dhcpServers) {
Write-Host "Searching $dhcpServer..."
Get-DhcpServerv4Scope -ComputerName $dhcpServer | ForEach-Object {
$results += Get-DhcpServerv4Reservation -ComputerName $dhcpServer -ScopeId $_.ScopeId -ClientId $clientId -ErrorAction SilentlyContinue
@ml4den
ml4den / windowQuit.ps1
Last active September 5, 2017 11:30
Close/Quit Application Window with PowerShell
# Simple find and quit:
(New-Object -comObject Shell.Application).Windows() | where-object {$_.LocationName -eq "Personalisation"} | foreach-object {$_.quit()}
# Credit: https://www.tenforums.com/customization/51260-apply-windows-10-theme-cmd-powershell-programming-post963151.html#post963151
# Wait for window and quit:
do {
$windowcheck = (New-Object -comObject Shell.Application).Windows() | where-object {$_.LocationName -eq "Personalization"}
Write-Host "Waiting for window..."
Start-Sleep -m 200
}
@ml4den
ml4den / backupPrintQueues.ps1
Created July 13, 2017 10:47
Back Up Print Server Queues to a Remote Share with PowerShell
$servers = "printserver1","printserver2"
$remoteFolder = "\\fileshare\backups"
foreach ($server in $servers){
$localFile = "C:\temp\$server.PrinterExport"
& "C:\Windows\System32\spool\tools\PrintBrm.exe" -s $server -b -f $localFile
Move-Item $localFile $remoteFolder -Force
}