Jump to content
cmclean

TreeSize script

Recommended Posts

Created a script to be able to integrate the ps treesize report into labtech a little more using Cregs custom tabs plugin.

You need to create the folder C:\inetpub\wwwroot\LabTech\DISK then run the script

in the custom tabs Create a tab type webpage with a placement on computers and point it to http://yourlabtechserver.com/Labtech/Disk/%computerid%.html or https depending on what you have running.

 

It's not fast but it works.

TREE SIZE.zip

treesizeps1.zip

Edited by Guest

Share this post


Link to post
Share on other sites

You bet sorry not sure why it wouldn't export but added the script for downloading.

Put it in the LTShare\Transfer\Scripts folderor change it to wherever you want it.

Share this post


Link to post
Share on other sites
You bet sorry not sure why it wouldn't export but added the script for downloading.

Put it in the LTShare\Transfer\Scripts folderor change it to wherever you want it.

 

 

Thank you sir :D

 

-jeff

Share this post


Link to post
Share on other sites

I have it running once a day on all systems right now. haven't seen any problems with it but we only have around 300 systems on LT at the moment.

You could put an on demand button though in the custom tab.... now that I think about it that's a pretty good idea.

Share this post


Link to post
Share on other sites

The Script does not seem to be completing for me.

 

It goes to the point where the file is uploaded to the LTShare but it never copies it to the Inetpub. The SCript status continues to just say Running. The Command to copy never shows up in the Commands list.

 

Any Idea?

Share this post


Link to post
Share on other sites

Hi, does anyone run this powershell script on large datasets? I have run it on 2 Tb up to 6 Tb drives and the html file does not seem capable if listing things correctly. I know it's big ask running that sort of script and a drive that size, but it's on these drives that we would find the information most useful and if our guys can have that html file with fairly accurate information on whats what it's a huge time saver.

 

Thanks, regards Peter.

Share this post


Link to post
Share on other sites
The Script does not seem to be completing for me.

 

It goes to the point where the file is uploaded to the LTShare but it never copies it to the Inetpub. The SCript status continues to just say Running. The Command to copy never shows up in the Commands list.

 

Any Idea?

 

< Same here.

 

Been going through it, and I can't seem to find the hang-up. Tested on my PC, and "C_Drive.html" would upload to "\\LTShare\Uploads\[Company]\[PC NAME-ID]\" but looked as though it was hanging on the attempt to copy over to "[LT Server]\C:\inetpub\wwwroot\LabTech\DISK\"

 

But then, went to run it on a client's PC, and - after getting to the same point as previous test run - there wasn't even a [Company] Folder under "\\LTShare\Uploads." Drilled down to "C:\Windows\LTSvc\drive" on client PC...no C_Drive.html in there, either. :|

 

I'm the type to fully believe that it has something to do with an error on my part, so in the interest of full disclosure:

 

Imported TREE SIZE.xml (which automatically added "treesize.ps1" to "[LT Server]\LTShare\Transfer\Scripts").

Created "C:\inetpub\wwwroot\LabTech\DISK" on LT Server

Created Custom Tab via Greg's Custom Tabs Plug-In;

- Tab Text: --------------- TreeSize

- Title Text: -------------- TreeSize - Disk Size Info

- Subtitle Text:

- Tab Placement: -------- Computers

- Tab Section: ------------ Main Area

- Tab Type: --------------- WebPage

- Command Bar Align: -- Top

- URL: ---------------------- http://[LT Server FQDN]/LabTech/Disk/%computerid%.html

 

 

----OR does the initial run just take a decent chunk of time to complete?

Share this post


Link to post
Share on other sites
The Script does not seem to be completing for me.

 

It goes to the point where the file is uploaded to the LTShare but it never copies it to the Inetpub. The SCript status continues to just say Running. The Command to copy never shows up in the Commands list.

 

Any Idea?

 

< Same here.

 

Been going through it, and I can't seem to find the hang-up. Tested on my PC, and "C_Drive.html" would upload to "\\LTShare\Uploads\[Company]\[PC NAME-ID]\" but looked as though it was hanging on the attempt to copy over to "[LT Server]\C:\inetpub\wwwroot\LabTech\DISK\"

 

But then, went to run it on a client's PC, and - after getting to the same point as previous test run - there wasn't even a [Company] Folder under "\\LTShare\Uploads." Drilled down to "C:\Windows\LTSvc\drive" on client PC...no C_Drive.html in there, either. :|

 

