(To Support and anyone else)
This tool would be for turning on Storage Sense and forcing onedrive to keep files in the cloud after 30days
Here is the power shell script tool that uses Set-ItemProperty (we know the command works) when manually run in powershell direct on the device - its just 8 different keys being created keys (without var)
when running via Toolbox - One gets added others are missed, yet i can copy and paste the all commands manually to onto the computer in powershell - it work fine.
At the moment we just grabbed a Reg fragment to do the same thing, but would like powershell as its cleaner
as you can see we tried adding the full key halfway down, nothing gets added, (rebooted computer, nothing in the key,
anyone shed some light please?
***********************************************************
* Enable Windows 10/11 Storage Sense *
* 1 Delete temporary files that my apps aren’t using *
* 2 Delete files in recycle bin *
* 3 Delete files in Downloads folder *
***********************************************************
Enable Storage Sense
Ensure the StorageSense key exists
$key = “HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense”
If (!(Test-Path “$key”)) {
New-Item -Path “$key” | Out-Null
}
If (!(Test-Path “$key\Parameters”)) {
New-Item -Path “$key\Parameters” | Out-Null
}
If (!(Test-Path “$key\Parameters\StoragePolicy”)) {
New-Item -Path “$key\Parameters\StoragePolicy” | Out-Null
}
Set Storage Sense settings
Enable Storage Sense
Set-ItemProperty -Path “$key\Parameters\StoragePolicy” -Name “01” -Type DWord -Value 1
Set ‘Run Storage Sense’ to Every Week
Set-ItemProperty -Path “$key\Parameters\StoragePolicy” -Name “2048” -Type DWord -Value 30
Enable ‘Delete temporary files that apps aren’t using’
Set-ItemProperty -Path “$key\Parameters\StoragePolicy” -Name “04” -Type DWord -Value 1
Set ‘Delete files in recycle bin if they have been there for over’ to 14 days
Set-ItemProperty -Path “$key\Parameters\StoragePolicy” -Name “08” -Type DWord -Value 1
Set-ItemProperty -Path “$key\Parameters\StoragePolicy” -Name “256” -Type DWord -Value 14
Set ‘Delete files in my Downloads folder if they have been there for over’ to 60 days
Set-ItemProperty -Path “$key\Parameters\StoragePolicy” -Name “32” -Type DWord -Value 1
Set-ItemProperty -Path “HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy” -Name “512” -Type DWord -Value 60
Set value that Storage Sense has already notified the user
Set-ItemProperty -Path “$key\Parameters\StoragePolicy” -Name “StoragePoliciesNotified” -Type DWord -Value 1