Painlessly Get Data from PowerShell to Excel
Doug Finke has written an awesome article - complete with a module! - to help get data into Excel spreadsheets.
Doug Finke has written an awesome article - complete with a module! - to help get data into Excel spreadsheets.
When Microsoft first released the DSC Resource Kit (in Wave 10 as of this writing), they opened the door to community contributions. Our own PowerShell.org GitHub repo consists partly of DSC resource that used Microsoft’s code as a baseline, and then corrected problems or expanded capabilities.
What we never had was a way for Microsoft to circle back, pick up those enhancements, and include them as part of an official future Resource Kit Wave. Now, we do.
The NJ PowerShell User Group is having a meetup on Tuesday, April 28th from 6:00 - 8:00 PM. The first half hour will be for socializing, pizza, and playing pool at our coffee bar.
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. In-Person a ttendees must register, print out their EventBrite ticket, and present it at the door. Walk-ins will not be permitted.
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.
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 } } }
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
The NJ PowerShell User Group is having a meetup on Thursday, January 8th from 6:00 - 8:00 PM. If interested, please register through the Eventbrite website to track attendance for ordering pizza. For those attending online (Webex) we will send a follow-up email with the meeting link based on Eventbrite online registrants. 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
In-Person attendees must register, print out their EventBrite ticket, and present it at the door. Walk-ins will not be permitted.
At the 2nd of October, Lee Holmes gave a presentation about the current and future state of the Windows Management Framework (WMF) during the Dutch PowerShell User Group (DuPSUG) at the Microsoft headquarters in The Netherlands.
The slide decks and recorded videos will be made available soon, but this is what was discussed:
The release cycle of the Windows Management Framework (WMF)
Faster incremental releases of preview versions are being released. This rapid development means that companies that need specific new functionalities to tackle current problems they’re having, don’t have to wait as long as they had to in the past.
Everyone should keep in mind that documentation for preview versions can be more limited, but should still read the release notes carefully. They contain descriptions of some of the improvements that are discussed in this blog post, but also cover other things that aren’t discussed here. Also be sure to take a look at What’s New in Windows PowerShell at TechNet.
A request from the audience was to include more helpful real-life examples until documentation is fully up-to-date.
Aside from classes and new DSC features, which I’ve already written about, there are a number of less-headline, but still-very-awesome, new capabilities.
This article is based on the September 2014 preview release of WMF 5.0. Information is highly subject to change.
First up is the **ability to automatically create PowerShell cmdlets from an OData endpoint. **Huh? OData is a kind of web service (basically); PowerShell gains the ability to look at the endpoint and construct a set of proxy cmdlets that let you interact with the endpoint more naturally. This is spiritually similar to what PowerShell can already do for a SOAP web service endpoint.
Next are some 7-years-overdue cmdlets for managing ZIP files: Compress-Archive and Expand-Archive. Finally. These use underlying .NET Framework ZIP functionality (I think), which has had some compatibility problems in the past, so we’ll see how these hold up. But they should be the missing link to letting you do everything DSC-related right in PowerShell, since you can now ZIP up your custom resources for deployment via pull server.
Auditing gets a huge win, and this is really more of a headline feature than people think. For one, the ISE now supports transcript creation. Yay! You can also “nest” transcripts, meaning you can have one running, and then start a second one to cover only a portion of time. Closing the second one lets the first remain running. You can also specify a central transcript directory, which is useful when you want to collect these things into a central folder for reporting. For example, you should now be able to set up Remoting endpoints that automatically kick off a transcript when someone connects, and saves them to that central location.
More auditing comes in the form of Group Policy settings. You’ve always been able to log the fact that certain commands were run (did you know that?), but now you can enable detailed script tracing that logs a crapload of detail to the PowerShell operational log (which can, like any other event log, be forwarded to another server). You get the complete details of every script block executed, even if it creates another script block. Again, this is set up in Group Policy - check out the WMF 5.0 release notes for the location.
Ed Snowden gets a face slap with new Cryptographic Message Syntax (CMS) cmdlets, including Get-CmsMessage, Protect-CmsMessage, and Unprotect-CmsMessage. These use PKI to encrypt data. By the way, **if your organization doesn’t already have an internal PKI, WTF are you waiting for, you’re ten years behind the curve, man. **PKI becomes more important to Windows environments every single day, and you need to get with the program.
There’s also a new **fun feature for extracting content from strings. This system uses some Microsoft Research functionality called FlashExtract. Essentially, you give it examples of what your data looks like, and then point it to a big string (like a text file) full of data. It can extract all the data pieces based on your example. It’s early days for this technology, but it’s kind of awesome to see the PowerShell team giving us an easy way to play with it.
Because WMF 5.0 introduces PowerShellGet, **it now includes commands to add PowerShellGet repositories. That means you can stand up your own repo, host your modules there, and install modules by simply running Install-Module (or find them using Find-Module). Tres awesome! We don’t yet have technical details on what the heck a PowerShellGet repository actually looks like, but I’m sure that’ll crop up.
ARE YOU PLAYING WITH WMF 5.0 ON A NON-PRODUCTION VM YET? YOU SHOULD BE. Times are changing and you gotta keep up!
When Desired State Configuration (DSC) came out - gosh, just about a year ago - I kept telling people that there was more to come. And a lot of it is now just around the corner in PowerShell v5.
This article is written to the September 2014 preview release - things may change for the final release.
A major set of changes in DSC is a much more detailed and granular configuration of the Local Configuration Manager (LCM), the local “agent” that makes DSC work on the target node. This new level of configuration really shows you where Microsoft’s thinking is.
For example, a single target node can be configured _to pull configurations from multiple pull servers. _That doesn’t necessarily mean separate _machines, _as a single IIS instance can host multiple websites, but it means you’re no longer limited to one MOF per computer.
Yes, I said that. The LCM can now pull (but not have pushed to it) _partial configurations. _Each partial configuration is a MOF, but the understanding is that there can be more than one. There’s still no dynamic evaluation of which MOFs will be pulled; you have to specify them all in the LCM configuration, but now you can break a machine’s total configuration into multiple bits. Each partial configuration is given a source, which is a pull server.
Each partial configuration can be given exclusivity over certain resources. This helps avoid overlap. For example, you might decided that Partial Config A has exclusive control over all xIPAddress settings, meaning those settings from any other partial config wouldn’t work. Partial configurations can also depend on each other, so that (for example), Partial Config B won’t even run until Partial Config A is complete.
The LCM can also have a separate server configured for web- or file-based resource repositories, meaning those can be separated from the pull server endpoint.
What used to be called the “compliance server” is now simply the reporting server - we mentioned in “The DSC Book” that the name of this would likely change. It’s now a distinct configuration item, meaning even a node in Push mode can report its status to the reporting server!
New global synchronization capabilities also exist. A node’s configuration can be made dependent on _a configuration item from another node. _Meaning, Node “A” won’t try to configure until Node “B” completes certain items first. Communications is all via WS-MAN and CIM.
A new Get-DscConfigurationStatus returns a high-level status for a node - similar to what the reporting server would collect - and an amazing new Compare-DscConfiguration can now accept a configuration and tell you _where a given node differs. _This is a big deal, and something a lot of folks wanted in PowerShell v4. There’s also an **Update-DscConfiguration, **which forces a node to evaluate its DSC stuff right away.
DSC is quickly coming of age. In less than a year, we’ve seen (so far) 6 releases of additional resources, and now with PowerShell v5 we’re seeing a number of important enhancements and evolutions in the core technology. Many of the things that frustrated folks initially are now taken care of.
Try adjusting your search terms or browse all content.