I don't want to reinvent the wheel here as some other posts have done. That being said I recently set up a Raspberry Pi Zero-W (the headless way) and I had a pretty difficult time given that I didn't have a spare linux vm laying around. So in this post I'm going to provide some background info and the steps that I took, as well as some reference materials.

For those of you who aren't familiar - basically after you flash your MicroSD card with the OS you have to go in and edit some config files so that when your Pi boots up it knows what network to connect to. That and you also have to create a file to enable SSH. I have a Mac and a PC and I actually found this easier to do on my Windows 10 machine. This tutorial will be geared towards Windows 10 users.

Assumptions:

  1. You have one of these
  2. You have a MicroSD card for above
  3. You have Windows Subsystem for Linux enabled (If not scroll to the WSL section at the bottom)

Steps:

  1. Download Raspbian Lite here
  2. Download and install Etcher here
  3. Download and install EXT2FSD here
  4. Mount your MicroSD card and use Etcher to flash the Raspbian Image
  5. Enable SSH
  6. Enter Wifi Config
  7. Profit

Steps 1-3

Are pretty self explanatory so I'm not going to go in-depth.

Step 4

Insert or plug in your MicroSD card and it should be automatically detected by Windows. Open Etcher,select the image and then click flash.
etcher

Step 5

Here's where it gets interesting. At this point you will need to use EXT2FSD to mount the linux ext4 partition on your MicroSD card. You should simply be able to unplug the sd card and plug it back in for it to be recognized provided you have installed EXT2FSD. Here are some screen shots of my EXT2FSD and my explorer:
explorer
ext2

Please take note of your drive letters. Find the drive letter of your boot and rootfs drives. In my case they are I: and J: as shown in the screen shots.

Open up the Ubuntu Bash shell (hit the windows key and type in Ubuntu and hit enter). Replace i & I: and j & J: with YOUR specific drive letters in the code snippet below:

sudo mkdir /mnt/i
sudo mkdir /mnt/j
sudo mount -t drvfs I: /mnt/i
sudo mount -t drvfs J: /mnt/j

You can then use this command to verify that it worked properly.

df -h

This will list the available drives you have. Use the drive letter for your boot partition for this command:

cd /mnt/i
touch ssh

Step 6

Scroll up and take note of what drive letter has not been mounted yet from the output of the df -h command. Note your own drive letter of the rootfs partition.

Now type:

cd /mnt/j
nano etc/wpa_supplicant/wpa_supplicant.conf

Nano will open a text editor, you want to go and edit these values. Replace the values for ssid and psk with your network name and password. When you are done hit CTRL + X then hit Y to save your changes.

network={
    ssid="YOURSSID"
    psk="YOURPASSWORD"
    scan_ssid=1
}

You should now be back at the bash shell and can unmount the drive.

sudo umount /mnt/i
sudo umount /mnt/j

All done! You should be able to power up your Raspberry Pi Zero W. After 1-2 minutes you should see it available on your network (go to your router admin page and find it). Then you should be able to SSH into the CLI by using PuTTy or the bash ssh command.

The default login is username: pi, password: raspberry.

Questions, comments, let me know!

WSL Setup

If you don't have WSL installed do the following:

  1. Hit the windows key and type "turn windows features" and click "Turn Windows Features On or Off".
  2. Select "Windows Subsystem for Linux" and hit OK.

wsl

References:
Reference Medium Blog
Windows 10 WSL