Find and Disable Active Directory Users with PowerShell Faster than You can Open the GUI

In this scenario, a support request has been escalated to you because the help desk is unable to find a user account in Active Directory that needs to be disabled. The help desk included a screenshot where they attempted to search for the user who is named "William Doe": The request you received also stated that the user is in the "Sales" department so you perform a quick search for users who have a last name of "Doe" and who are also in the "Sales" department:Based Read more [...]
Posted in Active Directory, PowerShell | Tagged , | 1 Comment

Extract the Name from an Active Directory Distinguished Name with PowerShell and a Regular Expression

This is actually something I had a small blurb about in my previous blog article, but I wanted to go back, revisit it, and write a dedicated blog article about it. Sometimes there are properties in Active Directory like the one in the following example where the "Manager" property is being returned as a distinguished name and what you really wanted was just their name (in human readable format):You could write a complicated function or script to query Active Read more [...]
Posted in Active Directory, PowerShell, Regular Expressions | Tagged , , | Leave a comment

From Dangerous Script Copy & Paster to Scripting Games Winner and now PowerShell MVP!

I've been working in Information Technology for 20 years this year and I've wasted more than half of my career in the GUI (Graphical User Interface) having to learn GUI's for numerous products and different versions of all those different products over the years, more products and versions than I can count. Back in the VBScript days, I was the dangerous script copy and paster. Then when Exchange Server 2007 shipped, I was forced to learn at least some PowerShell since there were many things that Read more [...]
Posted in PowerShell | Tagged | 4 Comments

Create Active Directory Users Home Folder and Assign Permissions with PowerShell

The following function is a work in progress, but I thought I would go ahead and share it. This function requires a module named PowerShellAccessControl that was created by Rohn Edwards which is downloadable from the TechNet Script Repository. The version 3.0 beta revision of his module which is also downloadable on that same page is what was used to test the examples shown in this blog article.The following example demonstrates creating  home folders and assigning Read more [...]
Posted in Active Directory, PowerShell | Tagged , | Leave a comment

Using PowerShell to Search for Specific Users in Active Directory without Knowing their Exact Information

You're looking for a user in your Active Directory environment who goes by the nickname of "JW". You know that's the user's initials and you need to find their AD user account. Typically you'd use the Identity parameter, but that parameter doesn't allow wildcards:Verifying wildcard's are not allowed on the Identity parameter of Get-ADUser:What you'll need to do is use the Filter parameter instead:The Read more [...]
Posted in Active Directory, PowerShell | Tagged , | Leave a comment

PowerShell Function to Prevent Starting Hyper-V VM’s that are Connected to an External Network

Beginning with Windows 8 (Professional and Enterprise Edition), Hyper-V is available on workstations that have a processor that supports SLAT (Second Level Address Translation). For specifics about the requirements, see the Client Hyper-V blog article on Microsoft TechNet. That means you have a Hypervisor running right on your desktop or laptop computer for free. With the price of hardware these days, your regular everyday computer can be spec'd out with an i7 processor, 16 gigabytes of memory, and Read more [...]
Posted in Hyper-V, PowerShell | Tagged , | Leave a comment

Determine the Last Day of the Previous Month with PowerShell

I recently had a need to determine the last day of the previous month with PowerShell. Unless I'm overlooking something, PowerShell doesn't natively have a way to determine this. Luckily, the System.Time class in the .NET Framework has a DaysInMonth method that returns the number of days in a specific month which effectively gives you the last day of the month. The command to determine what I needed was simple enough:I went ahead and created a well documented Read more [...]
Posted in PowerShell | Tagged | Leave a comment

PowerShell Version 5 New Feature: New Parameters added to the New-DscCheckSum and Test-DscConfiguration Cmdlets

I'm continuing on my series of blog articles on the new features in the preview version of PowerShell version 5. Today I'll be discussing the existing DSC (Desired State Configuration) cmdlets in PowerShell version 4 that now have new parameters as of the May 2014 preview version of PowerShell version 5. To begin, I'll define a DSC configuration that's parameterized so that it's reusable:Run the configuration specifying the computer names to create MOF files Read more [...]
Posted in Desired State Configuration, PowerShell | Tagged , , , | Leave a comment

PowerShell Version 5 New Feature: SkipLast Parameter added to Select-Object

I'm picking up where I left off in my last blog article on the new features in the PowerShell version 5 preview. Today I be covering a new parameter, SkipLast that has been added to the Select-Object cmdlet. I have a text file where I saved a list of the available packages in the default OneGet Chocolatey repository. There are a total of 1893 items in this file:I'll use the new SkipLast parameter to skip the last 1885 items:This Read more [...]
Posted in PowerShell | Tagged , | Leave a comment

PowerShell Version 5 New Feature: NoWait Parameter added to Stop-Service

I presented a session on "What's New in PowerShell Version 5?" at TechStravaganza in Atlanta this past Friday and there was a lot of information I wasn't able to get to because of the massive amount of information that I've compiled about the updates to PowerShell version 5 that are in the May 2014 preview version so I thought I would blog about them. He's a picture of me presenting at TechStravaganza in Atlanta this past Friday. The event was held at the Georgia Tech Research Institute Conference Read more [...]
Posted in PowerShell | Tagged , | 1 Comment

If (‘Interested’ -in ‘PowerShell’) {‘Are you Participating in the PowerShell.org Forums?’}

If you're interested in PowerShell and you're not participating in the forums at PowerShell.org, you're missing out on an awesome opportunity to learn from others instead of having to re-invent the wheel each time you need to accomplish a task. If you've been using PowerShell for a while and you're not participating in the forums, then you're missing out on an opportunity to help others who are asking for your assistance. Recently, a topic was posted in the forums about retrieving the fully qualified Read more [...]
Posted in PowerShell | Tagged | Leave a comment

Error when Using PowerShellGet Find-Module or Install-Module with the Name Parameter and a Local NuGet Repository

If you're following me on Twitter then you probably know that I've been working a lot with the new features in PowerShell version 5, with my focus being on the cmdlets in the OneGet and PowerShellGet modules. I've been fighting an issue where an error is received when the Name parameter is specified with Find-Module or Install-Module when using a local NuGet Repository: Find-PSGetExtModule : Module 'Pscx' was not found in the Gallery. At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PowerShellGet\PSGet.psm1:72 Read more [...]
Posted in PowerShell | Tagged , | Leave a comment