Function CleanUp-PSDrive {
Get-PSDrive -PSProvider FileSystem | Where { $_.Name -in (69..90 | ForEach-Object { [char]$_ })} | Remove-PSDrive
}
$Csv = Import-Csv "C:\Users\503080876\Documents\New folder\new.txt"
$Csv.Name | ForEach-Object -Begin { $Letter = 69 } {
New-PSDrive -Root $_ -Name([char]$Letter) -PSProvider FileSystem
#select root,used |
select used,free | export-csv "C:\Users\503080876\Documents\New folder\New1.txt"
if ($Letter -lt 90)
{
$Letter++
}
else
{
CleanUp-PSDrive
$Letter = 69
}
} -End { CleanUp-PSDrive }
答案 0 :(得分:0)
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 } |
选择对象@ {name =“文件共享名”; expression = {$$ em ..'DisplayRoot'}},@ {name =“ Total(GB)”; expression = {($ .free + $ .used)/ 1GB}},@ {name =“ Used(GB)”; expression = {$ .used / 1GB}},@ {name =“ Free(GB)” ; expression = {$ _。free / 1GB}} |
export-csv“路径” -NoTypeInformation