added Get-UserProfiles func from Tools.ps1

This commit is contained in:
2025-01-06 12:35:23 -05:00
parent 288a1a4d9c
commit 8ace7c6be1
+10
View File
@@ -1,5 +1,15 @@
#. $([Scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Tools.ps1')))
# Function to enumerate all user profile folders
Function Get-UserProfiles {
$ProfilePath = (Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList' -Name ProfilesDirectory)
$UserProfilePaths = @()
ForEach ( $userProfile in (Get-ChildItem -Path $ProfilePath | Where-Object { $_.PSIsContainer }) ) {
$UserProfilePaths += ,@($userProfile.FullName)
}
Return $UserProfilePaths
}
# When deleting temp files en masse, only delete files/folders older than the number of days specified here
$OlderThan = 7
$TimeDelta = New-TimeSpan -Days $OlderThan