Skip to content

Instantly share code, notes, and snippets.

@tberta
tberta / Listen-Ports.ps1
Last active June 27, 2023 15:43
Powershell functions to Listen on Custom TCP Port and Test Connection with speed
Function Test-TCP {
<#
.SYNOPSIS
Test TCP Port with a low and configurable timeout
.NOTES
Not my own work. Copyright to the author.
#>
Param($address, $port, $timeout = 250)
@tberta
tberta / Rename-to-match-PS1Script-filename.cmd
Created May 26, 2023 11:15
Generic cmd file to run powershell script of same name. Rename this CMD file to the same name as the .PS1 file. All arguments to this cmd file are sent to the Powershell script as-is. I use -Command option as it better handles the script arguments.
@ECHO OFF
REM Generic cmd file to run powershell script of same name.
REM Rename this CMD file to the same name as the .PS1 file.
REM All arguments are sent to the powershell script as-is
REM I use -Command option as it better handles the script arguments.
setlocal DisableDelayedExpansion
set receivedargs=%*
set scriptname=%~dpn0
set scriptname=%scriptname%.ps1
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -Command ^& '%scriptname%' %receivedargs%