updated Get-UserProfiles func
This commit is contained in:
@@ -120,7 +120,7 @@ If ( Test-Path $ADSKInst ) {
|
|||||||
# TODO: Evaluate system restore points and delete them if they take up too much space
|
# TODO: Evaluate system restore points and delete them if they take up too much space
|
||||||
|
|
||||||
# Remove files from user profile directories
|
# Remove files from user profile directories
|
||||||
ForEach ( $userProfile in $(EnumUserProfiles) ) {
|
ForEach ( $userProfile in $(Get-UserProfiles) ) {
|
||||||
|
|
||||||
# Remove all user temp files older than 7 days
|
# Remove all user temp files older than 7 days
|
||||||
$OldTempFiles = Get-ChildItem -Path "${userProfile}\AppData\Local\Temp" -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -lt ((Get-Date) - $TimeDelta) }
|
$OldTempFiles = Get-ChildItem -Path "${userProfile}\AppData\Local\Temp" -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -lt ((Get-Date) - $TimeDelta) }
|
||||||
|
|||||||
@@ -764,7 +764,7 @@ Function WriteToFile_UTF8NoBOM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Function to enumerate all user profile folders
|
# Function to enumerate all user profile folders
|
||||||
Function EnumUserProfiles {
|
Function Get-UserProfiles {
|
||||||
$ProfilePath = (Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList' -Name ProfilesDirectory)
|
$ProfilePath = (Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList' -Name ProfilesDirectory)
|
||||||
$UserProfilePaths = @()
|
$UserProfilePaths = @()
|
||||||
ForEach ( $userProfile in (Get-ChildItem -Path $ProfilePath | Where-Object { $_.PSIsContainer }) ) {
|
ForEach ( $userProfile in (Get-ChildItem -Path $ProfilePath | Where-Object { $_.PSIsContainer }) ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user