when using measure-object -property length, sometimes an exception is thrown. i suspect maybe it has to do with user rights.
added another piece of code that gets folder size without such exception being thrown