繁体   English   中英

Powershell Mount Point Automation:重启后会显示驱动器号

[英]Powershell Mount Point Automation: Drive letter appears after reboot

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

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

我的脚本到目前为止:

  $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修复了上一个问题,但在使用上述脚本时,驱动器号stil重新出现。

如果我手动删除了驱动器号,它就不会回来。

该系统是Server 2012 R2

有任何想法吗?

在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
  }

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM