ServerCore loads shared storage via PowerShell script

Since ServerCore does not have a graphical management interface, it is very troublesome to load and initialize the shared storage. The initialization operation can only be performed through the DiskPart command. To simplify the operation, the following PowerShell script can be used:
 
   "List disk" | diskpart #List all current logical disks 
  
   $SelectDisk = Read-Host "Please select the logical disk to be loaded"
   "Select Disk $SelectDisk `r ATTRIBUTES DISK CLEAR READONLY `r Online Disk `r CONVERT BASIC `r CREATE PARTITION PRIMARY" | diskpart
  
   "List VOLUME" | diskpart #List all current logical volumes
  
   $SelectVolume = Read-Host "Please select the logical volume to be loaded"
   $DiskLable = Read-Host "Please enter the disk volume name"
   $SelectASSIGN = Read -Host "Please assign a drive letter to the logical volume"
  
   "SELECT VOLUME $SelectVolume `r FORMAT QUICK FS=NTFS LABEL=$DiskLable `r ASSIGN LETTER=$SelectASSIGN" | diskpart

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326643289&siteId=291194637