Techy Stuff

Occasionally, I’ll throw some posts up here with things I’ve figured out how to do. This will be especially true if I had trouble finding my own answers on Teh Google. I’d rather put my methods up here and hopefully solve someone else’s problem faster.

Fun With Windows PowerShell

Last modified on 2011-10-24 14:11:31 GMT. 1 comment. Top.

I haven’t posted anything geeky or techy lately, so I felt the need to do so.

Recently at work, I was given a DVD containing a data dump of closed loans. And when I say “data dump”, I mean almost 7,000 individual image files that used to be full loan packages, all stored in a spiderweb of folders that seemed to make NO SENSE WHATSOEVER.

“Christy, we need to be able to sort these out so we can review each loan.”

::Christy’s eyes cross::

Luckily, there was a csv file on the DVD that included paths to where each individual page of each loan was located.

Here’s how I did it.

# Where is the csv file?
$text = "\\domain\root\Imaging\Folder\key.csv"
# Okay, import the csv file data.
$loans = Import-Csv -Path $text
# Assign the loan number, the path and a unique filename to 
# usable variables.
	foreach($strLoan in $loans)
		{
		$loanNum = $strLoan.LoanNum
		$location = $strLoan.Path
		$name = $strLoan.Filename
		$destination = "\\domain\root\Imaging\Folder\Loans\"
# Test if a folder exists for that loan number already.
# If not, create one.
		if (!(Test-Path $destination$loanNum))
		{
			New-Item $destination$loanNum -type directory
		}
# Copy all the guts associated with that loan number
# to the correct folder.
		Copy-Item $location $destination$loanNum\$name
		}
Clear-Host

*****

Shadow Copies FTW!

Last modified on 2011-09-28 13:10:14 GMT. 3 comments. Top.

The company I work for uses Quickbooks for their accounting software, and we’ve had some really bizarre problems with it lately.

(For anyone interested, we’ve had two different company files suddenly start “losing” payee names from already cut checks and the vendor list. The file just seems to decide to corrupt and start writing data to the wrong tables. So the data is still THERE but you can’t see it and you can’t tell who you wrote a particular check to. Quickbooks support is at a loss as to why.)

Yesterday, we were dealing with the same problems and I was asked how recent our backups were. Back when we first started having issues with the files, I set up Shadow Copies on the drive the files are stored on and set it to take a snapshot every hour so we wouldn’t lose hours of work if the file decided to crap out. (Further proof that I am awesome.)

I went to our CFO’s office to explain to him how to find the previous versions of the files, how they were time-stamped, how to open them to look at them, etc. When he opened the folder for one of the previous versions, I suddenly heard a phantom voice say “Oh wow! That’s cool!!”

The CFO started laughing because I visibly jumped. Apparently, he was on the phone with Quickbooks support and had screen-sharing going, and the Quickbooks guy had never seen this before.

Techno-Geek Nerd Princess: Educating support staff since 2011!

*****

PowerShell AuthorizationManager check failed (resolution)

Last modified on 2013-04-03 13:25:52 GMT. 13 comments. Top.

I recently had a problem running PS scripts on one of my servers running Windows Server 2003. Every script was failing with the following error message;

AuthorizationManager check failed.
At line:1 char:2
+ . <<<< ‘C:\Path\Microsoft.Powershell_profile.ps1’
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException

Here are the steps I took to clear the error in my environment.

– First, check PowerShell to ensure the ExecutionPolicy is not set to “Restricted”.

Get-ExecutionPolicy

If it is, set it to either “RemoteSigned” or “Unrestricted” depending upon your security preferences.

Set-ExecutionPolicy RemoteSigned

If the error continues;

– Check to make sure Windows Management Instrumentation service (WMI) is Enabled and running. If it’s disabled, try enabling it and starting it to see if that clears the error.

– Occasionally, with the ExecutionPolicy set to “RemoteSigned” or “Unrestricted”, this error may occur if the script was downloaded from the internet using Internet Explorer and IE has “blocked” the file. Right-click the file, select “Properties” and click “Unblock”.

– If all else fails, go to the path noted in the error and delete the PowerShell profile file.

If you found the answer to your problem here, please leave me a quick comment to let me know! You can also find me on Google+.

