Monday, December 18, 2017

Getting last modified software on Windows using Powershell

I like getting weird requests and resolving them with one line of code in Powershell. Powershell is indeed a very polished tool for working in the terminal in Windows.

This week I was asked by a friend this question: "hey, how can I get the lastly installed software on my machine"?

Get-WmiObject

# getting windows diag information - expot all installed software on my machine
Get-WmiObject -Class Win32_Product | Export-Csv installed.csv


And how do I look for what was modified most recently in our machine?

Get-ChildItem

# getting last modified files
Get-ChildItem C:\ -rec | sort LastWriteTime | select -last 1000 | Export-Csv files.csv


Fun! I do not miss the old DOS command prompt.

References

https://stackoverflow.com/questions/24028104/powershell-find-latest-modified-file-information
https://stackoverflow.com/questions/13345066/windows-how-to-list-files-recursively-with-size-and-last-access-date