jblackburn
Member
- Messages
- 15
- Reaction score
- 1
- Points
- 3
I have a powershell script I'm trying to run as a program or a script through the new script section. The script won't work correctly and I'm not sure why. It executes and shows up in the task manager and then just sits there for 120 minutes until it kills itself
The script is below. The first part of the script works because the registry values are present however cleanmgr doesn't execute. execmgr doesn't show an error as its technically running ok
The script itself works if I manually go to the machine and execute the script as an admin. It just won't work through the sccm client process.
Any ideas of possible alternatives? I'm trying to get rid of the Windows.old folder after a Win 10 inplace install
#create registry value
$regpath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations"
New-ItemProperty -Path $regpath -Name "StateFlags1221" -PropertyType DWORD -Value 2 -Force | Out-Null
$regpath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\update Cleanup"
New-ItemProperty -Path $regpath -Name "StateFlags1221" -PropertyType DWORD -Value 2 -Force | Out-Null
$regpath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files"
New-ItemProperty -Path $regpath -Name "StateFlags1221" -PropertyType DWORD -Value 2 -Force | Out-Null
#start clean application
cleanmgr.exe /SAGERUN:1221
The script itself works if I manually go to the machine and execute the script as an admin. It just won't work through the sccm client process.
Any ideas of possible alternatives? I'm trying to get rid of the Windows.old folder after a Win 10 inplace install
#create registry value
$regpath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations"
New-ItemProperty -Path $regpath -Name "StateFlags1221" -PropertyType DWORD -Value 2 -Force | Out-Null
$regpath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\update Cleanup"
New-ItemProperty -Path $regpath -Name "StateFlags1221" -PropertyType DWORD -Value 2 -Force | Out-Null
$regpath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files"
New-ItemProperty -Path $regpath -Name "StateFlags1221" -PropertyType DWORD -Value 2 -Force | Out-Null
#start clean application
cleanmgr.exe /SAGERUN:1221
