Slackbot
03/10/2022, 12:07 PMOsiris Amanpour
03/10/2022, 12:17 PMNick Panaccio
03/10/2022, 12:19 PMNick Panaccio
03/10/2022, 12:19 PMNick Panaccio
03/10/2022, 12:22 PMNathan Sperry
03/10/2022, 12:25 PMNick Panaccio
03/10/2022, 12:26 PMKees Baggerman
03/10/2022, 12:32 PMJames Rankin
03/10/2022, 12:32 PMKees Baggerman
03/10/2022, 12:32 PMNick Panaccio
03/10/2022, 12:37 PMNathan Sperry
03/10/2022, 12:39 PMNick Panaccio
03/10/2022, 12:42 PMGet-CimInstance -Class Win32_UserProfile | Where { $_.LocalPath.split('\')[-1] -like '*Panaccio*' } | Remove-CimInstance | Out-NullOsiris Amanpour
03/10/2022, 12:46 PMNick Panaccio
03/10/2022, 12:48 PMOsiris Amanpour
03/10/2022, 12:49 PMOsiris Amanpour
03/10/2022, 12:50 PMNick Panaccio
03/10/2022, 12:50 PMNick Panaccio
03/10/2022, 12:50 PMc4rm0
03/10/2022, 3:59 PMFrançois-Xavier Rigaud
03/10/2022, 6:28 PMScott Knights
03/11/2022, 12:32 AM# Cleanup profiles. Run at server startup
# Will clean any .BAK registry keys from the profile list, remove profiles then cleanup any leftover junk in c:\Users
# Remove any .BAK keys from the ProfileList registry key
$profkey="HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
$keys=get-childitem -path $profkey|where{$_.name -like "*.BAK"}
$keys|remove-item -force
# Get the domain primary SID
# Use this method to get the domain SID if the AD Posh module is available
#$domainsid=((get-addomain).domainsid).value
# Use this method to get the domain SID if the AD Posh module is not available
$domain = Get-WmiObject Win32_ComputerSystem | Select -Expand Domain
$krbtgtSID = (New-Object Security.Principal.NTAccount $domain\krbtgt).Translate([Security.Principal.SecurityIdentifier]).Value
$domainsid = $krbtgtSID.SubString(0, $krbtgtSID.LastIndexOf('-'))
# Get user profiles (only get domain users)
$profiles=Get-CimInstance -ClassName Win32_UserProfile -ComputerName localhost|where{$_.SID -like "$domainsid*"}
# Attempt to remove profiles
$profiles | Remove-CimInstance
# Delete any folders left in C:\Users that shouldn't be there
$folders=get-childitem C:\Users -directory -force|where{$_.Name -notlike "All Users" -and $_.Name -notlike "Default*" -and $_.Name -notlike "Public"}
$folders|remove-item -recurse -force