Skip to content

Instantly share code, notes, and snippets.

View tcartwright's full-sized avatar

Tim Cartwright tcartwright

  • Houston, Texas
View GitHub Profile
@tcartwright
tcartwright / postman_load_cdn_js.js
Created March 12, 2025 17:23
POSTMAN: Global functions from CDN javascript file
// can be used at a collection level pre-request script to pull a js from a cdn, and expose the methods to all your requests
// can also use a script package instead of a CDN.
await (async () => {
const requestPromise = new Promise((resolve, reject) => {
pm.sendRequest("https://cdn.foo.com/foo_utils.js", (err, res) => {
if (err) {
console.error(err);
return reject(err);
}
@tcartwright
tcartwright / postman_collection_init.js
Last active March 12, 2025 19:55
POSTMAN: Set up date and lorem variables
// clear out all the current date vales and then re-add them
let vars = JSON.parse(JSON.stringify(pm.globals.values));
vars.forEach((variable) => {
let keyName = variable.key;
if (keyName.match(/^currentdate|^lorem/i)) {
pm.globals.unset(keyName);
}
});
@tcartwright
tcartwright / CleanBuildArtifacts.ps1
Last active March 3, 2025 17:57
POWERSHELL: Clean build artifacts
Clear-Host
$parentDir = $PSScriptRoot
if ($parentDir) {
Write-Host "Cleaning $parentDir" -ForegroundColor Yellow
Get-ChildItem -path $parentDir -Filter "bin" -Recurse -Directory | Remove-Item -Recurse -ErrorAction SilentlyContinue -Verbose
Get-ChildItem -path $parentDir -Filter "obj" -Recurse -Directory | Remove-Item -Recurse -ErrorAction SilentlyContinue -Verbose
} else {
@tcartwright
tcartwright / GetSystemInformation.ps1
Last active February 21, 2025 19:20
POWERSHELL: Get system information
Clear-Host
$memInfo = Get-WmiObject Win32_PhysicalMemory
$diskInfo = Get-Disk | Sort-Object DiskNumber
$driveInfo = Get-Volume | Where-Object { $_.DriveLetter } | Sort-Object DriveLetter
Write-Host 'Get-ComputerInfo' -ForegroundColor Yellow
$computerInfo = Get-ComputerInfo | Select-Object `
@{Name="DNSHostName"; Expression={$_.CsDNSHostName}},
@{Name="Domain"; Expression={$_.CsDomain}},
@tcartwright
tcartwright / TestHttpsCert.ps1
Last active February 20, 2025 14:33
POWERSHELL: Test https cert
Clear-Host
$hostName = "www.microsoft.com"
$req = [System.Net.HttpWebRequest]::Create("https://$hostName")
$req.GetResponse().Dispose()
[System.Security.Cryptography.X509Certificates.X509Certificate2]$cert = $req.ServicePoint.Certificate
#$cert | Format-List *
$props = $cert | Select-Object Subject,
@tcartwright
tcartwright / TestSPNsAndAD.ps1
Last active February 14, 2025 17:18
POWERSHELL: Test SPNs and AD connectivity
Clear-Host
Write-Host "`r`nSetspn -L `$env:COMPUTERNAME`r`n" -ForegroundColor Yellow
Setspn -L $env:COMPUTERNAME
Write-Host "`r`nSetspn -L `"`$(`$env:USERDOMAIN)\`$(`$env:USERNAME)`"`r`n" -ForegroundColor Yellow
Setspn -L "$($env:USERDOMAIN)\$($env:USERNAME)"
Write-Host "`r`nTest-ComputerSecureChannel`r`n" -ForegroundColor Yellow
Test-ComputerSecureChannel
@tcartwright
tcartwright / sort-postman-collection.bat
Created January 22, 2025 14:41
POWERSHELL: Sorts a postman collection by names of folders and requests recursively
@rem bat file to ease use of powershell script
@%~d0
@cd "%~dp0"
powershell.exe -ExecutionPolicy RemoteSigned -NoLogo -NonInteractive -NoProfile -file "%~dpn0.ps1" -Path "%~1"
@pause
@tcartwright
tcartwright / GetAllPortsProcesses.ps1
Last active January 16, 2025 18:46
POWERSHELL: Get process using TCP port
Clear-Host
if (!(Get-Module Join-Object)) {
Install-Module -Name Join-Object -Force -AllowClobber -Scope CurrentUser
}
$tcpConnections = Get-NetTCPConnection
# list all ports processes:
$processes = Get-Process -Id ($tcpConnections).OwningProcess -IncludeUserName
@tcartwright
tcartwright / InstallNugetCLI.ps1
Last active January 16, 2025 19:20
POWERSHELL: Install Nuget.CLI
Clear-Host
if (!(Get-PackageSource -Name Nuget)) {
Register-PackageSource -provider NuGet -name Nuget -location "https://www.nuget.org/api/v2"
}
$remotePackage = Find-Package NuGet.CommandLine -ProviderName Nuget
$localPackage = Get-Package NuGet.CommandLine
if (!$localPackage -or $remotePackage.Version -gt $localPackage.Version) {
@tcartwright
tcartwright / GetPostmanUserInfo.js
Last active January 3, 2025 14:56
POSTMAN: Get User Information from script
utils = {
GetUserInfoPromise: function() {
return new Promise((resolve, reject) => {
// have to use a promise as sendrequest is async if we want to use the response
const postman_api_key = pm.globals.get('postman_api_key');
pm.sendRequest({
url: 'https://api.getpostman.com/me',
method: 'GET',
header: {
'X-API-Key': postman_api_key,