[sourcecode language="powershell"] $files = get-childitem $args -recurse -include *.dll,*.exe if($files -eq $null) { Write-Host "No Exe or dll files present in the folder"; } else { foreach ($i in $files) { $ver = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($i).FileVersion if($ver -eq $null) { $i.FullName | Out-File NoVersion.txt -append } else { "{0}`t{1}"-f $i.FullName, [System.Diagnostics.FileVersionInfo]::GetVersionInfo($i).FileVersion | out-file Version.xls -append } } … Continue reading PowerShell: Get File Version Info
Category: Scripts
PowerShell: Clear Event logs from Windows machine
Problem Statement: Need to clear off Application, Security and System Event logs of your Windows PC? Well here's the solution. [sourcecode language="powershell"] foreach($computer in $args) { $ALive=get-wmiobject win32_pingstatus -Filter "Address='$computer'" | Select-Object statuscode if($ALive.statuscode -eq 0) { $logs = [System.Diagnostics.Eventlog]::GetEventLogs("$computer") $Applogs = $logs|where-object {$_.logdisplayname -eq "Application"} $Applogs.clear() $Securitylogs = $logs|where-object {$_.logdisplayname -eq "Security"} $Securitylogs.Clear() $Systemlogs … Continue reading PowerShell: Clear Event logs from Windows machine
Python: Working with Dynamic Link Library (dll)
Problem Statement: What if you get a DLL file and you want to quickly test some of the exported APIs? Any ideas? Solution: Python provides you one. Code snippet: [sourcecode language="python"] from ctypes import * libc = windll.LoadLibrary('C:\\Windows\\kernel32.dll'') x = libc.GetModuleHandleA () print x #Prints the object del libc #Deletes the handle [/sourcecode] In this … Continue reading Python: Working with Dynamic Link Library (dll)
Python: Profiler for scripts and libraries
Problem Statement: Profiling your python script. A profiler is a program that monitors performance of a program during run time and provides a lot of information on the program. Yes a module in Python that can do it easily for you! Solution - Case Study: [sourcecode language="python"] import wmi import os import time import string __DELAY = … Continue reading Python: Profiler for scripts and libraries
Python: Knowing the path of the currently running script
Problem Statement: When we deal with frameworks, how often do we have to import modules. And it doesn't stop there; there arises a need where the imported would in turn import an another module, right? Would debugging an error condition be easy in these cases. If you have dealt with frameworks before, you would definitely … Continue reading Python: Knowing the path of the currently running script