Adding PXE server into a Unifi Security Gateway

So I’m in the process of setting up a PXE Server on my network. I have a Debian based TFTP server that I created without DHCP setup on it. Mainly because I want the USG to do most of the work.

So of course I went looking around the web to do this first. Which I really couldn’t find anything on how to do it, which of course lead me to an important lesson. Always look through the settings first. 🙂

So here’s what you need to do.

  • Log into your Unifi system
  • Then click network
  • Then click edit for the lan you want the pxe server to be on
  • Then click advanced DHCP options.

  • Click enable network boot. Enter the ip of the server as well as the file it will be booting. In my case currently I have just one linux distro in there.
  • Under DHCP TFTP Server put in the ip address of the PXE server as well.

And then you should be good to go provided you set up your PXE Server correctly.

Microsoft Windows & Office ISO Download tool

While I have most of the ISOs of windows versions there are times where I need to get another copy. Maybe it’s got a corrupt version, or I need a weird version of windows etc.

So this tool is one of the important ones I use to get an ISO file

It’s called the Windows and Office ISO Download tool. And it can be downloaded here.

It’s works nice and allows you get get a wide range of ISOs from Microsoft.

Script to keep Hamachi alive

We use hamachi by logmein at work for various things, but one of the problems with hamachi at times is sometimes the tunneling engine doesn’t start. Now previously I had created a batch file that did this job, but it was pieced together with code I found online. So overall it was complicated.

So I wanted to redo it in powershell as well  make it give some kind of message in case someone else was needing to run this script.

So here it is

while ($true) {

if (-not (Test-Connection '192.168.0.207' -Quiet)) {

Write-Host "Test failed: $(Get-Date -Format "MM/dd hh:mm tt")"

Write-Host "Restarting Hamachi..." -ForegroundColor Red

Restart-Service Hamachi2Svc
Start-Sleep -Seconds 60

}

else {

Write-Host "Connection test passed: $(Get-Date -Format "MM/dd hh:mm tt")"

Start-Sleep -Seconds 600

}

}

It does need to be ran as an admin and I’ve got it set up as scheduled task for when the computer reboots.

The line that says

Start-Sleep -Seconds 60

is how long it will wait for hamachi to restart before it tries again. In my case it seems 60 seconds is plenty of time, but you may want to bump the time up a bit if needed.

Run a powershell script in task scheduler without it poping up.

I run some powershell scripts at work to keep things running and do things automatically. Problem when you put them in a task scheduler they pop up on the screen when they run.

So here’s what I found that works to keep them from showing up.

Open up the properties of a scheduled task

in the program/script section put

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

for arguments  put in

-File "C:\folder_of_script\script.ps1"

for start in put

c:\folder_of_scripts\

And that’s all there is to it.

To login automatically in windows 10

I had some computers that need to automatically login. Most are because they’re doing something. Running security systems, or virtual machines that really don’t need to be logged out.

So here’s all you need to do to make windows 10 log into a user automatically.

First hit the windows key and then type

netplwiz

and click that program.

It will come to a window that looks like this.

You want to uncheck the box that I circled above on the user you want to login.

Then it will take you to a page where you enter your password.

And that’s it.

Debloating Windows 10 the easy way

I found this website on GitHub. Windows10Debloater

I particular there’s one script in particular on the main page.

At the time of this posting it is called Windows10Debloater.ps1

Used it on some of my machines. While it wasn’t able to remove everything I will say 90% of the bloat is removed and you just have to uninstall a couple other apps.

I do suggest checking the page out before running the code as I have noticed things change and as of this writing this script was updated 9 days before.

Run scripts in powershell

Powershell scripts by default is set to restricted. So if you try to run a powershell script on a new machine you’ll find that it doesn’t work.

So here are the commands I use most often.

First off the default command is

Set-ExecutionPolicy -ExecutionPolicy Restricted

This is the command I run if this is a powershell script that will be ran all the time on that computer

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

And this is the one I use to just run something one time

Set-ExecutionPolicy -Scope Process -ExecutionPolicy AllSigned

Logmein Hamachi setup on linux

This was going to be a completely different post, but here we are. I needed a linux vm to access a hamachi network. Ultimately the build didn’t work right but the Hamachi part did.

First I got the latest build from logmein. At the time of this writing this was the latest build.

sudo wget http://vpn.net/installers/logmein-hamachi_2.1.0.198-1_amd64.deb

Then I did

dpkg -i logmein-hamachi_2.1.0.198-1_amd64.deb

And then I started it up by typing.

/etc/init.d/logmein-hamachi start

Now that that was done it was time to attach and login

So I did

sudo hamachi login

Then I had to attach it to my account by typing.

sudo hamachi attach myemail@address.com

Then I did the following command changing the 1s to my network id #

sudo hamachi do-join 111-111-111

And that was all I needed to do to get the turnkey running on a hamachi vpn network

Batch file to sort files by name

So we have electronic journals that get dumped into a folder. These are things we need to keep. However having them all thrown into the same folder can also be a pain.  Not only does it just cause a bunch of files to be in one folder but I we need to look back at Jan 18th 2017 we’d have to sort through tons and tons of these files looking for the one we wanted.

So I wrote this bat file that basically looks at out file name and puts everything into it’s own separate folder.

So first I’ll post the code then I’ll explain.

@echo off

setlocal enabledelayedexpansion

cls

pushd c:\sortfolder\

for /f "tokens=*" %%1 in ('dir /a-d /b c:\EJ\*.JRN') do (

set filename=%%1&set dirname=!filename:~0,2!\!filename:~2,2!\!filename:~4,2!

if not exist c:\sortedfolder\20!dirname!\ (md c:\sortedfolder\20!dirname!\)

move %%1 c:\sortedfolder\20!dirname!\>nul

)

Now out file format looks like this 18091700-000101Z.JRN

Now the only part we’re really interested in is

(180917) 00-000101Z.JRN

18 year, 09 month, 17 day.

Now this does all the sorting.

set filename=%%1&set dirname=!filename:~0,2!\!filename:~2,2!\!filename:~4,2!

!filename:~0,2! – Starts at the first character and goes two over so it grabs 18

!filename:~2,2! – Starts after the second character and goes 2 over so 09

!filename:~4,2! – Starts after the 4th character

If you adjust the first and last number you can sort by other setups.

So !filename:~0,4! Would start and go to include 1809

Clear dropbox cache

So with work we tend to use dropbox for some rather large files. And on most of my computers I don’t have an issue with how dropbox functions. However I occasionally have issues where these large files remain on the system in a hidden file, and I will have to go in and clean out these old files.

Like today I had to go and remove about 200 gigs of old files. Now from what I’ve read dropbox is supposed to take care of this itself, but clearly it doesn’t happen all the time.

So here’s how you clean this out.

Hit the start button and type:

%HOMEPATH%\Dropbox\.dropbox.cache

This will bring you to the dropbox cache where you can delete files that you have deleted from dropbox, but still remain on your system.