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 / TestHttpsCert.ps1
Last active May 22, 2025 14:50
POWERSHELL: Test https cert
Clear-Host
$hostName = "www.microsoft.com"
$req = [System.Net.HttpWebRequest]::Create("https://$hostName")
$req.GetResponse().Dispose()
$servicePoint = $req.ServicePoint
[System.Security.Cryptography.X509Certificates.X509Certificate2]$cert = $servicePoint.Certificate
# $servicePoint | Format-List *
@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,
@tcartwright
tcartwright / ListWebSites.bat
Last active December 5, 2024 15:43
BAT: Get list of IIS web sites, listing IDs, and bindings with state
C:\Windows\System32\inetsrv\appcmd.exe list site
@tcartwright
tcartwright / 0.Directory.Build.props-Directory.Build.targets-Directory.Packages.props.MD
Last active November 28, 2024 16:25
VISUAL STUDIO: Directory packages, build, and targets files.
@tcartwright
tcartwright / PullMainBranchesForAllRepos.ps1
Created November 26, 2024 22:44
POWERSHELL: Pull all the main branches for a set of repo folders
Clear-Host
$folders = [IO.Directory]::EnumerateDirectories("**PATH**")
$branches = "dev", "qa", "staging", "master"
foreach ($folder in $folders) {
Set-Location $folder
if (!(Get-ChildItem -Path ".git" -Directory -ErrorAction SilentlyContinue)) {
continue
}
@tcartwright
tcartwright / FixGitFileCasing.md
Last active November 26, 2024 22:37
GIT: Rename file with bad casing that cant be changes cannot be undone on

If you've changed the case of a file name in Git and can't undo the changes, it's likely that Git isn't recognizing the change as a rename. Here's how to fix it:

  • Method 1: Using git mv

    • Rename the file back to the original case:
      • Code git mv NewFileName.txt oldfilename.txt
    • Commit the change.
      • Code git commit -m "Fix case sensitivity issue"
  • Method 2: Force a rename

  • Rename the file to a temporary name: