diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index fbda00e9..54a60b9c 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -13570,8 +13570,15 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF") # Run the task Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_.CreationTime -lt (Get-Date).AddDays(-1)} | Remove-Item -Recurse -Force -# This the only way to get "C:\$WinREAgent" path because we need to open brackets for $env:SystemDrive but not for $WinREAgent -Remove-Item -Path (-join ("`$env:SystemDrive\", '$WinREAgent')) -Recurse -Force +# Unnecessary folders to remove +`$Paths = @( + # Get "C:\$WinREAgent" path because we need to open brackets for $env:SystemDrive but not for $WinREAgent + (-join ("`$env:SystemDrive\", '`$WinREAgent')), + (Get-Item -Path `$env:SystemDrive\Recovery -Force | Where-Object -FilterScript {`$_.Attributes -match "Hidden"}).FullName, + "`$env:SystemDrive\Intel", + "`$env:SystemDrive\PerfLogs" +) +Remove-Item -Path `$Paths -Recurse -Force [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 index 127df173..a4de95b4 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 @@ -10164,8 +10164,15 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF") # Run the task Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_.CreationTime -lt (Get-Date).AddDays(-1)} | Remove-Item -Recurse -Force -# This the only way to get "C:\$WinREAgent" path because we need to open brackets for $env:SystemDrive but not for $WinREAgent -Remove-Item -Path (-join ("`$env:SystemDrive\", '$WinREAgent')) -Recurse -Force +# Unnecessary folders to remove +`$Paths = @( + # Get "C:\$WinREAgent" path because we need to open brackets for $env:SystemDrive but not for $WinREAgent + (-join ("`$env:SystemDrive\", '`$WinREAgent')), + (Get-Item -Path `$env:SystemDrive\Recovery -Force | Where-Object -FilterScript {`$_.Attributes -match "Hidden"}).FullName, + "`$env:SystemDrive\Intel", + "`$env:SystemDrive\PerfLogs" +) +Remove-Item -Path `$Paths -Recurse -Force [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 index 93ca2c77..b0a43834 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 @@ -11280,8 +11280,15 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF") # Run the task Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_.CreationTime -lt (Get-Date).AddDays(-1)} | Remove-Item -Recurse -Force -# This the only way to get "C:\$WinREAgent" path because we need to open brackets for $env:SystemDrive but not for $WinREAgent -Remove-Item -Path (-join ("`$env:SystemDrive\", '$WinREAgent')) -Recurse -Force +# Unnecessary folders to remove +`$Paths = @( + # Get "C:\$WinREAgent" path because we need to open brackets for $env:SystemDrive but not for $WinREAgent + (-join ("`$env:SystemDrive\", '`$WinREAgent')), + (Get-Item -Path `$env:SystemDrive\Recovery -Force | Where-Object -FilterScript {`$_.Attributes -match "Hidden"}).FullName, + "`$env:SystemDrive\Intel", + "`$env:SystemDrive\PerfLogs" +) +Remove-Item -Path `$Paths -Recurse -Force [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 index 33aaef2e..290bae40 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 @@ -13594,8 +13594,15 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF") # Run the task Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_.CreationTime -lt (Get-Date).AddDays(-1)} | Remove-Item -Recurse -Force -# This the only way to get "C:\$WinREAgent" path because we need to open brackets for $env:SystemDrive but not for $WinREAgent -Remove-Item -Path (-join ("`$env:SystemDrive\", '$WinREAgent')) -Recurse -Force +# Unnecessary folders to remove +`$Paths = @( + # Get "C:\$WinREAgent" path because we need to open brackets for $env:SystemDrive but not for $WinREAgent + (-join ("`$env:SystemDrive\", '`$WinREAgent')), + (Get-Item -Path `$env:SystemDrive\Recovery -Force | Where-Object -FilterScript {`$_.Attributes -match "Hidden"}).FullName, + "`$env:SystemDrive\Intel", + "`$env:SystemDrive\PerfLogs" +) +Remove-Item -Path `$Paths -Recurse -Force [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 index 3161e349..8de75bc1 100644 --- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 @@ -13012,8 +13012,15 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF") # Run the task Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_.CreationTime -lt (Get-Date).AddDays(-1)} | Remove-Item -Recurse -Force -# Get "C:\$WinREAgent" path because we need to open brackets for $env:SystemDrive but not for $WinREAgent -Remove-Item -Path (-join ("`$env:SystemDrive\", '$WinREAgent')) -Recurse -Force +# Unnecessary folders to remove +`$Paths = @( + # Get "C:\$WinREAgent" path because we need to open brackets for $env:SystemDrive but not for $WinREAgent + (-join ("`$env:SystemDrive\", '`$WinREAgent')), + (Get-Item -Path `$env:SystemDrive\Recovery -Force | Where-Object -FilterScript {`$_.Attributes -match "Hidden"}).FullName, + "`$env:SystemDrive\Intel", + "`$env:SystemDrive\PerfLogs" +) +Remove-Item -Path `$Paths -Recurse -Force [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 index 7cc59d3b..72bc0b6e 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 @@ -13033,8 +13033,15 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF") # Run the task Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_.CreationTime -lt (Get-Date).AddDays(-1)} | Remove-Item -Recurse -Force -# Get "C:\$WinREAgent" path because we need to open brackets for $env:SystemDrive but not for $WinREAgent -Remove-Item -Path (-join ("`$env:SystemDrive\", '$WinREAgent')) -Recurse -Force +# Unnecessary folders to remove +`$Paths = @( + # Get "C:\$WinREAgent" path because we need to open brackets for $env:SystemDrive but not for $WinREAgent + (-join ("`$env:SystemDrive\", '`$WinREAgent')), + (Get-Item -Path `$env:SystemDrive\Recovery -Force | Where-Object -FilterScript {`$_.Attributes -match "Hidden"}).FullName, + "`$env:SystemDrive\Intel", + "`$env:SystemDrive\PerfLogs" +) +Remove-Item -Path `$Paths -Recurse -Force [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null