/build/static/layout/Breadcrumb_cap_w.png
02/25/2019 252 views

I am deploying Windows 10 In-Place Upgrades using MDT. During that process, I place a time stamp in the registry so I know when the upgrade is completed. The timestamp is placed by a batch file, "reg add HKLM\SOFTWARE\WOW6432Node\MyCompany\Software\InPlaceUpgrade /v datestamp /d "%DATE%" /t REG_EXPAND_SZ /f" and the format is "Fri 02/22/2019". I currently have a script that I can push or users can pull that will check for the Windows.old folder and remove it, what I'd like to do is eliminate the manual part, by myself or my users and have KACE inventory the timestamp, and after 60 days, run my script. Is this even possible or am I expecting too much from KACE. I have found a few Powershell scripts that retrieve the last time stamp for a registry key, and that date would work as well, I just don't know how what to do with the retrieved date.

0 Comments   [ + ] Show comments

Comments


All Answers

This content is currently hidden from public view.
Reason: Removed by member request For more information, visit our FAQ's.
0

Edit, My answers seem to be deleting lately.

You can create a custom inventory rule to gather the timestamp,  you then create a device smart label and associate with if the created date is more than 60 days then machines will drop into that label.

You then create a script to run whenever and just drop the devices in there. They will drop out the label once that folder has been deleted.

EDIT::

You can also just use a PowerShell script to delete the folders after certain amount of time.


# Defines the '60 days old' (today's date minus 60)
$age = (Get-Date).AddDays(-60)

# Get all the files in the folder and subfolders | foreach file
Get-ChildItem C:\Windows.old -Recurse -File | foreach{
    # if creationtime is 'le' (less or equal) than 60 days
    if ($_.CreationTime -le $age){
        Write-Output "Older than 60 days - $($_.name)"
        # remove the item
        Remove-Item $_.fullname -Force -Verbose
    }else{
        Write-Output "Less than 60 days old - $($_.name)"
    }
}

Answered 02/27/2019 by: Ziggi
Blue Belt

  • I like the original idea (I already have a script that will remove the OLD folder) just need to figure out how to collect the dates in a CIR. Thank you.
    • Hopefully it's something like this :) RegistryValueReturn(HKLM\SOFTWARE\WOW6432Node\MyCompany\Software\InPlaceUpgrade, datestamp, DATE)