Skip to content

Instantly share code, notes, and snippets.

@thecliguy
thecliguy / replace.ps1
Created June 1, 2018 09:51
Replace Example
$sRawOutput -replace ':\\: =>', '='
Grant user 'Log on as batch job' rights
=======================================
NTRIGHTS.EXE:
* NTRIGHTS.exe is part of the Windows Server 2003 Resource Kit.
Once installed, NTRIGHTS.exe resides in 'C:\Program Files (x86)\Windows Resource Kits\Tools\'.
* I have tested it on Windows Server 2012 R2 x64, works fine.
* [ ] Run the following command: ntrights -u <USERNAME> +r SeBatchLogonRight
SECPOL.MSC:
@thecliguy
thecliguy / FindExpectedValueInStdOut.ps1
Last active March 4, 2018 11:01
Find Expected Value in Standard Output
$ExpectedValue = "Ping statistics for 127.0.0.1:"
$Binary = "ping.exe"
$Arguments = "127.0.0.1 -n 10"
$ProcessStartInfo = New-Object System.Diagnostics.ProcessStartInfo
$ProcessStartInfo.UseShellExecute = $false
$ProcessStartInfo.RedirectStandardError = $true
$ProcessStartInfo.RedirectStandardInput = $true
$ProcessStartInfo.RedirectStandardOutput = $true
$ProcessStartInfo.FileName = $Binary
@thecliguy
thecliguy / ListApprovedAndDeclinesUpdates.ps1
Created January 22, 2018 14:01
List Approved and Declines Updates
# List approved and decline updates, including details such as the computer
# group(s) for which they have been approved/declined and the date/time on which
# the action was taken.
# NB: If an administrator has neither approve or declined an update then it is
# implcitly classified as 'NotApproved'. However, it would appear that the
# 'GetUpdateApprovals' method (used below) does NOT retrieve such updates.
$serverName = "TestServer"
$portnumber = 8530
@thecliguy
thecliguy / Explanation.txt
Last active May 31, 2018 23:39
WeeChat - Zero-Width Space (ZWSP)
The bridge bot of #powershell on freenode puts a zero-width space character after the first letter of Slack
nicks, to avoid people who are on both sides of the bridge triggering their own @mention.
Source machine:
* Windows Version: Windows 10 Pro, Version 1709, 16299.431
* Font used in conhost: Consolas (for both OpenSSH on Windows Subsystem for Linux and Win32-OpenSSH)
Target server:
* Ubuntu version: Ubuntu 16.04.4 LTS
@thecliguy
thecliguy / books.xml
Last active October 8, 2017 08:23
Books
<?xml version="1.0"?>
<catalog>
<book>
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
@thecliguy
thecliguy / gist:fdc72cbed2ce4e9ebb27d7dc3ebd0d2b
Created September 29, 2017 15:35
Sample Scheduled Task Creation
$TaskName = "My Scheduled Task";
$SchedTaskCred = Get-Credential "domain\user" `
-Message "Scheduled Task Service Account Credentials"; `
$SchedTaskCredUser = $SchedTaskCred.UserName; `
$SchedTaskCredPwd = $SchedTaskCred.GetNetworkCredential().Password; `
$Action = New-ScheduledTaskAction `
-Execute "PowerShell.exe" `
-Argument '-ExecutionPolicy Bypass -file "C:\MyScript.ps1"' `
-ErrorAction Stop; `
$Trigger = New-ScheduledTaskTrigger `
@thecliguy
thecliguy / win10colors.cmd
Created September 17, 2017 19:38 — forked from mlocati/win10colors.cmd
ANSI Colors in standard Windows 10 shell
@echo off
cls
echo  STYLES 
echo ^<ESC^>[0m Reset
echo ^<ESC^>[1m Bold
echo ^<ESC^>[4m Underline
echo ^<ESC^>[7m Inverse
echo.
echo  NORMAL FOREGROUND COLORS 
echo ^<ESC^>[30m Black (black)
@thecliguy
thecliguy / moodle_upgrade.sh
Created August 25, 2017 11:47 — forked from derhofbauer/moodle_upgrade.sh
Bash Moodle Upgrade Script
#!/bin/sh
echo "This script updates your moodle installation."
echo "You will need a few pieces of information to complete this process."
echo ""
echo "Warning: This will disable Web-Access to the moodle installation!"
echo "Make sure nobody is logged in at the moment or activate maintenance mode manually so no data is lost."
echo ""
echo ""
@thecliguy
thecliguy / TcpChatMessenger.cs
Created July 21, 2017 22:36 — forked from define-private-public/TcpChatMessenger.cs
Synchronous, single-threaded TCP Chat Server in C#
// Filename: TcpChatMessenger.cs
// Author: Benjamin N. Summerton <define-private-public>
// License: Unlicense (http://unlicense.org/)
using System;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;