• drop table #tfoldsizeinMB

    create table #tfoldsizeinMB(size nvarchar(100))

    declare @cmd varchar(3000)='powershell "(Get-ChildItem ''D:\backups\MSSQLSERVER\'' -recurse | Measure-Object -property length -sum).sum/1MB"'

    --select @cmd

    insert into #tfoldsizeinMB

    EXEC xp_cmdshell @cmd

    select CEILING(size) as 'Size(MB)' from #tfoldsizeinMB where size is not null

    Thanks.