Jump to content
kuuser

Disk cleanup script (with treesize before and after), results emailed and added to Connectwise ticket

Recommended Posts

quick question. I have been monitoring this post some what and noticed many users requesting this script. My question is has anyone actually received the script by any chance. if yes if possible to send me a copy pleas. 

 

thank you 

Share this post


Link to post
Share on other sites

i am also interested in the script id be willing to help out and add additional directories to the script as well.

Share this post


Link to post
Share on other sites

For everyone posting, I think it's safe to say this isn't happening and the author of the topic has gone missing. 

Share this post


Link to post
Share on other sites

Hopefully this post will revive some life into this idea.

For anyone interested, here's my TreeSizePRO script that I use to get disk-space reports for our customers.  This script is pretty old so I went and wrote some documentation on how to get it installed and working correctly.  I hope it can help anyone out there looking to use TreeSizePro with Automate and possibly give people ideas on how to make it better.  The TreeSizeProAutomateScript.7z file attached to this post includes the XML script and PDF instruction guide on how I configured my system.  I am sure there's a million better ways to set this up and your welcome to hack away to your hearts content.

Some important points before you download:

  1. The script requires a licensed copy of TreeSizePro as the FREE version does not support passing command-line parameters.
  2. You need an OLD version of TreeSizePro (Pre 6.2) as anything newer has the following limitations:
    • Newer versions will not run on WinXP/Win2003
    • Newer versions require .NET 4.5 pre-installed
    • Newer versions require the portable version to be run from a USB drive
  3. The old version that I use with my script (6.1.1.1026 32.bit) does have have any of the above limitations.
  4. You will need to contact JAM software (URL in the Documentation) to obtain the legacy version.
  5. The script is not Plug and Pray.
    • You need to modify two lines to confirm the location of where you are storing the TreeSize.EXE and TreeSize.INI files.
    • You need to modify the location of where you are storing the 7za.exe file that zips up the reports and prepares them for e-mailing to you.image.thumb.png.2b884ed7e72170ec9e9d510c6c200fea.png

 

Here's an overview of what the script does:

  1. Runs TreeSizePro silently on the users computer.
  2. Creates 3 files
    1. A  %COMPUTERNAME%_FILES.XML that you can load into Excel to see the largest files.
    2. A  %COMPUTERNAME%_FOLDERS.XLSX that you can load into Excel to see the largest folders.
    3. A  %COMPUTERNAME%_TREE.XML that you can load into any copy of TreeSizePro to review the computer in detail.image.png.5bc7e61e7f5a78a451086aebaf986e49.png
    4. Once complete, the three reports are zipped up (using 7-Zip) and e-mailed to the tech who ran the script.

 

Example Largest Files:
image.thumb.png.cb58e696b8136727418d2c00dae9ec99.png

Example Largest Folders:
image.png.9c1812a8563a37ff6d9a478fa7a17ad7.png

Example TreeSize.XML report:
image.png.4976430ab41f2ff90e1f629133dda451.png

 

The Script:
image.thumb.png.5f671d628c1787fa1b95f2f685bbe89d.png

  1. Attachment Updated: 7/22/2018 @ 2:00 p.m. PST

TreeSizeProAutomateScript.7z

image.png

  • Like 1

Share this post


Link to post
Share on other sites

Hi,

I've found and modified a powershell script that can output HTML and do roughly the same.
You will need to setup an SMTP relay server, account and the appropriate email address.
Parameters are optional, it will use defaults if you leave them blank.

It will email a report. The body and attachment contain the tree sorted by size. If you open the attachment in a browser javascript will kick it to make it expandable.
like so:

image.png.664c2fc78386f62d2ba4542bc707c471.png

Treesize (Email).xml

Share this post


Link to post
Share on other sites
On 7/27/2018 at 5:42 PM, Wupsje said:

Hi,

