How to find the primary drive in windows using powershell


At times we may have to find some space in the machine where we can store some data. We cannot guess the drive as it may be different on different machine. With powershell we can find the drive to where the OS is mounted and can try to store the data there. The below line of code will help you achieve this using powershell.

$disk = Get-WmiObject -Class Win32_logicaldisk -Filter "VolumeName = 'OSDisk'"
echo ($disk.Properties | Where-Object{ $_.Name -eq  "Caption"}).Value.Trim();

Setting Up Kafka

Apache Kafka is a high-throughput, low-latency event processing system designed to handle millions of data feeds per second. It has the c...… Continue reading

Libish Varghese Jacob

Libish Varghese JacobI am a lead engineer at a prominent wind turbine manufacturing firm. My interests span a diverse range, and immersing myself in technology is one of them. This platform serves as my primary knowledge base, where I seek information and insights. Moreover, I utilize this platform to share my experiences and experiments, hoping they may benefit those following a similar path. It's important to note that the suggestions I express here are based on my best knowledge at the time of writing and may not necessarily represent the optimal solutions. I wholeheartedly welcome any comments you may have to improve or refine my ideas. Your feedback is greatly appreciated and valued.