How to delete disk partitions on Windows using PowerShell

Today I just added an old SSD to a Windows machine to use it as a back up drive. With old disks, usually they come with existing data, and I wanted to get rid of it. The problem is I couldn’t figure out how to do this using the Disk Management, the native GUI application used to manage disks. The problem could be simple to Windows users. Basically, when I right-clicked on the 2 partitions (450 MB and 100 MB) on Disk 0, there is no option to remove them....

May 15, 2022 · 3 min · 618 words · kenno

Where is which in PowerShell

As the title says, an easy way to find out the path of a program/command on Windows using PowerShell can be done with Get-Command cmdlet. For example, I want to find out where I had installed nvim (Neovim) on a rarely use Windows machine. To do this, I can execute the following command: ❯ Gt-Command nvim CommandType Name Version Source ----------- ---- ------- ------ Application nvim.exe 0.0.0.0 C:\Program Files\Neovim\bin\nvim.exe With PowerShell, we can also just print a specific attribute (?...

June 16, 2021 · 1 min · 114 words · kenno

Line Continuation in PowerShell

Usually on bash command-line, the line break character is \. So when I first started to use PowerShell, the \ didn’t work for me. It turned out that the line-break or line continuation in PowerShell is the back tick: `. Here is an exmaple of PowerShell command to create a DNS delegation in one line: PS C:\ Add-DnsServerZoneDelegation -Name "example.net" -ChildZoneName "lab.example.net." -NameServer "idm.lab.example.net." -IPAddress 172.25.250.8 -PassThru -Verbose And we can break it to mutiple line as:...

December 23, 2020 · 1 min · 99 words · kenno

DNS Delegation on Windows Server

One of the requirements to join an Identity Management Server (IdM) to an Active Directory (AD), a DNS delegation needs to be created on AD. With the Red Hat training for RH362, we were taught to use a command-line interface program called dnscmd on AD server. I personally found this command very cumbersome, and I think a better way is to do this DNS delegation using PowerShell cmdlet. I’ll demonstrate how to do DNS delegation both using dnscmd and PowerShell cmdlet....

November 19, 2020 · 2 min · 400 words · kenno

Create Folder Recursively With Powershell

Let’s say I want to create the following directories: C:/Program Files/MiKTeX 2.9/tex/latex/math using PowerShell because, as you may guess it, it’s a Windows directory structure. Here’s the command to do that: PS C:\> New-Item -Type Directory -Path "C:/Program Files/MiKTeX 2.9/tex/latex/math" The command seems simple enough. So why did I create this post? Well, guess what? I have to Google this out for the 3rd time this month. From now, if I need to look it up again, I can just go to https://blog....

May 14, 2020 · 1 min · 91 words · kenno