ОБ
Size: a a a
ОБ
ОБ
SK
Q
ОБ
SK
ОБ
Q
КЭ
A
SK
Get-WindowsDriver -Online | Group-Object -Property { Split-Path -Leaf $_.OriginalFileName } | Where-Object { $_.Count -ge 2 } |
ForEach-Object { $_.Group | Sort-Object -Property Date -Descending | Select-Object -Skip 1 } |
ForEach-Object { Write-Verbose "removing $($_.Driver):"; . pnputil.exe -d $_.Driver | Write-Verbose }
Q
SK
Get-WindowsDriver -Online | Group-Object -Property { Split-Path -Leaf $_.OriginalFileName } | Where-Object { $_.Count -ge 2 } |
ForEach-Object { $_.Group | Sort-Object -Property Date -Descending | Select-Object -Skip 1 } |
ForEach-Object { Write-Verbose "removing $($_.Driver):"; . pnputil.exe -d $_.Driver | Write-Verbose }
Q
Q
SK
ОБ
SK
# cleanmgr.exe /sageset:3
if (Get-Command cleanmgr.exe -ErrorAction SilentlyContinue) {
"$(Get-CurrentDiskSpace) - Start Disk Space Cleanup Manager"
$StateIndex = 3
$StateFlag = "StateFlags{0:d4}" -f $StateIndex
$Exclude = @(
"Content Indexer Cleaner",
#"Delivery Optimization Files",
#"Device Driver Packages",
"GameNewsFiles",
"GameStatisticsFiles",
"GameUpdateFiles",
"Recycle Bin",
"Temporary Sync Files",
"User file versions"
)
# Filter excluded components
$Components = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches" |
Where-Object { $Exclude -NotContains $_.PSChildName }
if ($Components) {
New-ItemProperty -Path ($Components | Select-Object -ExpandProperty PSPath) -Name $StateFlag -Value 2 -PropertyType DWORD -Force -ErrorAction Stop | Out-Null
#cleanmgr.exe /sagerun:3
$Proc = Start-Process cleanmgr.exe -ArgumentList "/sagerun:$($StateIndex)" -Wait -PassThru -WindowStyle Hidden
#"$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") - Cleanmgr exit code = $($Proc.ExitCode)"
Remove-ItemProperty -Path ($Components | Select-Object -ExpandProperty PSPath) -Name $StateFlag -Force -ErrorAction Continue
"$(Get-CurrentDiskSpace) - End Disk Space Cleanup Manager"
}
else {
"No Components found"
}
}
SK
Q
# cleanmgr.exe /sageset:3
if (Get-Command cleanmgr.exe -ErrorAction SilentlyContinue) {
"$(Get-CurrentDiskSpace) - Start Disk Space Cleanup Manager"
$StateIndex = 3
$StateFlag = "StateFlags{0:d4}" -f $StateIndex
$Exclude = @(
"Content Indexer Cleaner",
#"Delivery Optimization Files",
#"Device Driver Packages",
"GameNewsFiles",
"GameStatisticsFiles",
"GameUpdateFiles",
"Recycle Bin",
"Temporary Sync Files",
"User file versions"
)
# Filter excluded components
$Components = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches" |
Where-Object { $Exclude -NotContains $_.PSChildName }
if ($Components) {
New-ItemProperty -Path ($Components | Select-Object -ExpandProperty PSPath) -Name $StateFlag -Value 2 -PropertyType DWORD -Force -ErrorAction Stop | Out-Null
#cleanmgr.exe /sagerun:3
$Proc = Start-Process cleanmgr.exe -ArgumentList "/sagerun:$($StateIndex)" -Wait -PassThru -WindowStyle Hidden
#"$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") - Cleanmgr exit code = $($Proc.ExitCode)"
Remove-ItemProperty -Path ($Components | Select-Object -ExpandProperty PSPath) -Name $StateFlag -Force -ErrorAction Continue
"$(Get-CurrentDiskSpace) - End Disk Space Cleanup Manager"
}
else {
"No Components found"
}
}