I'm the type to fully believe that it has something to do with an error on my part, so in the interest of full disclosure:

 

Imported TREE SIZE.xml (which automatically added "treesize.ps1" to "[LT Server]\LTShare\Transfer\Scripts").

Created "C:\inetpub\wwwroot\LabTech\DISK" on LT Server

Created Custom Tab via Greg's Custom Tabs Plug-In;

- Tab Text: --------------- TreeSize

- Title Text: -------------- TreeSize - Disk Size Info

- Subtitle Text:

- Tab Placement: -------- Computers

- Tab Section: ------------ Main Area

- Tab Type: --------------- WebPage

- Command Bar Align: -- Top

- URL: ---------------------- http://[LT Server FQDN]/LabTech/Disk/%computerid%.html

 

 

----OR does the initial run just take a decent chunk of time to complete?

 

 

Seth, I concur. I lean towards myself as the error condition, but do my due diligence to prove or disprove either way. I followed your steps as well and believe it to be configured correctly based on the original post. I have gone as far as creating a seperate simple script to write a simple text file, then upload to LT, and then copy. I am finding that all works except for the copy. So I'm now focused on why the file does not copy. It could be because the script is defined to utilize the variable %uploadedfile% to c:\destination. I have tried several variations to copy this file using various script commands and all have failed. Anyone have suggestions? Thanks.

 

-jeff

Share this post


Link to post
Share on other sites

What version of labtech are you on?

 

The Script does not seem to be completing for me.

 

It goes to the point where the file is uploaded to the LTShare but it never copies it to the Inetpub. The SCript status continues to just say Running. The Command to copy never shows up in the Commands list.

 

Any Idea?

 

< Same here.

 

Been going through it, and I can't seem to find the hang-up. Tested on my PC, and "C_Drive.html" would upload to "\\LTShare\Uploads\[Company]\[PC NAME-ID]\" but looked as though it was hanging on the attempt to copy over to "[LT Server]\C:\inetpub\wwwroot\LabTech\DISK\"

 

But then, went to run it on a client's PC, and - after getting to the same point as previous test run - there wasn't even a [Company] Folder under "\\LTShare\Uploads." Drilled down to "C:\Windows\LTSvc\drive" on client PC...no C_Drive.html in there, either. :|

 

I'm the type to fully believe that it has something to do with an error on my part, so in the interest of full disclosure:

 

Imported TREE SIZE.xml (which automatically added "treesize.ps1" to "[LT Server]\LTShare\Transfer\Scripts").

Created "C:\inetpub\wwwroot\LabTech\DISK" on LT Server

Created Custom Tab via Greg's Custom Tabs Plug-In;

- Tab Text: --------------- TreeSize

- Title Text: -------------- TreeSize - Disk Size Info

- Subtitle Text:

- Tab Placement: -------- Computers

- Tab Section: ------------ Main Area

- Tab Type: --------------- WebPage

- Command Bar Align: -- Top

- URL: ---------------------- http://[LT Server FQDN]/LabTech/Disk/%computerid%.html

 

 

----OR does the initial run just take a decent chunk of time to complete?

 

 

Seth, I concur. I lean towards myself as the error condition, but do my due diligence to prove or disprove either way. I followed your steps as well and believe it to be configured correctly based on the original post. I have gone as far as creating a seperate simple script to write a simple text file, then upload to LT, and then copy. I am finding that all works except for the copy. So I'm now focused on why the file does not copy. It could be because the script is defined to utilize the variable %uploadedfile% to c:\destination. I have tried several variations to copy this file using various script commands and all have failed. Anyone have suggestions? Thanks.

 

-jeff

Share this post


Link to post
Share on other sites

LabTech Version

Current Control Center: v60.239

Current Agent: v60.239

 

 

Have you tried this....

 

\\[labtechserver]\c$\inetpub\wwwroot\LabTech\DISK\%uploadedfile%

 

I haven't done this before... But it's an 'educated' guess!! (????)

 

Ok, I can try that.

 

I changed last line to copy to \\lt.msinetworks.com\c$\inetpub\wwwroot\DISK\%computerid%.html. Think I should just use Server Name, or Server Name.Domain?

 

I think another problem might be that script requires PowerShell v 2.0 - and so far, the 2 clients I've tested to failure have been running WinXP SP3 and SBS 2003 SP2, both w/PS v1.

 

