Summary: Oliver’s true challenges begin and he discovers built-in Windows PowerShell scripts.
Note This is the fourth post in a series. To catch up, read:
- Oliver Script: A Holiday Tale–Part 1
- Oliver Script: A Holiday Tale–Part 2
- Oliver Script: A Holiday Tale–Part 3
If you will remember, our friend had taken on a new and terrifyingly amazing challenge. He was about to take on the venture of starting a new company from the ground up with a good friend. For everyone else, this could be considered “flying over a canyon full of crocodiles without a safety net, and armed with only a propeller.” On your worst days, you think you may be eaten alive—on your best days, you're inches from being eaten alive.
So our good friend flew into this land of wonder and terror. Each day, he was both excited and terrified to face the next. But the money began to flow because, as a team, he and his friend garnered much respect from those in the industry. Their skills grew, and as they did, the company began to prosper.
But as with many great ventures, sometimes the jackals would be snapping at their heels. Unfortunately, sometimes they would show up in the form of staff members who grew smart but unscrupulous. Twice did Oliver and his friend’s company come back when unscrupulous contractors attempted to steal customers.
The integrity and intelligence of Oliver and his friend won out over and over against people such as two contractors, Kags and Monks.
Kags and Monks were working with Oliver; and at one point, they were appearing quite eager to receive training from him. They seemed quite willing to learn; but in fact, they were more interested in learning how to contact clients directly to undercut the efforts of the company.
However, Oliver’s friend caught the two in the midst of their efforts and quickly dispatched each with a pink slip in their hands and merry boot in the rear for their troubles.
Over time Oliver began to finish their jobs with increased customer satisfaction. Yet, his billable hours seemed less than his counterpart's. His friend was quite perplexed by how this was possible and took him aside. “Oliver, I know you’re quite excellent at your work, but I don’t understand how it is that you can get the work done so quickly with so little effort. What is your trick?”
Oliver looked at his friend. “I’m simply leveraging a solution that is already provided by Microsoft in our customer environments. Most of the modern Microsoft solutions are providing sample code in Windows PowerShell for the many daily tasks I perform.”
He launched the Active Directory Administrative Center to show an example. “Here is something we do all the time—create and disable accounts in Active Directory. Normally, to create a user named John Smith, we would start by clicking New and then select User.”
“Then in the window that opens, we’d populate details such as First Name, Last Name, and Password.”
“The challenge I encountered was repeating tasks over and over. For example, I would often type the same information repeatedly or add users to groups per site.”
"One day I looked at the bottom of the console and I noticed a tab called Windows PowerShell History at the bottom of the Administrative Center. When I clicked it, I saw that all the work I had been doing was listed as mini Windows PowerShell scripts.”
“I then discovered that if I selected them all in the GUI, pasted them into Notepad, and saved that as a .ps1 file, I had a Windows PowerShell script that would create that a disabled account with no password for that user.”
“After I saw that, I realized I only need to have Windows PowerShell take in some key parameters (such as FirstName and LastName) and have it populate the values. It took me an hour on a Friday afternoon to learn that small piece.”
His friend nodded. “So the software from Microsoft usually gives pretty good examples of how it did it?”
Oliver nodded enthusiastically. “Even for some of our older clients running Exchange Server 2007. I can use the Exchange 2007 cmdlets for some administrative tasks, such as creating mailboxes. In this situation, I found that it provides a little option in the GUI that grabs the output: 'Select Ctrl+C to copy the contents of this page.'"
That output has a Windows PowerShell script embedded within it. I can also paste that script into Notepad to work from. Here is an example:
“The other day I was adding a web site component to one of the Windows Server 2012 environments, and I noticed something interesting. Before I finished, there was a link called Export configuration setting. I was about to click it to grab the settings for that task, but when I hovered over it, it showed me the Windows PowerShell script it was about to execute!”
“Even in the Microsoft Deployment Toolkit (MDT), we have a View Script option for every action! As a result, with a single script, I can deploy a new MDT deployment share in any client site.”
His friend was very impressed. “This definitely shows how you’ve been able to pull this off. We may have to look into switching you away from hourly billing to task-based. I can definitely see how we can take advantage of Windows PowerShell to do more work than our competition in the same time frame!”
Over time, the two of them combined their efforts to leverage automation wherever possible and they began to prosper.
However, an itch was nagging Oliver. Boredom. These smaller sites were increasingly simple to manage, and Oliver needed something to push him to his limits. Thus, his desire to work for Microsoft pushed at him.
The silly fellow tried to do something nobody else had: entertain them. Over the months, songs, parodies, and elaborately overdone videos flowed from Oliver. He even wrote a song about Windows PowerShell. Although these attempts did not garner him a job at Microsoft, there was some positive attention in the form of a job offer from a friend who was seeking help in his enterprise environment.
Oliver thought about that for a bit.
He told his business companion that it was time for him to seek greater challenges. He presented his notice, and he began the trek to start pushing his skills to an entirely new level: the enterprise.
Is Oliver ready for the enterprise? Is the enterprise ready for him? Will the ears of people at Microsoft recover from his songs? Stay tuned for tomorrow’s episode of Oliver Script: A Holiday Tale on the Hey, Scripting Guys Blog!
We invite you to follow The Scripting Guys on Twitter and Facebook. If you have any questions, send an email to The Scripting Guys at firstname.lastname@example.org, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then remember eat your cmdlets every day with a dash of creativity.
Sean Kearney, Windows PowerShell MVP and Honorary Scripting Guy