Skip to content

Instantly share code, notes, and snippets.

$results = echo (0..2) -pipelinevariable second | % {
echo (0..10) -pipelinevariable third | % {
echo (0..254) -pipelinevariable fourth | % {
$status = Test-NetConnection -CommonTCPPort HTTP "10.$second.$third.$_"
if ($status.TcpTestSucceeded) {
del outfile*.txt -ea 0
$fn = 0
gc file.txt |
% {
if ($_ -eq '-----BEGIN CERTIFICATE-----')
{
$fn++
$fname = 'outfile'+$fn+'.txt'
$fname
}
@LarryWeiss
LarryWeiss / Show-FileEncoding_function.ps1
Created May 7, 2019 15:13
Show-FileEncoding function written in PowerShell
########################################################################################################
#
# .SYNOPSIS
#
# PowerShell function that returns the file encoding name as a string.
#
# _____ _ ______ _ _ ______ _ _
# / ____| | | ____(_) | | ____| | (_)
# | (___ | |__ _____ ______| |__ _| | ___| |__ _ __ ___ ___ __| |_ _ __ __ _
# \___ \| '_ \ / _ \ \ /\ / /____| __| | | |/ _ \ __| | '_ \ / __/ _ \ / _` | | '_ \ / _` |
@LarryWeiss
LarryWeiss / ConvertFrom-CsvToFixedWidth
Created May 7, 2019 14:47
ConvertFrom-CsvToFixedWidth function written in PowerShell
################################################################
#
# .SYNOPSIS
#
# PowerShell function named "ConvertFrom-CsvToFixedWidth"
#
# _____ _ ______
# / ____| | | | ____|
# | | ___ _ ____ _____ _ __| |_| |__ _ __ ___ _ __ ___
# | | / _ \| _ \ \ / / _ \ __| __| __| __/ _ \| _ _ \
@LarryWeiss
LarryWeiss / Logs_function.ps1
Created February 27, 2019 19:32
uninterruptible PowerShell code
function Logs
{
$lineNumber = 0
$delimiter = ":"
$dateTimeStamp = "00-00-0000 00:00:00.000"
Get-ChildItem Log?.txt |
ForEach-Object {
$filename = $_.name
Get-Content $filename | ForEach-Object {
if ([System.Console]::KeyAvailable) { return } # <-- this makes it interruptable
------------------------------------------------------------------------------------------------
output redirection to Unicode text where
α is a command
ß and γ are file names or PowerShell variable names
α > ß only regular output - override
α >> ß only regular output - append
α 2> ß only error output - override
α 2>> ß only error output - append
α 2>&1> ß both regular output and error output, merged - overide
α 2>&1>> ß both regular output and error output, merged - append
@LarryWeiss
LarryWeiss / gist:6afba33b756aaeb4322130dec5c5d178
Created December 19, 2018 03:20
RSS Feed Reader (demo of an AngularJS 1.4.0 SPA using Bootstrap 3.3.4 CSS)
<!DOCTYPE html>
<html lang="en" ng-app="RSSFeedApp" ng-strict-di>
<head>
<meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>RSS Feed Reader (demo of an AngularJS 1.4.0 SPA using Bootstrap 3.3.4 CSS)</title>
<!-- based on http://www.ivivelabs.com/blog/making-a-quick-rss-feed-reader-using-angularjs/ -->
<!-- see: https://developers.google.com/feed/v1/jsondevguide for the service used in RSSFeedFactory -->
@LarryWeiss
LarryWeiss / gist:0e19b8365acf02a01910be4f037e5888
Created August 27, 2016 16:18
output redirection operators
output redirection where α is a command and ß and γ are filenames
------------------------------------------------------------------
α > ß only regular output - override
α >> ß only regular output - append
α 2> ß only error output - override
α 2>> ß only error output - append
α 2>&1> ß both regular output and error output, merged - overide
α 2>&1>> ß both regular output and error output, merged - append
α >ß 2>γ both regular output and error output, separately - both override
α >>ß 2>>γ both regular output and error output, separately - both append