Skip to content

Instantly share code, notes, and snippets.

@metastable
Created February 28, 2019 09:26
Show Gist options
  • Select an option

  • Save metastable/08aba803a578ac2dd9d75a3e98607413 to your computer and use it in GitHub Desktop.

Select an option

Save metastable/08aba803a578ac2dd9d75a3e98607413 to your computer and use it in GitHub Desktop.
Azure VM Drive D Format Script (SAMPLE)
#!/usr/bin/env powershell -File
# * Make sure you run this script from a Powershel Admin Prompt!
# * Make sure Powershell Execution Policy is bypassed to run these scripts:
# * YOU MAY HAVE TO RUN THIS COMMAND PRIOR TO RUNNING THIS SCRIPT!
Set-ExecutionPolicy Bypass -Scope Process -Force
wmic computersystem set AutomaticManagedPagefile=False
wmic pagefileset delete
Stop-Service -Name ShellHWDetection
Clear-Disk -Number 1 -RemoveData -RemoveOEM -Confirm:$false -passthru
Set-Disk -Number 1 -IsOffline $False
Set-Disk -Number 1 -IsReadonly $False
Initialize-Disk -Number 1 -PartitionStyle GPT
Remove-Partition -DiskNumber 1 -PartitionNumber 1 -Confirm:$False
New-Partition -DiskNumber 1 -DriveLetter D -UseMaximumSize
Format-Volume -DriveLetter D -FileSystem ReFS -AllocationUnitSize 65536 -NewFileSystemLabel 'Temporary' -SetIntegrityStreams $False -Confirm:$false -Force
Start-Service -Name ShellHWDetection
# Create Temp Directory
New-Item -Path D:\Temp -ItemType directory
wmic pagefileset create name="D:\\pagefile.sys"
wmic computersystem set AutomaticManagedPagefile=True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment