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;
  delay(1000);
}

void setup() {
	delay(1000);
	Serial.begin(115200);

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

void loop() {
	server.handleClient();
}

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
Get-VM

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

Quick Full-Disk Backups with Disk2VHD

Microsoft Sysinternals have free utility available to make full VHD backups from your hard drive. Using a VHD backup you can mount it in Windows and also import it into virtualisation software such as VirtualBox or VMWare and Hyper-V.

You can download the software from here:http://technet.microsoft.com/en-gb/sysinternals/ee656415.aspx

Below is a simple batch script to create automated backups using the command line; which can be set on a schedule.

Save the following as VHD.bat. Edit the backup_path variable with the location to store the backup. By default DISK2VHD will select all drives on the machine.

@ECHO OFF
ECHO Starting DISK2VHD Backup
SET starttime=%time%
SET backup_path=\\share\backups\
ECHO Backup started at: %starttime% > log.txt
IF NOT EXIST %backup_path%\%computername% MKDIR %backup_path%\%computername%
disk2vhd.exe * %backup_path%\%computername%\%computername%.vhd -accepteula
SET endtime=%time%
ECHO.
ECHO Backup completed at: %endtime% > log.txt
PAUSE

VBScript – Check User is a member of AD Group

Just a quick snippet of VBScript – To check whether or not the current user is a member of a specific Active Directory group. This could be useful when deploying scripts via GPO or using it in a netlogon script.

The example below checks to see if the user belongs to “Domain Admins” – Replace this with whatever group you would like to check.

Option Explicit
Dim objShell,grouplistD,ADSPath,userPath,listGroup
On Error Resume Next
set objShell = WScript.CreateObject( "WScript.Shell" )
  
If isMember("Domain Admins") Then
       MsgBox("Is member")
End If
  
Function IsMember(groupName)
    If IsEmpty(groupListD) then
        Set groupListD = CreateObject("Scripting.Dictionary")
        groupListD.CompareMode = 1
        ADSPath = EnvString("userdomain") & "/" & EnvString("username")
        Set userPath = GetObject("WinNT://" & ADSPath & ",user")
        For Each listGroup in userPath.Groups
            groupListD.Add listGroup.Name, "-"
        Next
    End if
    IsMember = CBool(groupListD.Exists(groupName))
End Function
  
Function EnvString(variable)
    variable = "%" & variable & "%"
    EnvString = objShell.ExpandEnvironmentStrings(variable)
End Function

Set objShell = Nothing

HVBackup – FREE Hyper-V Backup Solution (Modifications)

There is a free Microsoft Hyper-V backup solution called HVBackup – Website Link ; this is open-sourced under the LGPL license and is free to download and modify to suit your needs.

You can download and use this on your Hyper-V servers now by using the link above. I have been making changes to the HVBackup source to add a few new features, mainly…

  • Added GZIP Support (added by Pablo, on the HVBackup Forums)
  • Added GZIP Password (added by Pablo, on the HVBackup Forums)
  • HVBackup no longer responds to Command Line parameters, instead it reads all information from Settings.ini located in the same folder.
  • A GUI has been created to configure the settings, add servers, change formats, zip type, compression etc.
  • A Scheduler has been added to the GUI which allows you to Schedule HVBackup’s via the Windows Task Scheduler.

The new GUI I’ve written has been made in VB.NET and it manipulates the .ini settings file, allowing you to query your Hyper-V instance for server names and providing a quick interface for creating scheduling options via the Windows Task Scheduler.

This will be available for download shortly, if anyone wants to try this out feel free to contact me and I’ll send it over.

A couple of screenshots of the new GUI are below:

HBC2     HBC1