Advanced Windows PowerShell Scripting Video Training

Wednesday, January 30, 2013

Windows Server 2012 Hyper-V server is essentially Windows Server 2012 Server Core that is designed in only run Hyper-V. You do not have to worry about purchasing a license for Hyper-V server. The Host OS is free. You do need to properly license any virtual machines (VMs) that you run on the Hyper-V server however.

Setup is a breeze. It was, for the most part, just like installing Server Core. It is also very fast. Just download the installation software from Microsoft. For this deployment, I plugged a keyboard, mouse , and monitor into my target server so I can observe all the action. Really, there is not much to watch once you get things started.

Once the server starts up, you need to give it a password for the local administrator account. Then SCONFIG opens up. Use SCONFIG with the following options to place this server in your domain and make it manageable.

8) Give this server a static IP address.

1) Add to the domain. You can also rename it with this option.

7) Allow remote desktop connections to this server.

At this point, you can unplug the monitor, keyboard, and mouse.

Once the Hyper-V server reboots, go ahead and configure either your Windows Server 2012 graphical server or Windows 8 client with RSAT to manage this server.

In Server Manager, click All Servers.

Right click All Servers and select Add Server.

In the name field, type the name of your Hyper-V Server and click Find Now.

Select your server from the list and click the right pointing arrow.

Click OK.

In a few minutes, your Hyper-V server will be manageable from your Server 2012 or Windows 8 client.

Monday, January 28, 2013

While executing scripts against a large number of clients in your organization, you will undoubtedly encounter a few that are offline. This causes your script to hang on each one. This pesky little behavior can be mitigated in a variety of ways. The function below is what I use when I need to run a script synchronously. You simple give it the name of the client you are attempting to contact and the number of retries it gets. I usually only give it 1. It will return TRUE if contact was made. You then make a decision of what to do at that point. I allow the script to proceed if the response is TRUE or I send the client name to an error log if it is FALSE.FunctionTest-ClientConnectivity

Wednesday, January 23, 2013

This is a question that I often have to ask a user. The problem is that our users answers cannot always be considered…shall we say “reliable.” Below is a PowerShell function that you can use to to determine when the client in question was last started. Here is what you get when you run this function.

PS C:\windows\system32> Get-LastStartTime -ComputerName Work-PC

Last Startup Time: 12/31/2012 1:44:43 PM

I’m using this as part of the HelpDesk module that I creating for my up coming book and also I’ll be demonstrating the full module at the Cincinnati PowerShell users group meet up on Thursday, February 21, 2013. Here is a link to the event. Our focus will be on using PowerShell with your Help Desk.

Monday, January 21, 2013

Years ago I was introduced to portfolio rebalancing by a friend that I used to work with. In short, portfolio rebalancing allows you to sell off some stock in funds that have increased in value, and then buy more shares in funds that have decreased in value. This allows you to sell high, buy low. The company that currently manages my business retirement plan does not have an option for this, but I am allowed to transfer funds between different investments without fees.

Below is an example of two concepts that I use in my PowerShell classes. One is how to gather information from the internet and the other is how to use the XML variable type in PowerShell. You will have to create a CSV file that contains three pieces of information. FUND, QUNATITY, ALLOCATION. The Fund will be the ticker symbol for a stock or mutual fund. The quantity will be how much of that fund you own. The allocation is a percentage of how much of your portfolio you want that investment to consume. Make sure the allocation column totals 100%.