Solved

User profile Size Report

Posted on 2016-11-18
3
90 Views
Last Modified: 2016-11-21
Does anyone know of a script that will do the following. User can run the script themselves but we need to report back their profile sizes or anywhere there are documents stored on the machine, for example some users could have documents stores elsewhere or My Documents mapped differently.

Anyway, what i am looking for is a script that the users can run by clicking, this will then scan their machine and create a CSV in their logon name showing the directory of their profile and size back to a remote location.

Thanks in Advance

John
0
Comment
Question by:John Davies
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 24

Expert Comment

by:NVIT
ID: 41893889
> ...some users could have documents stores elsewhere

Does this mean the script must check the user's entire c: drive? Also at possibly random locations?
0
 
LVL 25

Accepted Solution

by:
Coralon earned 500 total points
ID: 41893901
Do you have a list of what you are looking for (specifically file extensions, and what details you want in your CSV file?)
Obviously, your remote location will need to let the users have access..  but, something like this would work for you.. )

Your base reporting script would be something like this: maybe something like c:\Reports\New-ProfileReport.ps1
$TxtSize = 0
$XlsSize = 0
$PPTSize = 0
$DocSize = 0
$XlsxSize = 0
$PPTxSize = 0
$DocxSize = 0

$Files = get-childitem -path $env:userprofile -recurse -include *.txt,*.xls,*.ppt,*.doc,*.docx*.xlsx,*.pptx
$files | where-object { $_.name -like '*.txt' } | foreach-object { $TxtSize += $_.length }
$files | where-object { $_.name -like '*.xls' } | foreach-object { $XlsSize += $_.length }
$files | where-object { $_.name -like '*.ppt' } | foreach-object { $PPTSize += $_.length }
$files | where-object { $_.name -like '*.doc' } | foreach-object { $DocSize += $_.length }
$files | where-object { $_.name -like '*.xlsx } | foreach-object { $XlsxSize += $_.length }
$files | where-object { $_.name -like '*.pptx' } | foreach-object { $PPTxSize += $_.length }
$files | where-object { $_.name -like '*.docx' } | foreach-object { $DocxSize += $_.length }
$Output = "Size of Text Files: $($TxtSize/1KB) kb"
$Output += "Size of Xls Files: $($XlsSize/1KB) kb"
$Output += "Size of PPT Files: $($PPTSize/1KB) kb"
$Output += "Size of Doc Files: $($DocSize/1KB) kb"
$Output += "Size of Xlsx Files: $($XlsxSize/1KB) kb"
$Output += "Size of PPTx Files: $($PPTxSize/1KB) kb"
$Output += "Size of Docx Files: $($DocxSize/1KB) kb"
$Output += "TotalSize: $($TxtSize + $XlsSize + $PPTSize + $DocSize + $XlsxSize + $PPTxSize + $DocxSize)"
$Output += "`r`n`r`n"
$Output += ($files | select-object -property Name,FullName,CreationTime,LastWriteTime,Length | convertto-csv -notypeinformation)
$Output | out-file -encoding ascii -filepath "\\server\share\$([datetime]::now.tostring('yyyy-MM-dd'))_$env:username`_ProfileDirectoryFiles.csv" 

Open in new window


Then you will put together a small script to run it.. even just a batch file.. something like this: c:\Reports\RunMyProfileReport.cmd
@echo off
powershell.exe -noprofile -noninteractive -file c:\Reports\New-ProfileReport.ps1

Open in new window


You give the users a shortcut to the batch file (possibly changing directories as need be)

Coralon
0
 

Author Closing Comment

by:John Davies
ID: 41895877
Thanks for that, perfect!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question