Posted On August 28, 2020

PowerShell: Quick Exercise On Disks Operations

kimconnect 0 comments
blog.KimConnect.com >> Windows >> PowerShell: Quick Exercise On Disks Operations
# View disks on the system
get-disk

Number Friendly Name Serial Number                    HealthStatus         OperationalStatus      Total Size Partition
                                                                                                             Style
------ ------------- -------------                    ------------         -----------------      ---------- ----------
0      VMware Vir... 00000000000000000001             Healthy              Online                     200 GB MBR
1      VMware Vir... 00000000000000000002             Healthy              Online                     500 GB MBR

# Set variables
$diskNumber=1
$driveLetter='D'

# Wipe entire disk and recreate it
# WARNING: the following lines will destroy all data on the selected disk index number set above!
Clear-Disk -Number $diskNumber -RemoveData -RemoveOEM
Initialize-Disk -Number $diskNumber
New-Partition -DiskNumber $diskNumber -UseMaximumSize -IsActive -DriveLetter $driveLetter
format-volume -driveletter $driveLetter

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Create Registry Keys within Windows Localhost

# createRegKey.ps1 $regKeys=@( @{ hive='REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome'; name='ChromeCleanupEnabled'; value=0 } @{ hive='REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome'; name='ChromeCleanupReportingEnabled'; value=0 } ) function…

PowerShell: Optimize RAM on Remote Computers

# simultaneousExec_v0.01.ps1# Requirement: must run as Administrator$computerNames="SHERER1","SHERER2"function installEmptyStandbyList{ $emptyStandbyListAvailable=(Get-Command EmptyStandbyList.exe -ErrorAction SilentlyContinue); if(!($emptyStandbyListAvailable)){ # Set…

Open VPN Client Configuration Fix

OpenVPN client works very well on Windows 7 machines. However, its Windows 10 and Linux…