Tag: PowerShell

Querying a SQL Server Database from PowerShell

A few days ago, I wrote a PowerShell script on my computer that would ultimately be used on a different computer to automate a specific task. One of the things this script did was to query a SQL Server database which worked fine on my computer. After moving the script, it didn't take long to figure out that the other computer didn't have the necessary SQL PowerShell snap-in or module. My goal was to install the minimum features of SQL Server 2008 R2 to be able to run Transact SQL from PowerShell Read more [...]

No Soup, I Mean No PowerShell -Version 2 For You Windows 8 and Windows Server 2012

Be sure to start off by reading my previous blog article titled "Error When Running PowerShell -Version 2 on Windows 8 and Windows Server 2012" if you have not previously read it since attempting to run PowerShell in version 2 mode generates an error on a default installation of Windows 8 or Windows Server 2012. In PowerShell version 3, you can access PowerShell version 2 by running "PowerShell.exe -Version 2" (or "powershell -v 2"): Windows 8 Release Preview The PowerShell version 2 Read more [...]

Error When Running PowerShell -Version 2 on Windows 8 and Windows Server 2012

Windows 8 Release Preview On a fresh installation of the Windows 8 Release Preview, when attempting to run PowerShell.exe -Version 2, you'll receive the following error: "Version v2.0.50727 of the .NET Framework is not installed and it is required to run version 2 of Windows PowerShell." The following error message is generated if you attempt to run the same command from the PowerShell ISE: "powershell : V e r s i o n v 2 . 0 . 5 0 7 2 7 o f t h e . N E T F r a m e w o r k i s Read more [...]

Collections Are More Transparent In PowerShell v3

In PowerShell version 2, it took me a while to figure out why using the dotted notation method of selecting a property worked at times and not at others. In the following example $v2 is a variable so I'm able to select the CPU property by using $v2.cpu or accomplish the same thing by piping $v2 to Select-Object with the -ExpandProperty parameter and specifying the CPU property: In the scenario shown in the following image, why didn't $v2.cpu return anything? Because it's a collection. In this Read more [...]

Use PowerShell to List Stopped Services that are Set to Start Automatically While Excluding Delayed Start Services

Have you ever had 67 emails about services on your servers being up and down from your monitoring solution? It's not a good feeling and those emails are only about the ones that monitoring is setup for. What other services could be stopped that aren't being monitored? Wouldn't you like a quick and easy way to check whether or not all of the services that are set to start automatically are actually running? My first thought: Use the Get-Service cmdlet. Unfortunately it doesn't have a parameter Read more [...]

Can iSCSI Targets be Renamed on an EqualLogic PS Series Storage Area Network?

I received a tweet from someone a few days ago asking if it was possible to rename an iSCSI target on an EqualLogic PS Series Storage Area Network (SAN). I wasn't sure, but it was interesting enough to research and determine if it was possible or not. Based on a screenshot provided by this person, they wanted to change the default iSCSI target name prefix so new volumes that are created have a different target prefix. It's possible to change this setting using PowerShell, but not the GUI: Even Read more [...]

Want VM Reliability and Uptime? Hyper-V on Server Core

While at TechEd last month I heard two things that I've been preaching for a while. Server Core installation (no-GUI) is the recommended installation type beginning with Windows Server 2012. I've been saying this for a while when it comes to Windows Server 2008 R2. Server Core: Reliability and Uptime In each of three datacenters that I support there are multiple Hyper-V servers that run Windows Server 2008 R2 w/SP1 with the Core Installation (Server Core). These production servers have unbelievable Read more [...]

Use PowerShell to Determine What Roles are Added When Turning a Windows 2012 Server into a Domain Controller

Goal: Determine what roles are installed when turning a Windows Server 2012 machine into a domain controller. I started out by using PowerShell to save a list of what roles are installed on a plain vanilla 2012 server that has the full GUI installation. The following one liner would be used in PowerShell version 2 to accomplish this task and the syntax is compatible with version 3: PowerShell version 3 has simplified syntax when using the Where-Object cmdlet Read more [...]

Welcome to PowerShell Hell

I finally figured out why the error messages in PowerShell are in bright red. It's because it's the color of flames and/or red hot coals and it means you may be in PowerShell Hell. That's what recently happened when I updated the Antivirus on my PC from Eset NOD32 version 4 to version 5. A few days after updating, I was in PowerShell Hell as shown below: When trying to run Get-ChildItem against WSMan:localhost, I received the following: Get-ChildItem : WS-Management cannot process the request. Read more [...]

Places to Learn More About PowerShell at TechEd

Stop by the Scripting Guys booth in the Connect Zone area at Microsoft TechEd North America 2012 to learn more about PowerShell: Here's The Scripting Guy (Ed Wilson) at the Scripting Guys booth yesterday while he was talking about my guest blog on the Hey, Scripting Guys! Blog (displayed on the monitor): Also stop by the Windows Server 2012 Server Manager & PowerShell booth in the Technical Learning Center area: µ Read more [...]

PowerShell 3.0 Hands-On Labs at TechEd 2012

Thinking about learning the new features of PowerShell 3.0 at Microsoft TechEd North America 2012? If you're planning to get some hands on experience using the hands on labs, don't waste your time. I attempted to go through the WSV11-HOL "What's New in Windows PowerShell 3.0 " this morning: Only to find out the resolution (screen size) on the virtual machine is set too high to view the content: I also attempted the WSV12-HOL "Introduction to Windows PowerShell Fundamentals 3.0 ", but had the Read more [...]

Use PowerShell to Audit Logon Authentication Type

Want to know what type of authentication mechanism is being used when users log onto your servers? This script pulls the information from the event logs to determine how users are being authenticated. It uses Get-Winevent with the -FilterXPath parameter. That parameter and what the logon type numeric codes translate to are a couple of things that I haven't seen much documentation on. The script sorts by server name in ascending order and then by the time in descending order. I've Read more [...]