I've found and modified a powershell script that can output HTML and do roughly the same.
You will need to setup an SMTP relay server, account and the appropriate email address.
Parameters are optional, it will use defaults if you leave them blank.

It will email a report. The body and attachment contain the tree sorted by size. If you open the attachment in a browser javascript will kick it to make it expandable.
like so:

image.png.664c2fc78386f62d2ba4542bc707c471.png

Treesize (Email).xml

I really like this idea. I have imported and testing, yet without the mailing piece. However I get some errors in the powershell : 

 At C:\WINDOWS\system32\config\systemprofile\AppData\Local\005bad98b86d4a43a3a5b85e0891dc8d.ps1:10 char:100
+ ... ng] $folderSizeFilterMinSize = (@folderSizeFilterMinSizeinMB@*1024*10 ...
+                                                                 ~
Unrecognized token in source text.
At C:\WINDOWS\system32\config\systemprofile\AppData\Local\005bad98b86d4a43a3a5b85e0891dc8d.ps1:10 char:100
+ ... ng] $folderSizeFilterMinSize = (@folderSizeFilterMinSizeinMB@*1024*10 ...
+                                                                 ~
Unexpected token '@' in expression or statement.
At C:\WINDOWS\system32\config\systemprofile\AppData\Local\005bad98b86d4a43a3a5b85e0891dc8d.ps1:10 char:100
+ ... ong] $folderSizeFilterMinSize = (@folderSizeFilterMinSizeinMB@*1024*1 ...
+                                                                  ~
Missing closing ')' in expression.
At C:\WINDOWS\system32\config\systemprofile\AppData\Local\005bad98b86d4a43a3a5b85e0891dc8d.ps1:10 char:100
+ ... ong] $folderSizeFilterMinSize = (@folderSizeFilterMinSizeinMB@*1024*1 ...
+                                                                  ~
Missing ')' in function parameter list.
At C:\WINDOWS\system32\config\systemprofile\AppData\Local\005bad98b86d4a43a3a5b85e0891dc8d.ps1:10 char:111
+ ... $folderSizeFilterMinSize = (@folderSizeFilterMinSizeinMB@*1024*1024),
+                                                                        ~
Unexpected token ')' in expression or statement.
At C:\WINDOWS\system32\config\systemprofile\AppData\Local\005bad98b86d4a43a3a5b85e0891dc8d.ps1:12 char:5
+     )
+     ~
Unexpected token ')' in expression or statement.
At C:\WINDOWS\system32\config\systemprofile\AppData\Local\005bad98b86d4a43a3a5b85e0891dc8d.ps1:10 char:72
+ ... ong] $folderSizeFilterMinSize = (@folderSizeFilterMinSizeinMB@*1024*1 ...
+                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The splatting operator '@' cannot be used to reference variables in an expression. '@folderSizeFilterMinSizeinMB' can b
e used only as an argument to a command. To reference variables in an expression use '$folderSizeFilterMinSizeinMB'.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnrecognizedToken

Share this post


Link to post
Share on other sites

Apparently ConnectWise Automate has issues with the @variablename@ in this Powershell script, as when replacing these with the actual values the PowerShell script works. And wow, what a nice output. Anyone have any ideas why this error appears ??

 

Share this post


Link to post
Share on other sites
On ‎9‎/‎6‎/‎2018 at 3:05 PM, thomasp said:

Apparently ConnectWise Automate has issues with the @variablename@ in this Powershell script, as when replacing these with the actual values the PowerShell script works. And wow, what a nice output. Anyone have any ideas why this error appears ??

 

I'm unsure why it's not working for you. You could use replace that parameters with a fixed value.

Edited by Wupsje

Share this post


Link to post
Share on other sites
On 10/1/2018 at 5:53 PM, Wupsje said:

I'm unsure why it's not working for you. You could use replace that parameters with a fixed value.

It it working for me, not sure why it did not in the first place. Changed some of the parameters in a fixed value and leaving some as a parameter.

A real nice looking script with a great output, helping us a lot !!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×