This message was deleted.
# _general
s
This message was deleted.
o
Yes but the dev doesn't support Windows 10/11, the support for modern packages / UWP has not been implemented.
n
I saw that note, but I'm debating whether or not that matters here. I remove all UWP apps in my image, and testing seems to be fine. Basically trying to automate removing the domain account I use for a few steps in my image build, and this was the first tool that came to mind.
This is on W10 20H2.
Also not sure if using Get-CimInstance/Remove-CimInstance is the same, either.
n
I use Get-CimInstance/Remove and not had any problems removing the profiles. Never check if it does the same thing as “manually”, as never had a problem yet
n
I think I'm going to give it a shot. Just don't want remains of my profile baked into the image, therefore hosing my logons.
k
You can always ping Helge on Twitter, he’s super responsive (and overall a nice guy)
💯 3
j
The "profile removal" process deletes the C:\Users\Username folder, and additionally removes a load of crap from HKLM like below HKLM\Software\Microsoft\Windows\CurrentVersion\GroupPolicy\State\SID HKLM\Software\Microsoft\Windows\CurrentVersion\GroupPolicy\SID HKLM\Software\Microsoft\Windows\CurrentVersion\GroupPolicy\Status\SID HKLM\Software\Microsoft\Windows Search\Gather\Windows\SystemIndex\Sites\SID HKLM\Software\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\SID HKLM\Software\Microsoft\Windows\CurrentVersion\Appx\PackageState\SID
k
n
I'm going to run with testing Remove-CimInstance first, since it's strictly PS which makes it easier for my process, but options are always good. Appreciate it!
n
Here is my script. The ignoreList should be tailored to suit
👍 1
n
Yeah, I don't even need to get that fancy:
Copy code
Get-CimInstance -Class Win32_UserProfile | Where { $_.LocalPath.split('\')[-1] -like '*Panaccio*' } | Remove-CimInstance | Out-Null
👍 1
o
I user a similar script in my gold image and works fine. Actually DelProf at shutdown wouldn't work reliably, I have found, so I use a PS script too.
n
I can't believe I've waited this long to address this.
o
better to have a clean image with no local profiles
but that's not a high priority 🙂
n
That's why I'm revisiting this... managed to forget to remove my own account more than once, haha.
(during image build)
c
BIS-F will remove any local profiles on the master image as part of the sealing process
f
Our sealing script enable Delprof as a scheduled task at startup. Sealing script > Enable scheduled task > Reboot. Delprof > disable scheduled task > Shutdown.
s
I run this on restart to cleanup profiles on persistent VDAs where I had some issues with profiles not being cleaned up properly.
Copy code
# 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
👍 1