ESP8266 – Create an AP and list other APs in range

See below for example code that allows you to create a wireless network. Upon joining the network, you can browse to the ESP8266 IP address and it will list other Wireless networks in range.

It also outputs debug information to the Serial console.

#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <ESP8266WebServer.h>

const char *ssid = "ESP";
const char *password = "yourpassword";

String html;
String APList;

ESP8266WebServer server(80);

void handleRoot() {
	server.send(200, "text/html", html + "</body></html>");

void getAPList() {
  html = "<html><head><style>body { padding:20px; font-size:14px; font-family: Arial; line-height:22px; }</style></head><body>";
  int n = WiFi.scanNetworks();
   if (n > 0) {
    APList = APList + "<select>";
     for (int i = 0; i < n; ++i) {
      APList = APList + "<option value=''>" + WiFi.SSID(i) + "</option>";
    APList = APList +  "</select>";
  } else {
    APList = APList + "<p>No Access Points found.</p>";
  html = html + "Access Point: ";
  html = html + APList;

void setup() {

	WiFi.softAP(ssid, password);
	IPAddress myIP = WiFi.softAPIP();
	Serial.print("AP IP address: ");
	server.on("/", handleRoot);

void loop() {
Posted in Arduino, Programming | Leave a comment

C# Running code in a new thread

Below are various example snippets on starting code in a new thread easily. As well as updating the UI from your new thread.

These are the most basic examples, for more information take a look at the Threading Tutorial on the MSDN website:

Start a new Thread and run your code.

using System.Threading;
new Thread(() => 
    Thread.CurrentThread.IsBackground = true; 
    Console.WriteLine("Hello, world"); 

Start a new thread and call a method

Thread t = new Thread(new ThreadStart(YourMethod));
t.Name = "Your new thread.";

static void YourMethod() {
   //Your code runs here.

Using Tasks to start a new thread.

using System.Threading.Tasks;
Task.Factory.StartNew(() => {Console.WriteLine("Your new thread."); });

.NET4 and Above. Update UI Control from Thread

control.Invoke((MethodInvoker) (() => control.Text = "new text"));
Posted in .NET, C# | Leave a comment

Install the SCCM Client with a Batch File

Tired of waiting for the Deployment wizard to finish on the SCCM console? Me too. I’ve found that when I am formatting PCs and need them to install the SCCM client it is much faster to install it manually using a batch file. Adjust the line below and replace SCCMSERVER with the FQDN of your SCCM server.

ECHO Starting SCCM Install...
ECHO SCCM Finished...
Posted in Code, Windows | Leave a comment

Useful Powershell Hyper-V Commands

After using Hyper-V for sometime now, I’ve got used to management without the GUI. You can find below some useful PowerShell commands that should get you started managing your server.

Start and Stopping a Virtual Machine

//Start a Virtual Machine called VMName
start-vm VMName
//Stop a Virtual Machine called VMName
stop-vm VMName

List all Virtual Machines on the server

//List all Virtual Machines

Create a Snapshot for a Virtual Machine

//Create a snapshot of the selected VM.
checkpoint-vm -VMName "Your VM Name Here"

List all Hyper-V Snapshots on the server

//List Hyper-V Snapshots..
get-vmsnapshot *

List all Hyper-V Snapshots for a given VM

//List a Virtual Machines Snapshots
get-vm "Your VM Name" | get-vmsnapshot

Validate the Virtual Machines VHD

//Validate a VMs Hard Drive
dir C:\VHDs | Select Name,@{n="Test";Expression={ Test-VHD $_.fullname}} | sort Test
Posted in Programming | Leave a comment

Set Active Directory HomeDirectory with Powershell

Need to update the HomeDirectory on a bulk set of users, based on OU? See below. It will set \\SERVERNAME\Username as the home directory. Change the OU path as needed.

Get-ADUser -Filter * -SearchBase 'ou=YourOU,ou=Users,dc=DOMAIN,dc=LOCAL' | ForEach-Object {
	Set-ADUser $_.SamAccountName -HomeDrive "H:" -HomeDirectory "\\SERVERNAME\$($_.SamAccountName)"
Posted in Powershell | Tagged | Leave a comment

Change Default Gateway with a Batch file

Below is a useful script to change a default gateway IP address on a Windows 7 network adapter.

Set Gateway=
for /f "tokens=4*" %%a in ('netsh interface ipv4 show interfaces ^| find " connected" ^| find /v /i "Loopback"') do Set NIC=%%b
netsh interface ipv4 delete route prefix= interface="%nic%"
netsh interface ipv4 add route prefix= interface="%nic%" nexthop=%gateway% publish=Yes
Posted in Windows | Tagged , , | Leave a comment

The application was unable to load a required virtual machine component. Please contact the publisher of this application for more information.

Windows Updates have lately broken some software and thrown the error message “The application was unable to load a required virtual machine component. Please contact the publisher of this application for more information.”

I have put together a batch file to remove all the updates from a Windows 7 system that causes this issue.

@echo off

echo Uninstalling 3022345
wusa.exe /uninstall /kb:3022345 /quiet /norestart

echo Uninstalling 3045999
wusa.exe /uninstall /kb:3045999 /quiet /norestart

echo Uninstalling 3068708
wusa.exe /uninstall /kb:3068708 /quiet /norestart

echo Uninstalling 3071756
wusa.exe /uninstall /kb:3071756 /quiet /norestart

echo Uninstalling 3046017
wusa.exe /uninstall /kb:3046017 /quiet /norestart

echo Uninstalling 3060716
wusa.exe /uninstall /kb:3060716 /quiet /norestart

echo Uninstalling 3080149
wusa.exe /uninstall /kb:3080149 /quiet /norestart

echo Uninstalling 3101746
wusa.exe /uninstall /kb:3101746 /quiet /norestart

echo Uninstalling 3121212
wusa.exe /uninstall /kb:3121212 /quiet /norestart

echo Uninstalling 3088195
wusa.exe /uninstall /kb:3088195 /quiet /norestart

echo Uninstalling 3093513 with Restart
wusa.exe /uninstall /kb:3093513 /quiet
echo Forcing Restart...

Save as a .bat file and run. It will get the to end update and force a restart of the machine.

Posted in Tutorials | Tagged , , , | Leave a comment

Useful SCCM 2012 Device Collection Queries

Below are some useful SCCM Device Collection Queries. Some of these may require the device collection to be Dynamic.

Device Collection based on OU

SELECT * from SMS_R_System WHERE SMS_R_System.SystemOUName = "YOURDOM.LOCAL/Computers/YourCustomOU"

Device Collection Laptops/Notebooks

SELECT * FROM SMS_R_System INNER JOIN SMS_G_System_SYSTEM_ENCLOSURE ON SMS_G_System_SYSTEM_ENCLOSURE.ResourceID = SMS_R_System.ResourceID WHERE SMS_G_System_SYSTEM_ENCLOSURE.ChassisTypes in ( "8", "9", "10", "14" ) 

64bit Devices


Windows 8 Devices

SELECT SMS_R_SYSTEM.ResourceID, SMS_R_SYSTEM.ResourceType, SMS_R_SYSTEM.Name, SMS_R_SYSTEM.SMSUniqueIdentifier, SMS_R_SYSTEM.ResourceDomainORWorkgroup, SMS_R_SYSTEM.Client
SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId
"%Workstation 6.2%" or SMS_R_System.OperatingSystemNameandVersion LIKE "%Windows 8%" 

All Servers

SELECT SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client FROM SMS_R_System INNER JOIN SMS_G_System_SYSTEM ON SMS_G_System_SYSTEM.ResourceId = SMS_R_System.ResourceId WHERE SMS_G_System_SYSTEM.SystemRole = "Server"

Domain Controllers

SELECT SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client FROM SMS_R_System WHERE SMS_R_System.PrimaryGroupID = "516"

Computer Name Contains…

SELECT SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client FROM SMS_R_System INNER JOIN SMS_G_System_SYSTEM ON SMS_G_System_SYSTEM.ResourceID = SMS_R_System.ResourceId WHERE SMS_G_System_SYSTEM.Name LINK "%COMP%" ORDER BY SMS_R_System.Name
Posted in Blog, Techy | Tagged , , , , | Leave a comment