Here is an example PowerShell script that will retrieve a list of users on a remote Windows computer, including the size and last modified date of each user’s folder:
$computer = "RemoteComputerName"
$users = Get-WmiObject -ComputerName $computer -Class Win32_UserAccount | Where-Object {$_.LocalAccount -eq $true} | Select-Object Name
foreach ($user in $users) {
$username = $user.Name
$folder = "C:\Users\" + $username
if (Test-Path $folder) {
$folderinfo = Get-WmiObject -ComputerName $computer -Class Win32_Directory -Filter "Name='$folder'"
$foldersize = "{0:N2}" -f ($folderinfo.Size/1GB) + " GB"
$lastmodified = $folderinfo.LastModified
Write-Host "Username: $username, Folder size: $foldersize, Last modified: $lastmodified"
} else {
Write-Host "The folder for user $username does not exist on $computer"
}
}
Make sure to replace “RemoteComputerName” with the appropriate value.
You also need to have the appropriate permissions to access the remote computer and the folders you want to check.
This script uses the Win32_UserAccount class to get a list of local users on the remote computer, and then iterates through each user to get the size and last modified date of the user’s folder (if it exists). The script will then output the username, folder size, and last modified date for each user.