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

@tcartwright
tcartwright / ConvertFilesToUTF8.ps1
Created November 26, 2024 22:12
POWERSHELL: Convert files to UTF-8 NO BOM
$Utf8NoBomEncoding = [System.Text.UTF8Encoding]::new($false);
Get-ChildItem -Path "." -Recurse -File |
Where-Object { $_.FullName -inotmatch "\\bin\\|\\obj\\"} |
ForEach-Object {
Write-Output $_.FullName;
$content = [IO.File]::ReadAllLines($_.FullName);
[IO.File]::WriteAllLines($_.FullName, $content, $Utf8NoBomEncoding);
}
@tcartwright
tcartwright / CleanRsaMachineKeys.ps1
Created November 14, 2024 17:52
POWERSHELL: Cleans machine keys out that may get out of control
#Requires -RunAsAdministrator
Clear-Host
$deleteDate = (Get-Date).AddMonths(-2)
$counter = 0
# https://port135.com/remove-older-files-machinekeys/
# Back up the three files below. These files are used by IIS. It’s important to back them up before removing any files from MachinkeKeys folder.
#
# 6de9cb26d2b98c01ec4e9e8b34824aa2_GUID iisConfigurationKey