Archive for the ‘scripting’ Category

get-eventlog does not display time on out-file

Tuesday, November 26th, 2019

Powershell is fun and yet there are times it can be annoying.

I am doing a refresh as I am looking for a new job. My last one was not script minded.

A simply test was to get use get-eventlog sort by index and time. It did this. Next was to output index, time and source.

get-eventlog -logname Security -newest 50 |select-object -property index,time,source | sort time,index | out-file c:\last.txt

The other two worked. Time did not.

You would think it would be obvious to simply use “time” and well; it isn’t.

You need to use timegenerated or timewritten.

get-eventlog -logname Application -newest 50 |select-object -property index,timegenerated,source | sort index,time

More reading to do.

The return of python

Thursday, September 19th, 2019

I decided to take up python again. Wasn’t a heavy user as I was a bit of a Perl snob. The current job really doesn’t offer serious time for good scripting so I was a little lax on that front.

I have a refresher book “Visual Quickstart Guide for Python” and for simple minded fun “Mission Python: Code a space adventure Game”

The mission book wants pygame. I quickly found I needed to install pip as well. Commands not recognized.

I should mention; I am using Windows 10 on a laptop and have installed Visual Studio community edition with the Python add on. I still upgraded Python to the latest release.

If you are using Windows; you can make your python experience a little easier with two PATH additions for python and the scripts folder in python. In my case

  • “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\”
  • “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\ Scripts\”

After that; you can get a nice little script which will run the pip install. Start an admin level CMD window and enter: python <location of script>\get-pip.py

Once it’s installed; you can install pygame simply by entering: pip install pygame

It’s a quick install. Just verify there are no error messages.