Skip to content

Instantly share code, notes, and snippets.

@bohack
bohack / PacketFence Code Generator
Created August 21, 2018 13:34
PacketFence Code Generator
#!/bin/bash
# Bohack
# 04/26/16
# Script to generate password for htpasswd file
if [ -z "$1" ]
then
echo
echo "$0 [user to generate passwd for]"
@bohack
bohack / VDI Printer Script
Created March 20, 2018 16:33
VDI Printer Script
' Author: Jon Buhagiar
' Date: 10/19/17
' Purpose: This script will check the ViewClient_Broker_Tags. If it is External
' or 10.8x.0.0 (wireless) then it will quit and allow TPAutoConnect to
' redirect the client host default printer. If it is not External or 10.8x
' it is assumed to be Internal, the script will then record the current
' default printer and set the default printer via the regKey. Edit the
' strIPExclude with a CSV value.
'
' Usage: Use a GPO applied to the VDI computers for logon and logoff scripts for
@bohack
bohack / Get a list of users by their SAMid and lookup their UPN
Created February 23, 2018 18:07
Get a list of users by their SAMid and lookup their UPN
@ECHO OFF
REM Bohack
REM 2/23/18
REM Get a list of users by their SAMid and lookup their UPN
FOR /F "TOKENS=*" %%a IN (listofusers.txt) DO (
ECHO %%a
DSQUERY USER -SAMID %%a | DSGET USER -SAMID -UPN
)
@bohack
bohack / Get Total RAM from a PC via VBscript WMI
Created January 30, 2018 14:44
Get Total RAM from a PC via VBscript WMI
On Error Resume Next
Prefix ="fstu516"
For Count = 1 to 36
Total = 0
If Count < 10 then Fill="00"
If Count < 100 and Count > 9 then Fill="0"
strComputer = Prefix & Fill & Count
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory")
@bohack
bohack / Secure Local Password Check
Created December 6, 2017 15:25
Secure Local Password Check
<#
.Synopsis
Verify Local SAM store
.DESCRIPTION
This function takes a user name and a password as input and will verify if the combination is correct. The function returns a boolean based on the result. The script defaults to local user accounts, but a remote computername can be specified in the -ComputerName parameter.
.NOTES
Name: Test-LocalCredential
Author: Jaap Brasser
@bohack
bohack / Create Users for Lab Redux
Last active November 6, 2017 20:22
Create Users for Lab Redux
# Create users and Groups for Lab
# Bohack
# 11/6/17
Import-Module ActiveDirectory
# Variables for Creation
$rtdomain = "DC=Netmind,DC=Local"
$orgrt = "Netmind"
$orgpath = "OU=Netmind,$rtdomain"
@bohack
bohack / Create Users and Groups for Lab
Created November 6, 2017 19:28
Create Users and Groups for Lab
# Create users and Groups for Lab
# Bohack
# 08/31/14
Import-Module ActiveDirectory
# Create the OU structure
Echo "Creating OU Structure"
New-ADOrganizationalUnit -Name Contoso -Path "DC=Contoso,DC=Com"
@bohack
bohack / PowerShell Find Last Logon Time
Created October 31, 2017 14:10
PowerShell Find Last Logon Time
Import-Module ActiveDirectory
function Get-ADUserLastLogon([string]$userName)
{
$dcs = Get-ADDomainController -Filter {Name -like "*"}
$time = 0
foreach($dc in $dcs)
{
$hostname = $dc.HostName
$user = Get-ADUser $userName | Get-ADObject -Properties lastLogon
@bohack
bohack / Office Activation Script on Startup
Created October 19, 2017 17:51
Office Activation Script on Startup
@ECHO OFF
REM Jon Buhagiar
REM 10/19/17
REM Office Manual Activation
IF EXIST "C:\Support\.officeactivation" GOTO :END
CSCRIPT "C:\Program Files (x86)\Microsoft Office\Office16\ospp.vbs" /act
ECHO %ERRORLEVEL% - %DATE% - %TIME% > "C:\Support\.officeactivation"
@bohack
bohack / Bill's Mom's BBQ Recipe
Created September 18, 2017 15:56
Bill's Mom's BBQ Recipe
Scale out as needed!
3 Tablespoon Paprika
1 Tablespoon Pepper
1/2 to 1 Teaspoon of non-iodized Salt
1/2 to 1 Teaspoon of Cayenne Pepper (be careful!)
1 Tablespoon of Powered Onion
1 Tablespoon of Powered Garlic
2 Tablespoons of Brown Sugar
1 Tablespoon of Chilli powder