Archive for the ‘Windows’ Category

The remote session was disconnected because there are no Remote Desktop LIcense Servers

Monday, November 3rd, 2014

Remote Desktop is one of things administrators use throughout their day. It’s very useful and greatly missed when it does not work.

A user reported he had lost access to a 2012 server running remote desktop services. The server pinged and I was able to get to the hidden share.  However, when I attempted a Remote Desktop Connection; I received:

The remote session was disconnected because there are no Remote Desktop License Servers available to provide a license.  Please contact the server administrator.

Most likely the Remote Desktop Service had been running in trial mode and the grace period had expired. This server was located in another building and I was not interested in driving over.

Many people don’t know or simply forget there is a command line ability for remote desktop. You can by pass the licensing problem and get access by running the following from the Run command:

mstsc /admin

This will disable licensing for the session.  Basically; you are accessing the server through administrative mode only.

For more command line information, you can look at this.

Server 2012 changed many things.  It changed the way you manage Remote Desktop Services. Previously, you would simply go to administrative tools and bring up the services manager or session host configuration.  Now, you only get RD Licensing Diagnoser.

I ran it and a message which caught my attention was about licensing not being configuration for either Device or User.  There were also messages about license servers not getting accessed but I was interested in the configuration used during setup. The problem was where to configure this?  Especially since, Remote Desktop Session Host Configuration no longer exists.

Server 2012 is an attempt to be more virtual and cloud like so the management tools are geared for that. If you simply want a server to run Remote Desktop Service and use your license servers, you may configure the needed options through the local computer policy.  Start the editor:

gpedit.msc

Work your way through:

Computer Configuration -> Administrative Templates -> Windows Components -> Remote Desktop Services -> Remote Desktop Session Host -> Licensing

There you will find your two needed options:

Use the specified RD license servers

Set the Remote Desktop licensing mode

Enable them and enter your license server(s) and the user or device mode.

Close out and give the server a reboot and you should have access to the server.

Changing to Powershell ISE

Thursday, October 23rd, 2014

I have had a constant problem with AdminScriptEditor.  For whatever reason, it will format certain lines which break up my variables (IE.  $  variable).

In a moment of anger, I decided to start using the Powershell ISE.  Simple but missing a few things such as a print menu.

There is the add-ons menu which is kind of clumsy but it gives you the chance to add missing routines and functions.

I found Jeffrey Hicks wrote a series of functions to extend ISE.  Simple install process and now I can print my scripts!

There is also a technet entry on this.

DNS check for powershell

Saturday, October 11th, 2014

I had a need to do a quick DNS lookup for computers in a powershell script which going through a list of computers. There are two ways to a system will not have a DNS entry: 1) System retired. 2) System uses DHCP and is not on the network.

A quick way to perform a look would be to use:

[System.Net.Dns]::GetHostName()

It does give output directed to the console.  If you want to suppress it, use the [void] option.

[void][System.Net.Dns]::GetHostName()

Trimming white space

Friday, October 10th, 2014

Working with a CSV file; I had a situation where the command line would give the output I wanted but the script would get the object information.  I found I could get what I needed by converting the output to a script but it introduced white space.  A computer name would turn into:

“Computer                                       “

What was interesting was the system commands would treat the white space as part of the computer name which of course cause the commands to fail.

Look around the Net; I found a command to trim white space.

$server = $server.trim()

The system name returned to proper size and what is great about this command is that it will trim white space from both sides.

Replace a character in a string

Friday, October 10th, 2014

I had a script where I needed to change a character in a string.

Simple task as I found on the Net.

$str = $str.replace(‘\’,’_’)

Scriptblock doesn’t work with variables.

Friday, October 10th, 2014

Powershell is a fun experience which I wish I had started awhile ago.  It’s features seem endless and it greatly eases system management.

The recent scare over Shellshock caused us to evaluate our Cygwin installations.  We didn’t know the exact number of installations and the version of Bash in use.

The question of the number of Cygwin installations was easy to solve. A script to review the organization units and scan each computer for Cygwin.

After a list was generated; a script was written and three results files were created: Found, System Down, and Not Found.

Cygwin due to it’s open source nature does not follow Microsoft design standards.  It has it’s own way of doing things. Good for the user but not always good for system management purposes.

I didn’t find a “Quick and Dirty” way to get the version number of the Bash executable.   Nothing in the registry and file information lacked details.

Redhat (we use them for support) advised using the “–version” option to identify the version.  A rather tedious task if done through remote desktop or nagging the users to send the information.

What would be nice if there was way to run a command remote and get the information.

Powershell has a nice option called “invoke-command.” It’s a one use option for such things.

The command is rather simply to use:

Invoke-Command -scriptblock { c:\cygwin\bin\bash –version }  -computername <hostname>

This gave the following output:

GNU bash, version 4.1.15(1)-release (i686-pc-cygwin)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

A little too much detail for a version number.  This was quickly addressed by using Select-String command.

Invoke-Command -scriptblock { c:\cygwin\bin\bash –version }  -computername <hostname> | Select-String -pattern “GNU bash, version”

This in turn gave:

GNU bash, version 4.1.15(1)-release (i686-pc-cygwin)

This was usable.  It also helped with simple errors.  If you don’t get the expected result, add an error message. This became evident when trying to run the command on Windows 2003 which lacked Powershell 2.0 and systems which did not have remote management configured.

Invoke-Command is great.  It gave me the information I needed without visiting each system.

I wrote a script and quickly found two problems:

  1. There are flavors of Cygwin and unless there was a conscious effort during install; you could end up with different directories (ie: C:\cygwin, C:\cygwin64, C:\rhcygwin).
  2. Running the command for several systems.  Invoke-Command can take up to five systems.  Great for a small number but not so great when you have hundreads or more.

