PowerShell Functions
Nmap Function¶
-
Open your $PROFILE for editing with
-
Set Notepad alias to use norepad++ instead of regular norepad
-
Add it in the $PROFILE to load each time.
-
Then add the below function outside any code blocks . It’s a standalone function
function nmap {
$IP=$args[0]
$port=$args[1]
Write-Output "Selected IP Address = $IP and Port Number = $port"
Write-Output "Checking if port is open Please Wait..."
$Result = Test-NetConnection $IP -Port $port -InformationLevel "Detailed"
if ($Result.TcpTestSucceeded -eq $true) {
Write-Output "Port $($Result.RemotePort) at $($Result.RemoteAddress) is Open"
} else {
Write-Output "Port $($Result.RemotePort) at $($Result.RemoteAddress) is Closed"
}
}
- Reload/Restart your PowerShell and test it .
Example
nmap 10.2.32.60 2087
Selected IP Address = 10.2.32.60 and Port Number = 2087
Checking if port is open Please Wait...
Port 2087 at 10.2.32.60 is Open
Dig custom function using Resolve-DnsName utility of PowerShell¶
- Usage
- Possible options for type. Unfortunately not all of them give trustworthy results. Stick to regular ones like A, MX , NS
A_AAAA, A, NS, MD, MF, CNAME, SOA, MB, MG,
MR, NULL, WKS, PTR, HINFO, MINFO, MX, TXT,
RP, AFSDB, X25, ISDN, RT, AAAA, SRV, DNAME,
OPT, DS, RRSIG, NSEC, DNSKEY, DHCID, NSEC3,
NSEC3PARAM, ANY, ALL, WINS"
cPanel verify license function¶
- Verify License via PowerShell. Simply opens up new tab in chrome with the license website with post request
# Verify cPanel License
function verify {
$IP=$args[0]
start chrome https://verify.cpanel.net/app/verify?ip=$IP
}
- Usage
Ipinfo Function¶
- Checking IP address details
- Example Output
PS C:\Users\vladimir.ivanov> ipinfo 184.94.197.2 { "ip": "184.94.197.2", "hostname": "hou-2.nat.cptxoffice.net", "city": "South Houston", "region": "Texas", "country": "US", "loc": "29.6630,-95.2355", "org": "AS33522 cPanel, LLC.", "postal": "77587", "timezone": "America/Chicago", "readme": "https://ipinfo.io/missingauth" }
Command cheat sheets from cheat.sh. Wrapper function PowerShell¶
Get WMI Object¶
- BIOS DATA