This post will help you to check your local Windows Firewall status using PowerShell (whether it’s off or on for each Profile).
PowerShell commands follow standards and use verb-noun pairs for cmdlets. The verb at the start of the command describes the action the cmdlet performs, and the noun part is the action being performed. Here’s a list of Common Verbs, another Microsoft Docs link. The place of truth as I call it.
In this demo, we’re running Get-NetFirewallProfile with Format-Table We’re getting the Firewall Profile status, and also formatting it into a table after a pipe ‘|’ –
# get local firewall status powershell
Get-NetFirewallProfile | Format-Table Name, Enabled
The Windows Firewall on this machine is enabled, for all Profiles <- have a look at this MS Docs link to know more about Windows Firewall Profiles.
This post is contains a demo on how to enable Windows Firewall with PowerShell in Windows Server.
This might be needed if you have discovered Windows Firewall is disabled on your or multiple computers, or you might want to re-enable it after disabling this for a test (see my other post on disabling instead of enabling).
Enabling Windows Firewall with PowerShell can be done by going through the following steps:
Before running any command or script on your machine, it’s important for us to understand everything that it’s doing. In the command below we are disabling all 3 profiles:
# Domain – For when you are connected to a Domain Controller (computer connected to AD). # Private – For your home or private networks. # Public – For public WIFI locations such as coffee shops etc.
PowerShell commands follow standards and use verb-noun pairs for cmdlets. The verb at the start of the command describes the action the cmdlet performs, and the noun part is the action being performed. Here’s a list of Common Verbs, another Microsoft Docs link. The place of truth as I call it.
In this demo, we’re running Get-NetFirewallProfile with Format-Table We’re getting the Firewall Profile status, and also formatting it into a table after a pipe ‘|’ –
# get local firewall status
Get-NetFirewallProfile | Format-Table Name, Enabled
In the example above, the Windows Firewall is disabled, showing as ‘False‘.
We’re switching the cmdlet we ran above from Get to Set here (following on from verb-noun cmdlet descriptions).
To be able to run this; we have to open PowerShell or Windows Terminal as Administrator.
Set-NetFirewallProfile is being executed below, which enables all Profiles of the Local Windows Firewall –
# disable local firewall
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
# get local firewall status
Get-NetFirewallProfile | Format-Table Name, Enabled
I followed the change by another run of Get-NetFirewallProfile to verify the change.
This post contains a demo on how to disable Windows Firewall with PowerShell on a Windows computer.
Disabling the Local Firewall on Windows is not a recommended move, and it will ultimately make your computer less secure. Sometimes it’s necessary though, for example, during troubleshooting a difficult issue you might want to disable it for a quick test to rule the FW out as being the root cause. But in this example, you will have already tried to ensure the Firewall Rule exists before turning it off completely.
Anyway, disabling Windows Firewall with PowerShell can be done by going through the following steps:
Before running any command or script on your machine, it’s important for us to understand everything that it’s doing. In the command below we are disabling all 3 profiles:
# Domain – For when you are connected to a Domain Controller (computer connected to AD). # Private – For your home or private networks. # Public – For public WIFI locations such as coffee shops etc.
PowerShell commands follow standards and use verb-noun pairs for cmdlets. The verb at the start of the command describes the action the cmdlet performs, and the noun part is the action being performed. Here’s a list of Common Verbs, another Microsoft Docs link. The place of truth as I call it.
In this demo, we’re running Get-NetFirewallProfile with Format-Table We’re getting the Firewall Profile status, and also formatting it into a table after a pipe ‘|’ –
# get local firewall status
Get-NetFirewallProfile | Format-Table Name, Enabled
This is a post to share an opinion on the best Terminal for Windows 2022. The answer to all our needs in the year 2022 is Windows Terminal.
I have a blog post on How to Install Windows Terminal, and here is a link to the main Windows Terminal GitHub repo. You’ll find more up-to-date Windows Terminal information by following the GitHub link. This guide is a personal post to share a random thought.
That’s it. Done. Nothing much else to know about CLI Terminals in Windows. No need to be looking at other Windows Terminals in 2022, especially if you’re learning the ropes.
I’ll be honest, my reason for posting this one is to see how it performs against other websites for the term “Best Terminal for Windows”. It’s crazy, every post has way too much information – here are a billion different types of terminals in Windows. Download and try them all, even if you’re a novice.
Every one of them is over the top, all done for the Google SEO Ranking points that you get for writing 10,000 words in a post for a target keyword.
But… if you’re up for exploring random text editors that some folk think makes a good Windows Terminal, then go ahead.
Best Terminal for Windows
The best Terminal in Windows to use is Windows Terminal, as mentioned at the top of this post.
This is the best terminal to get you started if you’re committed to using the Windows OS. Anything else is exploratory. The best way to approach software in my opinion is, to choose the default vendor first. In this case, and in most of my work it’s Microsoft. So go try out the software that Microsoft is developing first if you are on a Windows OS, and if it’s not working to your needs, try to find an alternative.
In Windows Terminal, we can have multiple tabs for whichever terminal session need. One of the best examples is WSL –
This is a very different post from what I usually do. But it’s good to share an honest straight-to-post thought. I intentionally don’t give much personality away on this blog. It’s a place for posting my technical notes, with the hope that it provides every viewer with what they were searching for Online.
At least this top Terminal for Windows list comes from someone in the software/database engineering game. I use Windows Terminal every day and love it. Also, this post will likely & intentionally get lost in the nether. As ever, see how goes.
That’s me for now, over. This is the post you need to truly understand what the Best Terminal for Windows is, I’m sure you’ll agree.
In this post, I share a script that will help you create folders and sub-folders with PowerShell if they do not already exist. We use Test-Path in our PS scripts to check if objects exist before executing the create command.
This is one small part of a more detailed blog post I have on creating files and folders using PowerShell. My other post, How to Create New Files & Folders in PowerShell also covers more details on the differences between creating files vs creating folders.
Create New Folder (if not exists) in PowerShell
We’re creating a new folder, only if it doesn’t already exist – “C:\temp\demo”
The create folder command is New-Item, which runs conditionally depending on the Test-Path true/false result. When we run this script it also creates your C:\temp directory if it doesn’t already exist.
# create folder if not exists .ps1
$path = "c:\temp\demo"
If(!(Test-Path $path) ){
New-Item -ItemType Directory -Force -Path $path
}
This is a post on how to create new files and folders using PowerShell.
Creating new files and folders in Windows is generally done via GUI. That’s what it’s there for, the simplicity. But when you’re scripting or doing admin work, you might want to create new files and folders via command.
This guide covers performing the following in your PowerShell Terminal –
This is a post on how to change a Windows Subsystem for Linux (WSL) Distribution from running on Version 2 to Version 1.
WSL has two versions, the latest (2), and the original version (1). You can have many different Linux Distributions installed on your machine, and you can easily change the WSL Version for one of them.
This Microsoft documentation page explains the key differences between versions and will help explain why you might want to downgrade back to version 1 for your particular WSL development needs.
To change one of your WSL Distributions from WSL2 to WSL1, we just need to pass in the –set-version parameter and it’ll be converted very quick. I’m listing my available WSL Distro’s before and after to visually verify the change.
# check wsl distro versions
wsl -l -v
# change wsl distro using name above to desired version
wsl --set-version Ubuntu 1
This is a post on how to reboot a Windows Subsystem for Linux (WSL) virtual machine environment on your local machine. I’ve needed to do this a few times in the past year, my WSL instance throws some random error which was only resolved after a reboot.
As far as I know, we are unable to reboot from within WSL due to the lack of systemd. There are some open-source projects in the works to enable this which I’ve not tried yet. So we need to run a simple ‘wsl’ command to shutdown the host, and the enter WSL to get it back online.
This example shows exactly that, and I’m listing my installed WSL Distributions between each step.
# check wsl version
wsl -l -v
# reboot wsl2 instance
wsl --shutdown
# enter default wsl instance to boot
wsl
If you have multiple Linux Distributions installed on your Windows machine, by default you can only have one of them running, so when you’re switching between using ‘wsl -d <instanceName>’ the other will go offline. There is a way to get multiple WSL instances running at the same time, even with a GUI – have a look at this WSL Distro Manage project in GitHub if of interest.
One last note, the LXSS Manager Service is the broker to the Linux subsystem driver. We can also restart this service or of course reboot our local machine.
WSL allows users to develop and run applications within a GNU/Linux environment on a Windows computer. Previous to this Windows Feature you might have needed VM’s or a dual boot setup for this type of test/development environment.
There are 2 versions of WSL, the old (1), and the new (2). We should ideally be using the latest version like all other software in existence, but there are use cases where we might prefer to use WSL Version 1. This Microsoft documentation page explains the key differences between versions, and this post is to help explain how to check your WSL Version.
Personally I prefer to use WSL Version 2 as we’re able to make use of more apps like Docker. Also, I don’t need to worry about the exceptions for when it’s best to use WSL Version 1.
With descriptions out of the way, we can check our WSL Versions by running the following from a PowerShell Terminal –
# check wsl version
wsl -l -v
The above gives us a list of all installed Linux Distributions on your local machine including WSL Versions.
This is a post on how to help manage S3 Buckets with AWS CLI, and to help explain some local Operating System (OS) considerations when running such commands.
I’m more often involved in the PowerShell side rather than Linux. AWS CLI commands do the same thing in both environments, but the native (OS) language is used around it for manipulating data for output and for other things like wrapping commands in a For Each loop. All commands in this post can run on either OS.
PowerShell is cross-platform and has supported various Linux & DOS commands since its release. Some are essential for everyday use, for example, ping, cd, ls, mkdir, rm, cat, pwd and more. There are more commands being added over time like tar and curl which is good to see. Plus, we have WSL to help integrate non-supported Linux commands.
Here’s one of the simplest examples which list all S3 buckets the executing IAM User owns within your AWS Account.
# List all buckets in an AWS Account
aws s3 ls
The Default Region is configured during the AWS CLI Configuration as linked above. We can change this by running aws configure set region or configure your Environment Variables. Alternatively, we can pass in the –Region variable after ‘ls’ in the command to get a specific Region’s S3 Buckets. There are more ways for us to run commands across multiple Regions which I hope to cover another day.
Now I’m going to run a command to show me the Access Control List (ACL) of the bucket, using the list of Bucket Names I ran in the previous command. This time, I’m utilising the s3api command rather than s3 – look here for more information on the differences between them. When running AWS CLI commands these API docs will always help you out.
# Show S3 Bucket ACL
aws s3api get-bucket-acl --bucket my-bucket
Next up, I’m going to create a bucket using the s3 command rather than s3api. The reason I’m doing this is, I want to rely on my Default Region for the new S3 Bucket, rather than specifying it within the command. Here’s AWS’s explanation of this –
“Regions outside of us-east-1 require the appropriate LocationConstraint to be specified in order to create the bucket in the desired region – “ –create-bucket-configuration LocationConstraint=eu-west-1 AWS API Docs
The following command is creating a new S3 Bucket in my Default Region and I’m verifying the location with get-bucket-location afterwards.
# Change AWS CLI Default Region
aws configure set region eu-west-1
# Create a new S3 Bucket in your Default Region
aws s3 mb s3://pw-blog-bucket-101
# Check the Region of a S3 Bucket
aws s3api get-bucket-location --bucket pw-blog-bucket-101 --output text
And finally, to finish this off I’m going to: – Create a folder (known as Object) within the new Bucket. – List items in the S3 Bucket. – Copy a file from my desktop into the folder. – List items in the S3 Bucket. – Delete the Bucket.
# Create folder/object within a S3 Bucket
aws s3api put-object --bucket pw-blog-bucket-101 --key folder1/
# Show objects within S3 Bucket
aws s3 ls s3://pw-blog-bucket-101 --recursive --human-readable
# Copy a local file into the folder above
aws s3 cp .\Upload2S3.txt s3://pw-blog-bucket-101/folder1
# Show objects within S3 Bucket
aws s3 ls s3://pw-blog-bucket-101 --recursive --human-readable
# Delete the S3 Bucket
aws s3 rb s3://pw-blog-bucket-101
# List the S3 Bucket above (expect error)
aws s3 ls s3://pw-blog-bucket-101