*****

Twitter-pated

Last modified on 2011-08-16 20:43:30 GMT. 1 comment. Top.

I decided to make use of my neglected Twitter account. Most of the reason it’s neglected is because;

a) a lot of the people I follow update their Facebook status automatically when they tweet.
b) it’s another browser window to open and check during the day.

I already use the Google Desktop sidebar on my widescreen monitors at work. It doesn’t take up that much real estate on my screen and I can fit gadgets for GTalk, GDocs, photos, weather and even a nifty little system monitor.

“What would be really great,” I thought to myself, “is to have a little Twitter feed gadget just like the GTalk gadget.”

Well, there is an “official” Twitter gadget for Google Desktop but if you check out the page it’s apparently been abandoned and returns “invalid username/password” no matter what credentials you give it. (I tried.)

Upon hitting that brick wall, I polled the audience on my Google+ account to see what everyone else was using and/or recommended. Since all these applications were going head-to-head against the Google Desktop Sidebar, I’ve rated them on how much screen real-estate they took up, where a score of 1 would indicate taking up the whole freaking screen.

Here’s what I tried and what I thought of them.

Pidgin

http://www.pidgin.im/

Feels extremely clunky. No native Twitter support. I had to install a third-party plugin to connect to Twitter and then ANOTHER plugin to be able to update Twitter via my Pidgin status updates.

Note: The second time I started it up, it didn’t display my updated Twitter feed. I couldn’t find an option to refresh manually.

Real Estate score: 6 out of 10 – It’s about the size of an old school IM client…which is exactly what it looks like.

Seesmic

http://seesmic.com

This client is a bit of a memory hog. If I have it minimized, it doesn’t seem to bog down my system much, but if I maximize it to check it, my entire system starts to hang. Built on Microsoft Silverlight (possible cause?). Runs a bit slow.

It has a nice interface. I like the sidebar a lot. It’s easy to turn on and off filters, and I can drag to rearrange the columns. The GUI is nice to look at. Uses columns for different feeds. Desktop notifications are fixed in the bottom right corner of the primary monitor. Can’t drag them to reposition.

Real Estate score: 4 out of 10 – Takes up a lot of space on my second monitor, even when not maximized.

TweetDeck

http://www.tweetdeck.com/

TweetDeck runs on Adobe Air, is faster and uses considerably less system resources than Seesmic. It has a nice interface. Uses columns for different feeds. The post box at the top is easy to use. All the controls are right there and intuitive to find. Desktop notifications can be placed in any corner of the primary monitor screen, but they can’t be moved to a secondary monitor.

Real Estate score: 4 out of 10 – Takes up a lot of space on my second monitor, even when not maximized.

Trillian

http://www.trillian.im/

During the install, the Trillian software offered me a trial of Winzip (no thanks) and then asked to install the Trillian Toolbar (UGH), make Ask.com my default search provider (GAH) and set Ask.com as my home page (GAH!). Minus a thousand points.

Trillian offers email account support, instant messenger and Facebook/Twitter support. However, one of my big problems with it is that I don’t seem to be able to disconnect from Facebook chat when I have it connected to my Facebook account. I usually have Facebook Chat turned off when I have the site open in the browser. I can disconnect from Facebook entirely or I can set my chat status to “Away” but not disable it and still maintain my feed.

The client can be moved to secondary monitor. When minimized, the desktop notifications appear in the bottom left corner of the primary monitor. It places a separate icon in the task tray for every account you have set up. Each icon gets a teeny number identifier to keep count of how many notifications you have for that account. The desktop notifications also stack. (GAH!) Compared to the Facebook webpage, updates have serious lag. As in, up to 3-4 minutes.

Note: It actually turned ON the Facebook chat on my browser-based Facebook. I had to manually turn it back off through the site. Minus another thousand points.

Real Estate score: 6 out of 10 – It takes up about the same amount of room as an average IM client. Feels like an IM client more than anything else.

Twhirl

http://www.twhirl.org/

VERY simple interface. No Facebook support, though you can connect to a Seesmic account, which I guess you could connect to Facebook. Maybe?

