0 votes
in Rock by MarissaEubanks (4.0k points)
edited

Run the script below in the Lava Tester in your client's Rock instance to view their current drive percent full:

1 Answer

0 votes
by MarissaEubanks (4.0k points)
edited
 
Best answer
{% execute type:'class' %}
    using Rock;
    using Rock.Data;
    using Rock.Model;
    using System.IO;
    using System.Text;
    
    public class MyScript
    {
        public string Execute()
        {
            DriveInfo[] allDrives = DriveInfo.GetDrives();

            var sb = new StringBuilder();
            foreach ( DriveInfo d in allDrives )
            {
                sb.Append( "Drive " + d.Name );
                if ( d.IsReady == true )
                {
                    var used = d.TotalSize - d.TotalFreeSpace;
                    var rem = ( decimal ) used / ( decimal ) d.TotalSize;
                    sb.Append( "  Percent Full " + (rem * 100m ).ToString("0.00"));
                    sb.Append( "<br>" );
                }
            }
            return sb.ToString();
        }
    }
{% endexecute %}
Welcome! Here you can ask questions and receive answers (hopefully) from other members of our team.
...