![](/img/trans.png)
[英]Map a Azure Fileshare to Azure Runbook local drive to use as temporary storage
[英]How to find Azure 'Temporary Storage' drive through powershell script
我们是否具有PowerShell脚本来查找天蓝色的“临时存储”驱动器。
通常,我使用下面的PowerShell脚本来查找驱动器信息。
Get-WmiObject -class Win32_logicalDisk -computername Server1
毫无疑问,包含“ pagefile.sys”的驱动器是临时驱动器。 该文件是隐藏的。 使用powershell的“ Get-ChildItem -force -file”查找隐藏的pagefile.sys文件。
现在有了逻辑,您可以构造您的cmdlet了:)
我根据称为“临时存储”的卷进行设置。 我最终在这里寻找更好的解决方案,但是这是我所拥有的:
$volumes = get-volume
foreach ($volume in $volumes) {
if ($volume.FileSystemLabel -eq "Temporary Storage") {
$tempDrive = $volume.DriveLetter+":\"
}
}
这似乎在我的一些测试VM上也能正常工作。
foreach ($partition in get-partition) {
if ($partition.DiskPath -eq "\\?\ide#diskvirtual_hd______________________________1.1.0___#5&2d5f53a1&0&0.1.0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}") {
$tempDrive = $volume.DriveLetter+":\"
}
}
这是使用@Manjunath Rao逻辑的单线代码。
分区| %{get-childitem -force -file -filter pagefile.sys -Path(“ {0}:\\” -f $ _。DriveLetter)-ErrorAction SilentlyContinue} | 选择-ExpandProperty PSDrive
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.