Function CleanUp-PSDrive {
Get-PSDrive -PSProvider FileSystem | Where { $_.Name -in (69..90 | ForEach-Object { [char]$_ })} | Remove-PSDrive
}
$Csv = Import-Csv "path"
$ Csv.Name | ForEach-Object -Begin {$ Letter = 69} {
new-PSDrive -Root $ _ -Name ([char] $ Letter) -PSProvider FileSystem -Persist
if ($Letter -lt 90)
{
$Letter++
}
else
{
CleanUp-PSDrive
$Letter = 69
}
} -End { CleanUp-PSDrive } |
Select-Object @ {name = "Имя общего ресурса файла"; expression = {$ . 'DisplayRoot'}}, @ {name = "Total (GB)"; expression = {($ . free + $ .used) / 1 ГБ}}, @ {name = "Используется (ГБ)"; expression = {$ .used / 1 ГБ}}, @ {name = "Free (ГБ)"; выражение = {$ _. free / 1GB}} |
export-csv "путь" -NoTypeInformation