MrPig91 / PSChiaPlotter

A repo for powershell module that helps Chia Plotting
MIT License
181 stars 47 forks source link

Suggestions for disks #114

Open blllc opened 3 years ago

blllc commented 3 years ago

I'm not a programmer or scripter or whatever, but this is a nice change to the Get-ChiaVolume script:

 $mappedDrives = gwmi win32_LogicalDisk
    $BusType = "Logical"
    $MediaType = "Unknown"
    foreach ($drive in $mappedDrives){
        try{
            if ([string]::IsNullOrEmpty($drive.ProviderName)){
                $Label = "N/A"
            }
            else{
                $Label = $drive.ProviderName
            }
            if (-not[string]::IsNullOrEmpty($drive.DeviceID)){
                $DriveLetter = $drive.DeviceID.TrimEnd(':')
                $ChiaVolume = [PSChiaPlotter.ChiaVolume]::new($drive.VolumeSerialNumber,$Label,$drive.Size,$drive.FreeSpace)
                $ChiaVolume.BusType = $BusType
                $ChiaVolume.MediaType = $MediaType
                $MaxTempCount = [math]::Floor([decimal]($drive.size / (239 * 1gb)))
                $ChiaVolume.MaxConCurrentTempChiaRuns = $MaxTempCount
                $ChiaVolume.DriveLetter = $DriveLetter
                $DirectoryPath = $DriveLetter + ':\'
                $ChiaVolume.DirectoryPath = $DirectoryPath
                $ChiaVolume.AccessPaths.Add($DirectoryPath)
                if (Test-Path $label){
                    $ChiaVolume.AccessPaths.Add($Label)
                }
                $ChiaVolume
                Clear-Variable DriveLetter -ErrorAction SilentlyContinue
                $Log = @{
                    LogType = "INFO"
                    Message = "Chia Volume Found: Letter $($ChiaVolume.DriveLetter), UniquieId: $($ChiaVolume.UniqueID)"
                }
                Write-PSChiaPlotterLog @Log
            }
        }
        catch{
            Write-PSChiaPlotterLog -LogType "Warning" -Message "Unable to create a ChiaVolume from driveletter $($DriveLetter.DriveLetter)"
            Write-PSChiaPlotterLog -LogType ERROR -ErrorObject $_
        }
    }
}

With that, you can now see RAID-0/spanned drives with their drive letters.

Also, I'm not sure why it breaks the drive discovery in the GUI when trying to assign a logical drive mapped to a folder, but it does... otherwise you could use gwmi win32_volume for the first part of the script and also display the directory names as "DriveLetter" instead of the ?. Sorry, I wish I could be more help, but I'm just a simple caveman. Good luck.

MrPig91 commented 3 years ago

The driveletter that starts with "?" are those that are mapped to a folder and not a driveletter. I am using the MSFT_Volume CIM class (Get-Volume is wrapper around this essentiall) instead of win32_volume or win32_logical disk because it supersedes those WMI classes. Get-WMIObject is also deprecated which is why I am using functions that use CIM instead when I can. Dynamic disks ore spanned drives have been deprecated since 2004 and so this program intentionally leaves them out by design. Storage pools is the recommended replacement for this.

Can you expand on the expand on how assigning a logical drive mapped to folder beaks the drive discovery in the GUI? If a volume was mapped to a folder location it should pick it up, which is where the drive letter ? comes from since it has no drive letter. Unless, I am getting confused, I am too just a simple caveman :)

blllc commented 3 years ago

Sorry, it was late - I guess to clarify, it's not super helpful having the ? when you have 12 disks mapped to folders. It would be much easier if you showed the folder mapping in the dropdowns and list. Right now if I change the code to allow it to use "X:\YourFolder\" in place of a DriveLetter, they will not show up in either form, ? or "X:\YourFolder\"

I chose the gwmi because the output more closely resembles your code, and variables were easier to match up/substitute. CimInstance has some different variables, IIRC. And I understand the issue with Spanned volumes, but it doesn't help if you already have them set up and lack the drive space to move plots to a safe haven while you convert to storage pools... not that I know anyone in that predicament. ;)

Thanks!