WizardKit/.bin/Scripts/user_data.ps1
Alan Mason b180b42ec9 2016-10: Retroactive Updates
# Migration to Python started #
  * PoSH has an extreme slowdown for some systems while it runs an optimization
  ** pass for .NET on the first PoSH script execution.
  ** This is reason enough to move to an alternative.

* New additions:
  * User Data Transfer script
    * Will extract from a WIM or copy from a folder
    * Uses wimlib-imagex for images and FastCopy for folders
    * Removes undesired items after transfer/extraction
  * HWiNFO
  * Missing ODD repair registry patch
  * Q-Dir
  * SW Bundle install script

* ConEmu
  * Moving back to ConEmu for better performance.

* Copy-WizardKit
  * Now uses FastCopy

* functions.py
  * Ported init.ps1 to Python using functions.py (from WinPE) as a base

* Launch.cmd
  * Elevating programs/scripts now done using a temp VBScript file
  * Can run Python scripts (using either the 32 or 64 bit runtime)

* transferred_keys.cmd
  * Expanded searched paths

* Misc
  * Lots of variables and files renamed
  * Lots of hard-coded paths are now in variables
    * Should only be set in scripts in %bin%\Scripts
  * Moved a subset of the Diagnostics launchers to a new 'Extras' folder
    * The launchers moved are those that are less-often used
  * Refactored FindBin code to be more concise
  * Renamed "KitDir" "ClientDir" to indicate that it is on the client's system
  * Removed GeForce Experience launcher as it now requires an account
  * Added link to NVIDIA's driver webpage to download the correct driver
  * Removed AMD's Gaming Evolved launcher
    * This is usually bundled with the GPU driver anyway
  * Switched back to ConEmu
  * Variable and script names are now more descriptive
    * i.e. checklist -> final_checklist, and HH -> %kit_dir%
    * (not happy with %kit_dir%, will probably change again)
2017-11-17 00:53:08 -07:00

79 lines
No EOL
3.2 KiB
PowerShell

# Wizard Kit: List the data usage for the current user (and other users when possible)
param([string]$log)
cd $(Split-Path $MyInvocation.MyCommand.Path)
. .\init.ps1
#Folder GUIDs from: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457(v=vs.85).aspx
$user_dirs = , ("Desktop", "{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}")
$user_dirs += , ("Documents", "Personal", "{FDD39AD0-238F-46AF-ADB4-6C85480369C7}")
$user_dirs += , ("Downloads", "{374DE290-123F-4565-9164-39C4925E467B}")
$user_dirs += , ("Favorites", "{1777F761-68AD-4D8A-87BD-30B759FA33DD}")
$user_dirs += , ("Music", "My Music", "{4BD8D571-6D19-48D3-BE97-422220080E43}")
$user_dirs += , ("Pictures", "My Pictures", "{33E28130-4E1E-4676-835A-98395C3BC3BB}")
$user_dirs += , ("Videos", "My Video", "{18989B1D-99B5-455B-841C-AB7C74E4DDFC}")
#=SkyDrive=
#=Dropbox=
function print-dir-size ($name, $location) {
#"{0}: {1}" -f $name, $location
$name += ":"
$results = .\Get-FolderSize.ps1 "$location"
[int64]$bytes = $results.TotalBytes
if ($bytes -ge 1073741824) {
$total = "{0:N2}" -f [single]$results.TotalGBytes
$s = " {0} {1} Gb ({2})" -f $name.PadRight(10), $total.PadLeft(10), $location
} elseif ($bytes -ge 1048576) {
$total = "{0:N2}" -f [single]$results.TotalMBytes
$s = " {0} {1} Mb ({2})" -f $name.PadRight(10), $total.PadLeft(10), $location
} elseif ($bytes -ge 1024) {
$total = "{0:N2}" -f [single]($bytes/1024)
$s = " {0} {1} Kb ({2})" -f $name.PadRight(10), $total.PadLeft(10), $location
} else {
$total = "{0:N0}" -f $bytes
$s = " {0} {1} Bytes ({2})" -f $name.PadRight(10), $total.PadLeft(7), $location
}
WK-write "$s" "$log"
}
foreach ($user in get-wmiobject -class win32_useraccount) {
if (test-path registry::hku\$($user.sid)) {
WK-write (" User: {0}" -f $user.name) "$log"
# Profile
$user_profile = gp "registry::hklm\software\microsoft\windows nt\currentversion\profilelist\$($user.sid)"
print-dir-size "Profile" $user_profile.ProfileImagePath
WK-write " ------------------------" "$log"
# Shell Folders
$shell_folders = gp "registry::hku\$($user.sid)\software\microsoft\windows\currentversion\explorer\shell folders"
foreach ($dir in $user_dirs) {
$dir_name = $dir[0]
foreach ($reg_name in $dir) {
$dir_location = $shell_folders.$reg_name
if ($dir_location -and $(test-path "$dir_location")) {
print-dir-size $dir_name $dir_location
break
}
}
}
# Online Backups
foreach ($dir in "Dropbox", "Mozy", "OneDrive", "SkyDrive") {
$spacer = "True"
$dir_name = $dir
$dir_location = "{0}\{1}" -f $user_profile.ProfileImagePath, $dir
if (test-path $dir_location) {
if ($spacer) {
" ------------------------"
rv spacer
}
print-dir-size $dir_name $dir_location
}
}
# Spacer
WK-write "" "$log"
}
}