Category: PowerShell

Using PowerShell to Ace the Scripting & Regular Expression Interview Question

Last week I saw a tweet that referenced a couple of interesting articles on interview questions for programmers. I'm no programmer, but one of them (Steve Yegge's The Five Essential Phone-Screen Questions) had an interesting question about identifying which of 50,000 web pages had phone numbers in them. You have to identify all of the web pages with phone numbers hard coded in them. All of the web pages are HTML files in a directory tree under a folder named website. The phone numbers are in the Read more [...]

Confusion on PowerShell Parameterized Functions

I've run into an issue with PowerShell functions that I don't understand. I guess my confusion is most of the examples I've found online and in books don't work the way the authors explained (at least not for me). The problem is when I define a parameter inside a function, that parameter is not accessible when running the script. When I move the parameter outside of the function, it's accessible and it works without issue. I'm guessing this is because of Read more [...]

Where Do I Find This Thing Called PowerShell?

If you’re running Windows 7, you already have PowerShell 2.0 installed. It’s located under “All Programs > Accessories > Windows PowerShell”. I’m running a 64bit version of Windows 7 so I have both 64bit and 32bit (x86) links in my start menu. I prefer the PowerShell ISE (Integrated Scripting Environment) as apposed to the PowerShell Console. I use the 64bit version and have never run into an issue where I needed to use the 32bit (x86) versions. According to the Microsoft Support Read more [...]

Get-WmiObject : The RPC Server is Unavailable. (Exception from HRESULT: 0x800706BA)

This week while working with some PowerShell scripts that retrieve WMI information from remote servers, I ran into an issue where I was able to return results from Windows 2008 R2 servers without issue but was unable to return results from Windows 2008 (non-R2) servers even though they had PowerShell 2.0 installed and as far as I could tell they were configured exactly the same as the Windows 2008 R2 servers. Here's the error I received: Get-WmiObject : The RPC server is unavailable. (Exception Read more [...]

Your Search Cannot Be Completed Because This Site Is Not Assigned To An Indexer.

Your attempting to search a SharePoint 2010 Site (Foundation Edition) and you receive the following error message "Your search cannot be completed because this site is not assigned to an indexer." Search has never been configured for this SharePoint farm so we'll be configuring it from the ground up. First you'll need two service accounts, one for the search service to run as and one for the actual crawling. Todd Klindt has a great blog on service accounts that I use for reference. I used the Read more [...]

Set EqualLogic PS Series SAN Volume ACL’s using PowerShell

Query and return the current Access Control List (ACL) for an EqualLogic PS Series SAN volume named "mikefrobbins" using PowerShell: You can see the same information using the GUI: Remove the current ACL’s using the following PowerShell command: Once again, you can see the same information using the GUI: Add new ACL’s using the following PowerShell command: You can also Read more [...]

Unable to Grant Domain Local Groups Full Access Permission to a Exchange 2010 Mailbox using the GUI

John Doe is a user in your Active Directory environment (Windows Server 2008 R2 Forest Function Level) with a mailbox on the email server (Exchange Server 2010 with SP2): You want to grant a domain local group named "Test Group" the full access permission to John Doe's mailbox: You attempt to grant this permission by selecting "Manage Full Access Permission" from the Exchange 2010 Management Console: When you click add and search for the group, it doesn't appear: PowerShell to Read more [...]

Open a SharePoint Document Library with Windows Explorer

When attempting to open a SharePoint document library from a machine running Windows Server 2008 or 2008 R2 by using the “Open with Explorer” button as shown in the image to the right, you receive:  “Message from webpage > Your client does not support opening this list with Windows Explorer.”: To resolve this problem, enable the “Desktop Experience” feature on the machine you are attempting to open the document library from (the client machine): You can also enable the "Desktop Read more [...]

Add an Additional Web Front-end Server to an Existing SharePoint 2010 Farm using PowerShell

You've followed the instructions in my other three blogs and built a SharePoint 2010 farm (not a stand-alone installation) with one or more web front-end servers. Per one of the notes in a TechNet article I found:  “As a best practice, we recommend the operating system on the new server should be at the same service pack level and have the same security updates and other hotfixes as the existing farm servers.”  This article also shows the steps that I’ll be demonstrating in this blog. All Read more [...]

Reset the SharePoint 2010 Passphrase with PowerShell

You’re attempting to add an additional web front-end server to your SharePoint 2010 farm and find out the passphrase you've documented is incorrect or it isn't documented. Resetting the passphrase is a fairly simple process. Open PowerShell and execute the following script. Enter the new passphrase when prompted: Most other blogs on this subject use the code shown in the image below, but why would you want the password to be shown in clear text when Read more [...]

Installing SQL Server Denali CTP3 on Server Core

One of the new features in SQL Server Denali CTP3 is support for installation on Server Core. There’s an MSDN article on “Installing SQL Server Denali on Server Core” and another MSDN article on "Install SQL Server Denali from the Command Prompt" that has a detailed list of all the different parameters. Based on the first article, the setup routine should enable and/or install all of the necessary prerequisites, but that simply isn’t the case from what I found. If you just run setup Read more [...]

Check the Time on Remote Machines with PowerShell

I ran into an issue lately where the domain controller that hosts the PDC emulator FSMO role for the forest root domain became unavailable and the time for several machines in the domain was far enough off to start causing kerberos related security problems. Here's a simply Powershell script to query the time on remote machines via WMI. You could use Invoke-Command with Get-Date, but that takes too long compared to just using WMI. I chose to hard code the names I wanted to query directly into Read more [...]

Terminal Server Related PowerShell Scripts

Thought I would post a couple of PowerShell scripts that I’ve recently written. Both of these scripts were written specifically for terminal servers but they can be modified as needed. The first one finds what terminal servers a user is logged into. It retrieves a list of terminal server names from the specified OU. I started out by using the Get-TSServers cmdlet for the list of servers, but that cmdlet takes a while and you have more control by just using the Get-ADComputer cmdlet since your Read more [...]

Find AD User Account Lockout Events with PowerShell

A few weeks ago a user contacted me and stated they were constantly being locked out throughout the day. This could have been caused by a number of things from someone else trying to log in as them to being logged in somewhere else, changing their password and the session with the old password still being active. I ran a search of the security event log on the domain controllers and found the name of the machine that the user was being locked out from. The event ID for lockout events is 4740 for Read more [...]

Create AD Group and Copy a Group’s Members with PowerShell

This week, I was asked if I could export a list of users who were members of a specific group in Active Directory. My Question: What's this list for? Answer: We're working on a project that requires us to create a new security group in Active Directory and we're going to add all the users on the list to the new group. I determined that this new group really was necessary. My response: I can do even better than providing you guys with a list. I can create the new AD group, output a list of users, Read more [...]