Tuesday, May 20, 2014

Getting the Event Log from another machine with PowerShell

If you have to manage a server farm of more than one computer, PowerShell can be of use if you have access to it.

If you don't have access to it, you may have to setup PowerShell Remoting (don't ask me how, because I haven't done that myself yet).

PS C:\> Get-EventLog -ComputerName somecomputer -LogName Application -Newest 10

Note that I'm using the -Newest paramter and not using the -After parameter, because apparently this means you will need to wait for PowerShell to go through the entire log, instead of stopping at a certain point.

Using a specific version of PowerShell

If you inspect $PSVersionTable you'll see a few different versions of things being used with PowerShell in the current session, specifically look for $PSVersionTable.PSVersion. By default the most latest version will be used.

To launch a specific version of PowerShell you can pass the -version switch, e.g. for PowerShell v2:

c:\ powershell -version 2






Wednesday, October 9, 2013

Die Skype!

Every now and then Windows starts up with Skype running but not in the system tray.

For the life of me, I don't know why. The only way to then go into Skype is to 'launch' it again, which brings the app into focus and on the Taskbar. But then, since I minimize to the system tray and don't keep it in the Taskbar to save space, it gets lost again :(

It's also a pain opening up the Task Manager just to close Skype. So, the solution, kill skype!

    Start -> Run -> powershell -command "ps skype | kill"

Tuesday, February 19, 2013

LESS is more

If you're a Visual Studio web developer and you haven't tried out the Web Essentials extension by Mads Kristensen, then GO NOW, GET IT!

And for those who do know about it, and you were using it for it's LESS support, then you may have noticed in the last update how it was removed :( The only alternative then would appear to have been T4CSS.

But the same day I updated and saw the lack of LESS support, was the same day that I realised it's now baked into Visual Studio in the most recent ASP.NET and Web Tools 2012.2 Update.

It supports adding LESS files from the New Item dialog, and upon build will generate the CSS and minified CSS for it too. Which is obviously the reason it was removed from Web Essentials. Awesome :)

Thursday, February 14, 2013

Git tip - diff of only modified files

I was wondering how to see a diff of only those items that were modified in my Git workspace, and thanks to Stackoverflow, you can use the --diff-filter parameter:

git diff --diff-filter=M
git dt --diff-filter=M

The second one is if you use a visual diff tool. I prefer WinMerge, might do a post on my setup at some point, it's pretty simple once you know how.

Wednesday, February 13, 2013

Where'd my Visio BMPN stencils go?

For some reason, when opening up a saved Visio diagram that uses the BPMN stencils, these no longer show up in the Shapes window.

To get them back, click on More Shapes > Open Stencil... then find the Visio content directory, in my case this is C:\Program Files\Microsoft Office\Office14\Visio Content\1033, and then enter BPMN*_M.vss to show only the metric BPMN stencils. Select them all, then click Open.

I have no idea why it isn't stored with the document somehow. Apparently if you go to File > Info > Properties > Advanced Properties and then check the Save workspace option, then it should save things like this, but that's checked for me and it doesn't. Maybe because it's the Professional version and not the Premium version, but I doubt it. Sounds like a bug to me.

Thursday, February 7, 2013

Easier way to get to that hosts file

In Windows, there's a hosts file mapping IP addresses to hostnames. For some weird reason, it's in the arbitrary location of c:\windows\system32\drivers\etc\hosts. This kinda reminds me of a Unix/Linux path, with the \etc\hosts. But anyway. That's often too much to type in when just trying to go Start -> Run -> notepad++ hosts. So, use symbolic links :) Something else that is Unix/Linux like, that not many people know exist on Windows:

C:\>mklink hosts c:\windows\system32\drivers\etc\hosts
symbolic link created for hosts <<===>> c:\windows\system32\drivers\etc\hosts

Then you can just say, notepad++ \hosts.

Much easier.