1

我有一个奇怪的行为,powershell 创建了点:

我的脚本创建分区并将它们挂载到文件系统中。重新启动后,每个分区都会添加一个驱动器号。

到目前为止我的脚本:

  $disks = Get-Disk|where {$_.Number -ge 5}  ## >= 5: index disks
  $counter = 1
  foreach( $disk in $disks){
    $diskName="Disk_"+$counter.ToString("00")
    $disk = $disk | initialize-Disk -PartitionStyle GPT -passthru|new-partition -UseMaximumSize
    Format-Volume -Partition $disk -FileSystem ReFS -NewFileSystemLabel $diskName -Confirm:$false
    New-Item -ItemType Directory -Path ( "f:\Mounts\"+$diskName )
    $disk | Add-PartitionAccessPath -AccessPath ( "f:\Mounts\"+$diskName )
  }

起初,我将挂载点磁盘创建为 ReFS。这运作良好,但驱动器号也出现在重新启动后。重新启动后,磁盘管理 MMC 中也未显示安装点。使用 NTFS 修复了最后一个问题,但使用上述脚本时,驱动器号仍会重新出现。

如果我手动删除驱动程序字母,它不会回来。

系统是Server 2012 R2

有任何想法吗?

4

1 回答 1

1

在 Harry Johnston 的提示之后,我找到了一个可行的解决方案:

  $disks = Get-Disk|where {$_.Number -ge 5}  ## >= 5: index disks
  $counter = 1
  foreach( $disk in $disks){
    $diskName="Disk_"+$counter.ToString("00")
    $disk = $disk | initialize-Disk -PartitionStyle GPT -passthru|new-partition -UseMaximumSize
    Format-Volume -Partition $disk -FileSystem ReFS -NewFileSystemLabel $diskName -Confirm:$false
    New-Item -ItemType Directory -Path ( "f:\Mounts\"+$diskName )
    $disk | Add-PartitionAccessPath -AccessPath ( "f:\Mounts\"+$diskName )
    $disk | Set-Partition -NoDefaultDriveLetter $true
  }

最后一行被添加并阻止操作系统自动添加驱动器号。

于 2017-05-19T08:48:50.093 回答