When focus is removed from the app, it immediately turns 50% transparent by default, which makes it hard to read. Runs on Adobe Air, so there’s almost no discernable system resource usage. Developed by Seesmic. Desktop notifications show up in lower right corner of screen. They cannot be repositioned.

Note: Must stay running in taskbar. If you click the X to close it, it exits the interface completely.

Real Estate score: 7 out of 10 – Very small, easily positionable on multiple monitors.

TwitterGadget

http://www.twittergadget.com/

TwitterGadget offers a gadget that can be used on your GMail sidebar much like the Chat gadget or the Google Docs gadget. You can pop it out of the GMail screen just like a chat window.

It has a simple interface. The shortest auto-refresh rate is 3 minutes and you can set it to varying timeframes above that, though I’m not sure why you would want to. You can customize the heck out of the colors but can’t change the font. (I’m not fond of Verdana.)

Real Estate score: 5 out of 10 – If you have the window popped out of GMail, it takes up a good amount of screen real estate. If you leave it on your sidebar in the GMail window, it doesn’t seem to have enough space to be an effective reader.

An interesting note about all these clients is that I didn’t see any of them display a notification number on the taskbar when they were minimized. That would eliminate the problem of repositioning desktop notifications since they could be turned off entirely.

TweetDeck came out as my favorite client, though I’m still not entirely sold on it. What I’ve taken away from this is that my core requests for a Twitter Desktop Client are;

1) Needs to be able to both display and allow me to post to my Twitter feed.
2) Would love to be able to reposition desktop notifications across multiple monitors.
3) Must not use an abundance of system resources.
4) Would LOVE it to be integrated into Google Desktop Sidebar.

Is that too much to ask?

*****

Gpg4win Decoded

Last modified on 2011-08-12 19:08:52 GMT. 5 comments. Top.

I previously posted about a script I put together to decrypt and rename a gpg file. Part of the odyssey traveled to create that script involved attempting to put together the arguments to make gpg4win decrypt the file as an unattended task.

The amount of useful and helpful information in the README file for gpg4win is almost equal to the number of pink elephants sitting on my desk right now. I managed to finally piece it together and figure out how to pipe the passphrase into it. Here’s how I did it and what worked for me.

echo passphrase|gpg --batch --passphrase-fd 0 --output filename.txt -d c:\path\*.gpg

Note:

– If I remember correctly, you need to use the –batch switch in order for it to work correctly in Scheduled Tasks.
– The “-d” argument tells it to decrypt.
– If you either pipe your passphrase to gpg and don’t include the “–passphrase-fd 0” switch or vice versa, you will still be prompted to enter your passphrase when the script runs. You must pipe the passphrase at the beginning AND include the –passphrase switch.
– The “–passphrase-fd” switch isn’t included in the -help list in the command-line, so if you’re having trouble automating it, this is probably the piece you’re missing.

Other than that, I can’t seem to find my documentation on why that particular set of switches works for me. The README file is useless and the Novice manual doesn’t include anything about command-line switches. I know there is a comprehensive list somewhere out there on the internets, so if anyone has run across it, please post the link in a comment and I’ll update this post.

*****

Good luck, Brian!

Last modified on 2011-08-12 18:08:41 GMT. 0 comments. Top.

I got this email at work yesterday pitching a job candidate to me for my current position and decided to have a little fun with it this morning.

———————————————————————————
From: CJ
Sent: Thursday, August 11, 2011 4:45 PM
To: TGNP
Subject: Systems Administrator

Good Afternoon,

I hope this message finds you well. I understand that you are currently recruiting a systems administrator and I have a couple of really great candidates in mind that would be perfect for the position.

One individual in particular stands out among the group. His name is Brian and he has over 12 years of network administration, project management, desktop support, helpdesk, and end-user training experience. He has a BS in IT and holds several certifications, including MCITP Enterprise Desktop Administration 7 and MCITP Sever Administration on Windows Server 2008. In addition, he holds several virtualization certifications.

Please let me know if you would like to learn more information about Brian or if you would like to hear about other candidates at various levels of systems administration experience and expertise.

Sincerely,

CJ

Very Large Employment Placement Company
Account Executive, Consulting Services