Both of these issues required the use of variables and it was quickly discovered that -scriptblock option couldn’t use variables. For example:  $cygwinPath\bash.exe –version resulted as \bash.exe –version

The dynamic nature of scanning several computers was not something the command could do.  Rather then use another approach; I looked around the Net and found there was a way to use dynamic scriptblocks by using the NewScriptBlock command.

A quick change:

$scriptblock = $ExecutionContent.InvokeCommand.NewScriptBlock( “$cygwinPath\bash.exe –version”)
$versionResult = Invoke-Command -scriptblock $scriptblock -computername $server | Select-String -pattern “GNU bash, version”

This gave the needed results and we had an understanding of the work needed to be done.

If you would like to read more about Invoke-Command, Ed Wilson did a nice little writeup on his blog.

How to skip the first line with import-csv

Wednesday, September 3rd, 2014

I had a “quick and dirty” script to examine a list of hosts from a CSV.

There was a header with the data and I didn’t want the error that would pop up at the end of the foreach loop.

To get around the first line; I used a pipe and the select statement:

Import-Csv $file -header(“Hostname”, “OldIP”, “NewIP”) | select -Skip 1 | foreach {

Simple and it avoids a comparison check in the code.

The only thing to be concerned is if there are times there will be files without a header.

saveIndx: Unknown index name from ELIM

Monday, August 11th, 2014

While reviewing a server for an issue; I noticed a few messages from LSF.

saveIndx: Unknown index name <name> from ELIM

This message is reported a missing flag from lsf.shared. A quick edit and a process and service restart and the message went away.

 

Learning is a never ending adventure

Sunday, August 10th, 2014

If you are lucky to have a company which will pay for professional training, count your blessings. All to often, there is little or no budget for such things. Add in the mentality of “if we train them, they will leave!” pretty well eliminates professional training.

To remain employed, you always have to stay current and read and play with new things as much as possible.

As the year is coming to the end, people start making predictions as to what will be the hot knowledge for the next year.

Such is the case with this blog entry. And of course, I have my viewpoints. 😉

Migration to the Cloud is going to remain the effort as the reduction of IT people seems to be on many peoples minds. Many will try to fight it. Having survived a couple of reduction efforts, I advise all to embrace it and get involved if at all possible. It doesn’t matter, it’s a leaky sieve in matters of security. Companies will attempt it and declare it a success no matter the result. I would like to get involved with the Cloud; however, at the moment I don’t have access.

As to Powershell;if you work in the windows world, you are are foolish not to know it. I have finally started playing with it and now wish I had started awhile ago. It’s fun and it makes life easier!

IPv6; we have heard about it for a long time. It’s will start appearing! Just recently, Microsoft announced it ran out of IPv4 addresses for Azure. I expect other companies to run into the same problem.

Security is a good thing to understand. I don’t know if we are changing to a security minded world as some of the hype is motivated by the recent examples of security failures. It may be the start of a trend or it could very well be the usual fad and get reduced in effort as events die down and security starts being a massive expense. The security world is a certain type of mindset. It would be good to talk to a few people before deciding this will get you a job as with the glut of IT workers awhile ago. Many people working but many didn’t have the aptitude.

Compliance is rather boring for me. Not something I would want a career.

Vmware and Hyper-V are are mentioned but I am wondering if virtualization is becoming one of those expected skills but will not do much for you. I have used vmware and am currently getting ready to play with a Hyper-V cluster.

Office 365 and Google apps are growing. I can see this being a good thing to know especially when I hear more and more arguments of why do volume license when you can basically rent what you need? I am considering looking into Google Apps certification.

Time to start reading and setting up test environments!

 

Please wait for the System Event Notfication Service…

Thursday, August 7th, 2014

One of the most annoying things is a server which is hung up and won’t allow you to access it remotely. Especially, if it requires driving to get to the server.

Such was the case of a trouble call from a user trying to access a server. He would try remote desktop and received the following message:

Please wait for the System Event Notification Service…

The login process would remain at this point.

Remote Reboot failed but the system would ping and I could mount a hidden drive.

I needed remote desktop to work so I could look into this problem.

The System Event Notification Service as described from an article in the Microsoft Developer Network states:

Applications designed for use by mobile users require a unique set of connectivity functions and notifications. In the past these individual applications were required to implement these features internally. The System Event Notification Service (SENS) now provides these capabilities in the operating system, creating a uniform connectivity and notification interface for applications. Using SENS developers can determine connection bandwidth and latency information from within their application and optimize the application’s operation based on those conditions.

It sounds like something that is not needed, but it wasn’t the time to make this call when there was an annoyed user waiting for the server. I suspected we could at least kill the process and see if Remote Desktop would work again. Time to use the useful SC command:

sc \\servername queryex SENS

This returned:

SERVICE_NAME: sens
TYPE               : 20  WIN32_SHARE_PROCESS
STATE              : 4  RUNNING
(STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE    : 0  (0x0)
SERVICE_EXIT_CODE  : 0  (0x0)
CHECKPOINT         : 0x0
WAIT_HINT          : 0x0
PID                : 976
FLAGS              :

Using the PID; I could attempt a taskkill of the sens process.

taskkill /S <servername> /PID 976 /F

This made the login session continue and I had access to the server.

Checking the Net; there are a several situations which could cause this condition.  It ranged from removing Live Messenger (which was not installed), registry changes (which didn’t work or didn’t apply) to removing an update (which was not installed).

I had to log out and found the error was back.  I used the same taskkill steps and was able to access the server again.

Not seeing the obvious; I figured I would try the “fix most things Microsoft” solution and rebooted.

The error went away.

Sometimes a reboot is all that is needed.