Solved

User profile Size Report

Posted on 2016-11-18
3
72 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
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 24

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

809 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