Monday, June 22, 2015

PowerShell Triage for System Administrators

I've been working as a System Administrator for a university for several months now, and I've finally dipped my feet into the well-maintained pool of PowerShell.

Thanks to Powershell's intuitive design and architecture, I've been able to quickly develop a few basic tools that have really increased my productivity and made life a lot easier.

The "triage" of cmdlets that I've compiled are for managing user accounts without having to deal with Active Directory's cumbersome GUI. Both Ldapsearch and Reset have a -h argument to display additional options when running. I suggest that the simplest method for accessing these simply is to create a PowerShell profile that automatically sets aliases to these scripts when a shell is opened.

Test Credentials.ps1 is a simple call to ask for user credentials on the current domain. A popup window is presented to the user, and a verification is sent to the console after a logon attempt.

LdapSearch.ps1 is a ploy off the wonderful Linux-based Ldapsearch function. It takes multiple parameters and will let you search users or computers. The nice thing about this is that it will give you the DN of all searched objects, instead of having to deal with the (lack of) Active Directory display for this attribute.

Reset.ps1 is really the meat and potatoes of this triage. Reset will essentially handle calling both the above tasks, as well as perform password resets, account unlocks, and expiration date changes. Reset.ps1 handles multiple arguments and has built-in checks for any errors pertaining to a specified user account.


In Action:


Tuesday, December 2, 2014

Ping Parse

For my fellow Systems Admins out there, these situations do not present themselves very often, but for when they do, this program is your best friend.

I just finished developing a text file parser that will analyze every detail of a series of ping attempts to whatever you may need to keep an eye on. 

Simply get a persistent ping going and saving to a text file:

Windows:
ping [IPAddress] -t >> File.txt (don't forget the -t)

Unix:
ping [IPAdress] >> File.txt

Once you think you have enough data, close that session and we're ready to go. 

After downloading my jar file, simply run it with the path to that text file we created as the only argument. Open up a new command line or terminal window and run the following:

Windows/Unix:
java -jar [jar file path] [text file path]

So in my example, I'd run it as: java -jar Ping Parse 2.1.jar File.txt

That's it! Let it run and it will give you a comprehensive output showing you every stat you might want to know about the pings that you put out. 

I've tested this program with ping counts as high as 300k and the program never gets bogged down. Below are a couple results from my own use:



Before anyone gets upset, I know Java is clunky, but I wanted to get it working in that before seeing if it was worth making this into a full application. 

Thursday, November 6, 2014

Mac Quick-Switch Location App

Developed this little script a while back but finally decided I'd toss it up on my site. It's a simple Apple Network Location switch utility. Grabs the list of current locations and lets you choose which one you want to switch to. Very useful when using a laptop that you frequently visit different locations.
Tested and working on:
OSX 10.6
OSX 10.7
OSX 10.8
OSX 10.9

Download Mac Switch Network Location

Friday, October 18, 2013

Ajax Chat Emoticons Container Popup

This will show you how to add a small ox next to your BB codes that allows a popup box for storing more emoticons. I am doing this on a standalone version but it should work on all versions. 

Easy steps first: Put the emoticons in the correct folder for your chat to recognize (/img/emoticons), and make sure that config.js array's have been configured correctly with proper names and whatnot. 

While you're in config.js, you're going to have to create another array which tells the chat where the images are placed. Your options are display under the text area, display in the popup, or display both. But first, we have to make sure we have the container declared for the emoticons to be placed in.

In Config.js.

Find:
// The ID of the emoticons container:
        emoticonsContainer: 'emoticonsContainer',



Add After:
// The ID of the emoticonsPopup container:
        emoticonsContainerPopUp: 'emoticonsContainerPopUp',

Find:
emoticonFiles: new Array(
'Example1.png',
'Example2.jpg',
'Example3.gif'
);

Add After:
// Defines whether the associated emoticon will display (3 will only display outside popup, 2 will always display, 1 will display in the pop up, 0 is hidden):
emoticonDisplay: new Array(
 
1,
 
2,
 
3
),

Now we have to declare the array and allow the CSS to get data from it.

Open chat,js

Find:
this.emoticonFiles                      = config['emoticonFiles'];

Add After:
this.emoticonDisplay            = config['emoticonDisplay'];

Find:
initEmoticons: function() {
  this.DOMbuffer = "";

Add After:

var emoticonDisplayPopUpCount=0;

Find:

this.emoticonCodes[i] = this.encodeSpecialChars(this.emoticonCodes[i]);

Add After:
if(this.emoticonDisplay[i] == 2 || this.emoticonDisplay[i] == 3){
            
if(this.dom['emoticonsContainer']) {
                    
this.updateDOM(
                        
'emoticonsContainer',
                        
'
                        
+ this.scriptLinkEncode(this.emoticonCodes[i])
                        
+ '\');">
                        
+ this.dirs['emoticons']
                        
+ this.emoticonFiles[i]
                        
+ '" alt="'
                        
+ this.emoticonCodes[i]
                        
+ '" title="'
                        
+ this.emoticonCodes[i]
                        
+ '"/>
'
                    
);
            
}
            
}
            
if((this.emoticonDisplay[i] == 1 || this.emoticonDisplay[i] == 2) && (this.emoticonDisplay[i]!= 3)){
            emoticonDisplayPopUpCount
++;
            
if(this.dom['emoticonsContainerPopUp']) {
                    
this.updateDOM(
                        
'emoticonsContainerPopUp',
                        
'
                        
+ this.scriptLinkEncode(this.emoticonCodes[i])
                        
+ '\');">
                        
+ this.dirs['emoticons']
                        
+ this.emoticonFiles[i]
                        
+ '" alt="'
                        
+ this.emoticonCodes[i]
                        
+ '" title="'
                        
+ this.emoticonCodes[i]
                       
                         
+ '" height="'
                        
+ 25
                        
+ '" width="'
                        
+ 25
                       
                        
+ '" style="padding: 10px"/>'
                    
);
            
}
        
}


^^ What you can see being done here is that it's determining from the array that we set up, where the emoticons should be placed. Either in the container we're going to create, or the page, or nowhere. You can change the display size of the emotes from within here as well. 

Now that everything is declared, we need a place to put all of it, and a button to activate the box we put the emoticons in. 

Open Global.css

Find:
#content #colorCodesContainer {
  position:absolute; left:20px;
  bottom:55px;
 padding:3px;
  z-index:1;

}

Add After:
#content #emoticonsContainerPopUp {
  position:absolute; left:450px;
 bottom
:125px;
 padding
:3px;
 z
-index:1;
}

Find:
#content #colorCodesContainer a {
  display:block; float:left;
 width
:20px;
 height
:20px;
}

Add After:
#content #emoticonsContainerPopUp a {
  display:block; float:left;  width:60px; height:30px;
}

That creates the box for which we'll be adding the emoticons to in Chat.js. Now let's make that button!

Open LoggedIn.html
Find:


 id="bbCodeContainer">

Add *At the last spot in before the "/div"*:


 type="button" value="More Smilies" onclick="ajaxChat.showHide('emoticonsContainerPopUp', null);" />

Find:



 id="colorCodesContainer" style="display:none;" dir="ltr">

Add After:



 id="emoticonsContainerPopUp" style="display:none;" dir="ltr">