Installed Windows Update to WinXP SP3 PC, and am re-running script to verify. However, LabTech isn't listing SBS Windows Update for Windows Management Framework Core - so, that might be dead in the water.

 

Edit: Also, is there anything I need to do to get this to report for all volumes, or does it do that by default?

Share this post


Link to post
Share on other sites

Does anyone have this Working?

 

It simply will not run the Copy command. I see the issue being related to the LTServer since the last command would be running on it and not the Agent that the Script was run on. but the command never runs.

Share this post


Link to post
Share on other sites

Sorry I've been away for a bit. The only thing I can think of that would cause it off the top of my head is if your Labtech server doesn't have an ID of 1?

Share this post


Link to post
Share on other sites

Yea you will need to change the Set@computerid@ = to whatever number your LT server is. I falsely assumed they would all be 1. Sorry about that.

I tried to write it with the labtech server execute but I couldn't get it to work right and would have added a ton more complexity to the script.

Share this post


Link to post
Share on other sites

Seth: I think that the ID issue may be what you're running into as well.

As far as reporting all volumes it is possible but you have to know the volume letters ahead of time which can be put into a variable then written to the script but it would be two html files instead of one and the only way i can see that working is to maybe put the files into a zip and upload them.

I'll see if I can come up with something better I do agree that it would be nice to report on all drives on a system.

Share this post


Link to post
Share on other sites

And, it's official - I've been staring at a computer for far too long.

 

I changed the SET: @computerID@ = to the LTServer's Agent ID, and the script finished (before, it was seemed to be in a perpetual state of running, which would make sense if it was trying to hit Agent ID #1 - as there isn't one). The C_Drive.html file has not been copied over yet, though. I'm not too concerned with that - manually moving a file is not something I'm 'above;' I'm just happy the .html file is being generated and uploaded.

 

Now, I do have a minor question - and I hope it's not the kind that I read first thing in the morning, and begin questioning whether or not I should start scouting helmet-retailers so I can make sure I get one that will match whichever drool-rag I decide on - but...

 

With @computerid@ being set to the Agent ID of the LT Server...and with the next line of the script calling %computerid% for the name...does these not conflict?

Share this post


Link to post
Share on other sites

Now that you mention it...Maybe.. I'm going to completely be talking out of my ass since I tend to do a lot of research into scripting as I'm working on things then a few weeks later forget most everything.

 

I believe it will still pull the original id the script was run on if you use the %computerid% in the script its self. If you wanted to use the actual changed variable you would have to use the @computerid@ instead. using the "set computer id" only sets what system you want to the next set of lines in the script to run on.

Share this post


Link to post
Share on other sites

I finally resolved this with the following changes:

 

1.) Modified the @ComputerID@ from 1 to my LT Server ID

2.) Changed the function line in script from SHELL to FILE COPY and used %uploadedfile% as source path and c:\inetpub\wwwroot\labtech\disk\%computerid%.html for destination path.

 

Works Great! I'm attaching a modified version of the treesize.ps1 that will allow you modify line5 SHELL function to include other parameters such as paths, reportoutputfolder, htmlOutputFilenames, zipOutputFilename, topCountFilesperFolder, folderSizeFilterDepthThreshold, folderSizeFilterMinSize, and displayunit.

 

 

 

Powershell script includes examples of all defined parameters. If anyone can figure out how to manipulate the PS script to write all drives to a single HTML output file for upload to LabTech server that would be awesome.

 

Thanks.

 

-jeff

treesize.zip

Share this post


Link to post
Share on other sites

Thanks, Jeff - that FILE COPY adjustment worked perfectly. I didn't even consider that - since the SHELL command should have accomplished the same result (in theory).

 

I also uploaded your .PS1, but I'm not sure I see where the new parameter modification ability presents itself. Bear in mind: I'm a low-level, functioning retard on my good days. I also poked around the file a bit, to see if I couldn't make some adjustments to the default path/htmlOutputFilename - but I couldn't make any distinctions within the code as to where it was calling a particular drive letter.

 

I did notice, however, something on line 133 that might be a clue?

 

129 | function TreeSizeHtml {
130 |
131 |     $ErrorActionPreference = "Stop"
132 |
133 |     $pathsArray = @();
134 |     $htmlFilenamsArray = @();

 

Knowing nothing about PowerShell coding, could one not define here the drives to be included in the search? Or, does this mean something entirely different than that?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...