Articles

PowerShell articles, tutorials, and guides from community experts.

Terri Donahue

Special Charlotte PowerShell Group meeting on 4/22 featuring Lee Holmes

Charlotte hackers, our regularly scheduled meeting on April 2nd will not be occurring. Instead we will have our monthly meeting on April 22nd. Can you hear the drum roll in the distance? It will continue to build to a crescendo as April 22nd approaches. Lee Holmes will be speaking at the meeting.

In this highly interactive session, Principle PowerShell developer Lee Holmes shares some of his favorite PowerShell tips and tricks. Attendees are encouraged to share their favorite PowerShell tricks as well, and so the session should be both fun and educational.

Greg Altman
PowerShell for Admins

Home Labs for the IT pro

Every IT pro needs a lab. It’s not just the fact that we all have a little mad scientist in us, it’s a playground for experimentation and learning. By “lab” I do not mean a formal test or dev environment, but a much more informal setting that typically goes before the “dev” part gets started. This lab need not be expensive. A little creative repurposing and virtualization will go a long way towards getting started with a home lab.

Jacob Benson

March Omaha PowerShell User Group Meeting

This month we have several exciting things going on!  First, Trond Hindenes will be joining us via Lync from the great country of Norway for a presentation on Service Management Automation (SMA).  Trond is a Senior Consultant at Crayon who spends most of his non-snowboarding time working on Microsoft System Center, PowerShell, Active Directory, Virtualization and Microsoft Azure. You can find him onTwitter and on his website Trond’s Working!
Second, the first 30 minutes of this meeting will be used to announce the “official” formation of an Omaha System Center Users Group and to give attendees time to network with each other and talk to Matt, Kelly and Zac about the formation of the user group (if they are interested in learning more about it).  If you are interested in learning more about the Omaha Sytems Center User Group before the meeting you can find them on Twitter or you can email them omahascug@outlook.com .
We will attempt to record Trond’s presentation using Lync but no promises :).
Event Registration is here.

Steve
PowerShell for Admins

The fastest Powershell #1 : Count all users in Active Directory domain

Updated : October 01, 2015
** Question **: What is the fastest solution to count all the users in Active Directory domain?


** Answer **: To answer this question, I will compare 17 different commands in a domain with 75 000 users.

