Archive for July, 2013

Powershell: Direct output to a variable.

Thursday, July 25th, 2013

I was asked if there was a way to capture output of a specific program to a variable.

Basically, the person wanted to get a version number from the program.

Played around and had a way to accomplish this  but I found a simpler approach.

$scriptOutput = & "c:\path\program.exe" -V 2&1

Obviously, the -V works with the program in question.

I am liking powershell

The account used is a computer account. Use your global….

Thursday, July 25th, 2013

While scripting a report; I noticed a bogus error about a file version being wrong.

I examined the server in question and found the server service was not running.

I tried to start it but it stopped right away with the following message in the system event log.

The Server service terminated with the following error:
The account used is a computer account. Use your global user account or local user account to access this server.

Another server with the same problem would give this message:

Windows could not start the Server service on Local Computer Error: 1808: The account used is a computer account. Use your Global user account or local user account to access this server.

The service was configured correctly.

An odd problem and it’s cause was the fact a couple users placed URLs in the system Path variable (ie \\server\mount\dir).

Removing the entries and a reboot of the server corrected the issue.

You must be an administrator running a console session…..

Tuesday, July 9th, 2013

I was trying to debug a problem on a remote server through remote desktop.

I wanted to run a Windows File Protection scan (sfc) but was rewarded with:

You must be an administrator running a console session in order to use the sfc utility.

I looked at Microsoft and found this technote.

The resolution was was to run it locally as this was by design!!!!

I thought “Come on! I have to drive over to the machine!”

Then, I noticed “Applied To” and saw only Server 2000 listed.

Hmmm?  Administrator?…..

What would happen if I started a command window as a local administrator (right click the menu option and select run as administrator)?

Success!

Lesson of the Day:  Read the whole technote!