Applying a Windows PowerShell logon script to your servers is pretty easy. As you can see I have created an Organizational Unit where I will put my Computer object for my servers, and I have created and linked the Group Policy Object to just that OU. Within the GPO I have gone into the User Configuration. This is where you do not want to get confused. You only want this GPO to apply to computers, but computers do not have logon scripts, they have startup scripts.
In the GPO we are going to switch over to the User focus. Come over, open up the logon script and then, instead of doing an old style VBScript, we will add a PowerShell logon script. For scripts in this GPO you can configure to run Windows PowerShell scripts first or last. Keep in mind that if your users are picking up another (this would be your administrators) logon script from somewhere else in the domain then all of those things are going to apply in order, and all of those scripts will run.
You want to make sure that you do not have overlapping drive names for example if you are doing a bunch of drive mappings. Now within that script you can do lots of different stuff and in the article that accompanies this video I suggested creating a “Why are you logging on to the server console” type of prompt.
Here is another example. Here I am retrieving Windows Operating System information using Windows Management Instrumentation (WMI). I am loading up the portion of the .NET Framework that handles database connectivity, connecting to a SQL server database, creating a SQL command (we just need to make sure that query is executed after it is actually defined), and inserting into a table a bunch of information. In this case it is going to be the server name, the name of the user that is logged on, and the current Service Pack version for this machine. I would also setup that table to have a fourth column with the current date and time and configure the table so that it fills in the current date and time automatically. That way I do not have to specify as part of this query. By doing that, every time somebody logs on to the server console I will have a nice log of who logged on, when they logged on, and it will give me an idea of what Service Pack version the machine was running at the time.
I could configure a SQL Server Agent task on the server to automatically delete records that are older than say 90 days or whatever retention period you wanted and you have yourself a neat little log there. You can prompt to find out why the person was logging and maybe save that information to the database as well. There is a lot of neat things that you can do in a server specific logon script to help overcome specific management challenges.