———————————————————————————
From: TGNP
Sent: Thursday, August 11, 2011 4:45 PM
To: CJ
Subject: RE: Systems Administrator

Hello CJ!

I hope this message finds you well. The rumors of my recruiting for a systems administrator are greatly exaggerated, since that would be highly counter-productive to my continued employment in our currently downward-spiraling economy.

After scanning over Brian’s list of qualifications, I’m positive that you will be able to find him gainful employment, provided his social skills are as up-to-par as his technical repertoire. (We both know those IT people are hit-or-miss with social skills, am I right?)

Perhaps it might be a more efficient tactic to target your attempts to market him via email a bit more, rather than sending out mass communications and hoping to hit upon the right fit. However, I’m a network administrator and could be completely off-base. (We network admins tend to think we know everything.)

Good luck in your search and give Brian my best!

TGNP
Network Administrator
The Company That Employs Me

———————————————————————————

Side note: CJ called me back almost immediately and said that I made his day.

*****

Renaming An Output File According To Date

Last modified on 2011-08-04 21:19:45 GMT. 0 comments. Top.

About a month ago, I had a situation in which I needed to rename an output file to a unique meaningful name. I have a scheduled task that automatically downloads an encrypted file once a day from an FTP server. I wanted to create a batch file that would decrypt the file using gpg, rename the file to the current date (YYYYMMDD format) and move the newly renamed, decrypted file into the correct department folder. I thought it would be a pretty simple process to append the date to the filename, since that was the most logical unique identifier in my mind.  Easy-peasy, right?

Holy cow. Google almost failed me. Almost.

Apparently, there are about a bajillion different methods for converting date/time to a text string. Most of the solutions I found were dependent on regional settings, were overly complex (in my opinion) or didn’t give me the format I wanted the date to be in OR didn’t give me a meaningful date at all.

After A LOT of trial and error, I finally stumbled upon this simple solution. (Source)

for /f &quot;tokens=1-5 delims=/ &quot; %%d in (&quot;%date%&quot;) do rename &quot;decrypted.txt&quot; %%g-%%e-%%f.txt

It worked perfectly (i.e., the filename comes out as “2011-06-14.txt”). FTW!

So here’s what my batch file looks like (directory names have been changed, obviously);

cd c:\encryptedfiles\files
echo mypassphrase|gpg --batch --passphrase-fd 0 --output decrypted.txt -d c:\encryptedfiles\files\*.gpg
for /f &quot;tokens=1-5 delims=/ &quot; %%d in (&quot;%date%&quot;) do rename &quot;decrypted.txt&quot; %%g-%%e-%%f.txt
move *.txt M:\decryptedfiles
move *.gpg C:\encryptedfiles\files\archive

For those of you who prefer Windows Powershell, you can also do the same thing via a PS Script;

set-location &quot;C:\encryptedfiles\files&quot;
$date = (Get-Date).ToString('yyyyMMdd')
echo mypassphrase|gpg --batch --passphrase-fd 0 --output &quot;$date.txt&quot; -d &quot;C:\encryptedfiles\files\*.gpg&quot;
Move-Item *.txt M:\decryptedfiles
Move-Item *.gpg C:\encryptedfiles\files\archive

Not so painful!

 

 

 

 

 

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
Want to share?

3 Responses to Techy Stuff

  1. Brad Poynter says:

    I thought I would would share this with you since I just ran into it myself. A user brought their computer in saying that all their files had been erased from the drive after their “kid” had clicked on a link and installed something.

    It was a fraudware app that of course would fix these issues for the low price of 50 bucks. I looked all over the drive and EVERY FOLDER WAS EMPTY, Even the windows dir. I was all like WTF how did this thing even start but then it hit me. I checked the attributes on the root folders and almost every stinking file on the entire machine had been marked with the “hidden” attribute so they were there just not visable.

    I was about 2 minutes away from saying screw it and formatting the thing when I had my lightbulb moment, so I thought of all the nerds in the world I would share it with you.

    Have a wonderful day,
    Brad

  2. Nice read, I just passed this onto a colleague who was doing some research on that. And he actually bought me lunch because I found it for him smile So let me rephrase that: Thanks for lunch!

Leave a Reply

Your email address will not be published.