Using Salt with Windows

Week 5 of Configuration Management Systems course.

Course material:

Environment: My Windows 10 PC with plenty of storage. VirtualBox VM running Debian 11 XFCE. VM has 4 GB of RAM and 40 GB of disk space.

Hello Windows Salt!

Objective: Write a Salt state that creates a file called “suolaikkuna.txt”.

I started by creating an init.sls file to a Salt project directory called hello-windows. (source)

> cd C:\users\valka\salt\hello-windows
> New-Item -Path '.\init.sls' -ItemType File

In File Explorer, I opened init.sls in Notepad and wrote the instructions for creating the file.


I ran the Salt state with salt-call. The flag --file-root tells Salt to use the specified directory as root.

> salt-call --file-root=C:\Users\valka\salt --local state.apply hello-windows

I got an error. I forgot to add a colon to the Salt state.

error message



I ran the state again. This time it was successful.


I checked that the file created was actually there.


No notes, no pen

Objective: Gather the Windows machines technical information to a text file. Optional: can you save them in JSON-format?

I used the items state function from the grains module to gather information. I wrote the information to a .txt file.

> salt-call --local grains.items > tech-info.txt

technical information

For the JSON format, I used --out flag to specify the output as JSON. (source)

> salt-call --local grains.items --out=json > tech-info.txt

json info

Knock knock. Is the TCP port open?

Objective: Find out if a port is open or closed. Try it on both Linux and Windows. Show an open and a closed port on both operating systems.


I installed netcat.

$ sudo apt-get update
$ sudo apt-get install netcat

I tried connecting to ports 4505 and 4507. 4505 is a port used by Salt Master and port 4507 is, to my knowledge, not in use. (source: man nc, screenshots from the lecture,

$ nc -vz 4505
Connection to 4505 port [tcp/*] succeeded!
$ nc -vz 4507
nc: connect to port 4507 (tcp) failed: Connection refused

netcat output


I used tnc (Test-NetConnection) to connect to ports. (source: man tnc)

> tnc -Port 4510
> tnc -Port 4509

Port 4510 is commonly used by Microsoft Silverlight plugin which adds interactivity to browsers. (source). Port 4509 was not in use.

tnc ports


Profile picture

Written by Tuomas Valkamo who is studying IT at Haaga-Helia University of Applied Sciences.

Check out my GitHub. or Connect with me.

© 2022 Tuomas Valkamo