/build/static/layout/Breadcrumb_cap_w.png

Smart Label OS Install Date

I have been trying to get a smart label working based on the OS_INSTALL_DATE field in the db. I followed the following Blog post: http://www.itninja.com/blog/view/smart-label-based-on-os-installation-date, but am not getting it to work.

Looking at the db, I notice that the field type isn't a timestamp, but just a varchar. Is this what could be causing the issue? Or does anyone else know of a way to get this working?

Thanks!

3 Comments   [ + ] Show comments
  • What is it you are trying to do? Find machines older than a certain time? Just get the data itself for reporting? - nshah 8 years ago
  • My main goal is to apply a smart label to freshly imaged machines automatically so begin installing software, etc.

    We had it setup as the created date in KACE, but if we forget to delete the agent from KACE before reimaging the computer, it won't be picked up by the smart label.

    Going by OS install date, this will fix that issue. - crrussell3 8 years ago
  • Restarting the K1000 and following the above blog post worked. Something wierd was going on with it that self resolved. When in doubt, restart. - crrussell3 8 years ago

Answers (1)

Posted by: rockhead44 8 years ago
Red Belt
0

I have done the following to get the OS Date installed:


Created a powershell script to get the OS date and time installed and output a text file to C:\ProgramData\Dell\KACE\user

My file reads as:

=====================================

function Ps64([scriptblock]$block) {  
      
    $machineName = [Environment]::MachineName;  
  
    try {  
        # Note: The configuration name is what forces it to 64 bit.  
        $session = New-PSSession -ComputerName $machineName -ConfigurationName Microsoft.PowerShell  
    } catch {  
        # Try to enable Remote Management on this machine.  
        winrm quickconfig -q -f  
          
        # Try again.  
        $session = New-PSSession -ComputerName $machineName -ConfigurationName Microsoft.PowerShell  
    }  
  
    # Now invoke our code in 64 bit PowerShell.  
    try {  
        Invoke-Command -Session $session -ScriptBlock $block -ArgumentList $args  
    } finally {  
        Remove-PSSession $session  
    }  
}  
([WMI]'').ConvertToDateTime((Get-WmiObject Win32_OperatingSystem).InstallDate)|out-file C:\ProgramData\Dell\KACE\user\OSinstalldateandtime.txt

================================================================

From there I deploy the .ps1 file, along with a batch file. I zipped the 2 together and and created an offline kscript, with the zip file uploaded. From there I target my machines and call the .bat file which reads

@ECHO OFF
SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPath=%ThisScriptsDirectory%MyPowerShellScript.ps1
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\255\OSDT.ps1""' -Verb RunAs}";

That executes the powershell file and outputs the text file to the location I specified above. In my case, I had to include the full path to the package to get it to execute properly. 

Next, I created a  new Software inventory record as a CIR using the following syntax:

ShellCommandTextReturn(cmd.exe /c type C:\ProgramData\Dell\KACE\user\OSinstalldateandtime.txt)

Finally, I created a report which returns machines that have that software inventory record.

There may be an easier way but this is what worked for me after much research and trial-and-error.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
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