`[System.GC]::WaitForPendingFinalizers() [System.GC]::Collect() Set-Location -Path ‘C:\demo’ Add-Type -AssemblyName System.DirectoryServices.Protocols Import-Module -Name .\S.DS.P.psd1 Add-PSSnapin -Name ‘Quest.ActiveRoles.ADManagement’ $searcher = [adsisearcher]’(&(objectclass=user)(objectcategory=person))' $searcher.SearchRoot = ‘LDAP://DC=domain,DC=com’ $searcher.PageSize = 1000 $searcher.PropertiesToLoad.AddRange((‘samaccountname’)) function Get-QueryResult { [CmdletBinding()] Param ( [Parameter(Mandatory=$true)] [int]$Id ) switch ($id) { 1 { ( Get-ADUser -Filter ‘objectClass -eq “user” -and objectCategory -eq “person”’ -SearchBase ‘DC=domain,DC=com’ -Properties SamAccountName).SamAccountName } 2 { ( Get-ADUser -LDAPFilter ‘(&(objectclass=user)(objectcategory=person))’ -SearchBase ‘DC=domain,DC=com’ -Properties SamAccountName).SamAccountName } 3 { ( Get-ADObject -Filter ‘objectCategory -eq “person” -and objectClass -eq “user”’ -SearchBase ‘DC=domain,DC=com’ -Properties SamAccountName).SamAccountName } 4 { ( Get-ADObject -LDAPFilter ‘(&(objectclass=user)(objectcategory=person))’ -SearchBase ‘DC=domain,DC=com’ -Properties SamAccountName).SamAccountName } 5 { ( Get-ADObject -LDAPFilter ‘sAMAccountType=805306368’ -SearchBase ‘DC=domain,DC=com’ -Properties SamAccountName).SamAccountName } 6 { ( Get-QADUser -SearchRoot ‘DC=domain,DC=com’ -DontUseDefaultIncludedProperties -IncludedProperties SamAccountName -SizeLimit 0).SamAccountName } 7 { ( $searcher.FindAll() ) } 8 { (Find-LdapObject -SearchFilter:’(&(objectclass=user)(objectcategory=person))’ -SearchBase:‘DC=domain,DC=com’ -LdapServer:’’ -PageSize 1000 -PropertiesToLoad:@(‘sAMAccountName’)) } 9 { (Find-LdapObject -SearchFilter:‘sAMAccountType=805306368’ -SearchBase:‘DC=domain,DC=com’ -LdapServer:’’ -PageSize 1000 -PropertiesToLoad:@(‘sAMAccountName’)) } 10 { (Find-LdapObject -SearchFilter:’(&(objectclass=user)(objectcategory=person))’ -SearchBase:‘DC=domain,DC=com’ -LdapServer:’’ -PageSize 1000) } 11 { (Find-LdapObject -SearchFilter:‘sAMAccountType=805306368’ -SearchBase:‘DC=domain,DC=com’ -LdapServer:’’ -PageSize 1000) } 12 { (dsquery user -o samid ‘DC=domain,DC=com’ -limit 0) } 13 { (dsquery * -filter ‘(&(objectclass=user)(objectcategory=person))’ -attr samAccountName -attrsonly -limit 0) } 14 { (dsquery * -filter ‘sAMAccountType=805306368’ -attr samAccountName -attrsonly -limit 0) } 15 { ([regex]::match((.\AdFind.exe -b ‘DC=domain,DC=com’ -f ‘(&(objectclass=user)(objectcategory=person))’ -c),’\d{5}’).value) 2> $null } 16 { ([regex]::match((.\AdFind.exe -b ‘DC=domain,DC=com’ -f ‘sAMAccountType=805306368’ -c),’\d{5}’).value) 2> $null } 17 { ([regex]::match((.\AdFind.exe -b ‘DC=domain,DC=com’ -sc adobjcnt:user -c),’\d{5}’).value) 2> $null } } }

Terri Donahue

Charlotte PowerShell User Group Meeting–3/5/2015

We will be bringing you a presentation by Jason Walker, @AutomationJason, at our next meeting. Jason will be discussing the Anatomy of a DSC Resource. The session will dive into the anatomy of a DSC resource and will provide an understanding of what it takes to develop your own DSC resources.

Food and drinks will be provided. Everyone is welcome. Please RSVP on the MeetUp event page so we can plan food accordingly.

Don Jones
Announcements

PowerShell Summit Europe Registration

Registration for PowerShell Summit Europe will commence on February 27th, 2015 at roughly 12:01am server time (I believe the server is in a Pacific time Azure datacenter). We will be limited to roughly 100 attendees.
I want everyone to understand the basic rules of engagement for this. Setting up and running this event involves significant financial risk. While in this case the event venue, a Microsoft office in Kista (near Stockholm), Sweden, isn’t charging us huge fees and requiring us to commit to hotel rooms and the like, there is still risk. _Most of that risk is not borne by PowerShell.org, _but for the most part by myself, personally. Our speakers also commit to covering their own travel expenses (something we’re hoping to offset this year). In addition, PowerShell team members are taking time away from the product to attend, which is a huge logistical commitment because it’s such a relatively small team.
For the Europe 2014 event, we had very poor registration numbers almost until the last minute. We also had to work very hard to drum up topic submissions from European speakers. Those two facts worry us a lot, because it suggests that there isn’t a strong and engaged community interested in this event. If that’s the case, we don’t want to barge in and run the event at all. As a result, we’re going to be taking a pretty risk-averse approach this time, and I wanted to be up-front and forthright about it.
So: We’re going to evaluate the registration numbers and velocity in mid-April. By then, we need to see at least 20-30 registrations. (We usually achieve that in the first week of registrations for the North American event.) If we’re not hitting that level, then the event is subject to cancellation (and everyone will naturally get a full and complete refund).
Also know that, should we make it past that point, registration will end by August 15th 2015 or when we fill the available space, whichever comes first. In other words, last-minute registration won’t be a thing.
The success of this event **depends on the European members of the overall PowerShell community. ** You need to help get the word out. We aren’t going to be advertising, soliciting Microsoft’s help, or other techniques. This isn’t a commercial conference; it’s being done by the community and for the community - and if the community can’t make it happen, then it won’t happen.
Our agenda will be going online shortly, and you should head to http://PowerShellSummit.org to find the registration links (after reading the introductory material, click “Europe 2015” for details). We’ll get it all posted and ready for February 27th - it won’t be live until then. **Help us get the word out. **Tell co-workers. Use Twitter, Google+, and Facebook. Attend user group meetings and spread the word. We’ve got about 6 weeks to get 20-30 people signed up to make sure we’re covering base expenses and making this happen.

NJPowerShell
PowerShell for Admins

NJ PowerShell UG Meeting March 5th: Presenter Adam Bertram

The NJ PowerShell User Group is having a meetup on Thursday, March 6th from 6:00 - 8:00 PM.  The first half hour will be for socializing, pizza, and playing pool at our coffee bar. 

Registration: EventBrite  You must register to attend in person.

Agenda:

                6:00 – 6:30: Pizza and socializing

                6:30 – 7:30: Presentation

                7:30 - 8:00: Q & A

Please note that the Webex meeting will start at 6:00 PM, but the actual presentation won’t start until 6:30

Don Jones
Announcements

Design the Next Scripting Games

We have some folks working on the next Scripting Games… but we want some feedback from the community to make sure we’re offering something of value.
The current plan is to run a series of events, with both Beginner and Intermediate tracks. There will be no “advanced” track; the feeling is that, if you’re advanced, you should be helping out by judging ;). Events will be constructed as a combination of puzzles and real-world tasks, meaning some things will simply test your PowerShell skills, while others will test them in a more production-applicable way.
What we need from the community is some sense of what you want to get from the Games. However, before you reply, understand what is NOT on the table: we will not be running an event where every entry gets personal commentary or feedback from an expert judge. It simply isn’t practical - everyone doing the judging has a full-time job, and offering personal feedback just isn’t feasible.
What COULD be on the table is offering a numeric score from a judge, based on the completeness of your entry and what the judge thinks of it. However, if it’s a low score, you’re not going to be told why (“no commentary,” see above). So we’re not sure that numeric scores are useful.
One proposal has been to post the events, and have judges select both good ones and less-good ones to write about. In other words, provide commentary on the outstanding entries, but not EVERY entry. Individual entries wouldn’t receive a score, but you could certainly compare what you did to the outstanding ones that did receive commentary. The idea here is to give you a task on which to test your skills, and to provide some educational feedback on some representative entries. The fact is that, in any given task, we tend to see a lot of similar-looking entries anyway, so hopefully taking some of them and commenting (both positively and constructively) will help everyone “judge” their own entries and improve their skills.
After trying numerous approaches to the Games over the past years, and after listening closely to people’s feedback, we’re trying to come up with something that is both useful and do-able.
What do you think of that proposal? Or, would you offer another proposal for us to build the Games around? Keep in mind - any proposal that suggests “expert commentary on every entry” will simply have to be turned down outright. After major discussion, we simply can’t commit to it. We’ll leave this open for the month of February 2015 - discuss away!
Add to the discussion in the Forums. Login required; not accepting comments on this post.

Terri Donahue

Charlotte PowerShell User Group 2/5/2014

It has been quite a busy past couple of months and we have not had our monthly get-together. We are working to get back on track and will start in February. This month, I will be discussing IIS and PowerShell at our meeting. For those of you that do not know me, I am an IIS MVP and a PowerShell hack. I would like to tailor the discussion, demos, and examples to address specific questions or needs that the members have. You can also check out my powershell specific blogs here. Feel free to tweet to @owterri with any content requests that you have.