/build/static/layout/Breadcrumb_cap_w.png

Take Action After 60 Days

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

Answers (1)

Posted by: Ziggi 5 years ago
Blue Belt
1

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)"
    }
}


Comments:
  • 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. - momalle1 5 years ago
    • Hopefully it's something like this :) RegistryValueReturn(HKLM\SOFTWARE\WOW6432Node\MyCompany\Software\InPlaceUpgrade, datestamp, DATE) - Ziggi 5 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