Showing posts from June, 2014

Windows 8 Keyboard Layout Per App

One of the things that was making me crazy every day was the language change in Windows 8. In previous versions of Microsoft Windows, when I changed the keyboard layout in one application and then switched to another the layout automatically changed to the one I had when I was using that application before. In Microsoft Windows 8 and 8.1 when you change the keyboard layout and then switch to another application the layout does not change! Fortunately, there is a setting that allows the previous behavior. You'll find it in Control Panel, All Items View, Language, Advanced Settings on the left side. The checkbox has the title " Let me set a different input method for each app Window".

Active Directory Enterprise CA

In many cases I work with clients that use their own Certification Authority to issue certificates for their services, like Microsoft Exchange, Microsft Lync, IIS websites etc. In order for me to issue a certificate I obviously have to know where I can find the CA server... I use the following command:  certutil -config - -ping  in order to find the CA. If there is a CA with in your network a popup box will appear asking which CA to ping. You then should be able to get the server name from the output that follows on the command prompt.

How to Negate powershell conditions

While developing some new functions for one of my Powershell modules today, I faced the problem where I had to negate one of my functions. To be more specific, I have a function that returns $True if the Powershell session/user has administrator privileges. I then had to display an error cause the function had to be able to access system files. The solution is very simple. Lets say we have the following statement: if (Test-Path C:\Scripts) { Write-Host "Path exists." } and we want to negate it. The only thing we have to do is enclose the Test-Path check into Not function: if (-Not (Test-Path C:\Scripts)) { Write-Error "Path does not exist!" }

Task with Powershell Script Suddenly Started to Fail

Some weeks ago I created a powershell module that contained function to create, view and remove Volume Shadow Copies. I used that module in a script in order to create a new shadow copy and clean up the old ones. I added that script as an action on a Task in Task Scheduler and everything was working fine. After some additions to the module I copied the new file, with the same name, over to the server. I checked the logs a little bit later and there were no new events (my script is writing to a custom log). Then I tried to run the task manually and I got an error code. As it turned out I had to unblock the module file in Windows Explorer in order to avoid the security warning that was waiting for user input from the import-module command. After that everything is working fine again!

PowerShell Log

I'm starting to have many jobs that run powershell scripts on some servers so I decided to update the scripts in order to write to the event logs on the servers. I decided to create my own log in order to be free to do anything I want with it and I called it "Powershell Jobs". I also added a source for every job. All that with the New-EventLog command. I then added error handling code to the scripts using the $error.Count value in order to check if the last command had any errors and the $error[0] for the error message. I then write to the above log using the Write-EventLog command. That way I know what happened for every job and I can get it on Splunk (or any other syslog server) too. One more thing, depending on the result of a command I write error or information events and I'm using a seperate ID for every event type.