Solved How can I remove these items with powershell?
-
@Obsolesce said in How can I remove these items with powershell?:
@JaredBusch I did not use an elevated ISE window:
And it worked for me:
See, I swear this is what I did previously, but it did not work yesterday.
What version of powershell did you have on your test?
The system I just tried it on was a clean new install of Windows 10 21H2. -
@JaredBusch is the machine domain joined?
-
@Dashrender said in How can I remove these items with powershell?:
@JaredBusch is the machine domain joined?
Yes, but why is that relevant? This is a user land action.
-
@JaredBusch said in How can I remove these items with powershell?:
What version of powershell did you have on your test?
The system I just tried it on was a clean new install of Windows 10 21H2.PowerShell:
Name Value ---- ----- PSVersion 5.1.22000.832 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.22000.832 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
Windows:
Edition Windows 11 Enterprise Version 21H2 Installed on 10/19/2022 OS build 22000.856 Experience Windows Feature Experience Pack 1000.22000.856.0
-
@Obsolesce said in How can I remove these items with powershell?:
@JaredBusch said in How can I remove these items with powershell?:
What version of powershell did you have on your test?
The system I just tried it on was a clean new install of Windows 10 21H2.PowerShell:
Name Value ---- ----- PSVersion 5.1.22000.832 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.22000.832 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
Windows:
Edition Windows 11 Enterprise Version 21H2 Installed on 10/19/2022 OS build 22000.856 Experience Windows Feature Experience Pack 1000.22000.856.0
Thanks.
I'll be setting up a new laptop tomorrow and I will test this out more carefully. -
@Obsolesce on default install of Windows 10 21H2, it breaks the, but does not remove it.
Installing Windows 11 now.
-
Windows 11 22H2 clean install (just made a new USB).
So the answer is it works in Windows 11, but not 10 with a simple
Remove-Item
.@Obsolesce any recommendations for a way to do it in Windows 10? I have a good sized fleet of devices that cannot upgrade to 11 that will be used for a couple more years.
-
@JaredBusch I figured it out after creating a WIn10 VM (same issue in Win10 22H2 by the way)
Edition Windows 10 Pro Version 22H2 Installed on 10/22/2022 OS build 19045.2006 Experience Windows Feature Experience Pack 120.2212.4180.0
Get-ChildItem -Path ~\Documents -Hidden | ForEach-Object { (Get-Item -Path $PSItem.FullName -Force).Delete() }
Maybe you can shorten it:
Get-ChildItem -Path ~\Documents -Hidden -Recurse | ForEach-Object { $PSItem.Delete() }
-
-
@Obsolesce said in How can I remove these items with powershell?:
Get-ChildItem -Path ~\Documents -Hidden -Recurse | ForEach-Object { $PSItem.Delete() }
Thanks a ton.
-
As an update the solution for Windows 11 now also works for Windows 10 if you are on Windows 10 22H2 and fully updated.