If you have a collection of objects
$proc = get-process
you can get the number of members using the Length property
$proc is of type System.Array
IsPublic IsSerial Name BaseType
——– ——– —- ——–
True True Object System.Array
MSDN documenattion is at https://msdn.microsoft.com/en-us/library/system.array(v=vs.110).aspx
PowerShell also adds a Count property that is an alias of Length
if you are after the number of members in a collection via the pipeline you need to use the Measure-Object cmdlet
PS> $proc | Measure-Object
Count : 71
or measure directly
PS> Get-Process | Measure-Object
Count : 71
Notice that Measure-Object can also be used to discover other statistics – the Average, Sum, Maximum and Minimum. These only work for numeric properties.
This is worth a read
It discusses the evolution of Windows server and PowerShell. Read it in conjunction with the videos of Jeffrey Snover’s talks at WinOps and the European PowerShell conference this year.
Support for the WMF 5.0 preview is ending – https://blogs.msdn.microsoft.com/powershell/2016/05/23/end-of-support-for-windows-management-framework-wmf-5-0-production-preview-is-approaching-upgrade-to-rtm-bits/
Want to see what PowerShell 5.1 looks like?
Install Windows Server 2016 TP 5 or get on the fast ring for Windows 10 Insider Previews. The latest build – 14352 shows a PowerShell version of 5.1.14352.1002 with Powershell 1.0 through 5.0 as compatible versions
The WSMAN stack is still version 3.0 so no issues with remoting or CIM sessions between PowerShell 3.0, 4.0, 5.0 and 5.1
PowerShell 2.0 will have the CIM session issue as it uses WSMAN stack 2.0 and PowerShell 1.0 didn’t have remoting
The slides and code from my WinOps 2016 talk can be found here:
After rebuilding my test machine for Server 2016 (with mixed results) I needed to add a DHCP scope to the environment. I blogged about the DHCP PowerShell module several years ago.
To quickly add a DHCP scope to the current server
Add-DhcpServerv4Scope -Name ‘Manticore Scope’ `
-StartRange 10.10.54.2 -EndRange 10.10.54.30 `
-Description ‘Scope for Manticore domain’ `
-Type DHCP -State Active -SubnetMask 255.255.255.0 `
-LeaseDuration (New-TimeSpan -Days 2)
Set-DhcpServerv4OptionValue -ScopeId 10.10.54.0 -DnsServer 10.10.54.201
I’ll save this as I’ll have to rebuild the machine when Windows 2016 RTM’s and possibly again if I can’t get the wireless adapter to work then.
Having finished the current round of conference speaking I needed to upgrade my system to Windows 2016 TP5. I’m using a 6 year old Lenovo W510 system.
First problem is that I couldn’t get the wireless adapter working – after a lot of searching I saw a post with a similar issue due to the Wireless LAN Service which you need doesn’t install correctly. Server Manager and Get-WindowsFeature both show it as installed but the wlansvc service isn’t available – doesn’t show in in the services GUI or through Get-Service.
Telephone activation is a pain but works BUT if an internet activation fails you don’t get the telephone option.
saved the day.
Basically type SLUI 4 in the run dialog to open the manual activation dialog.
Hope this is fixed for RTM otherwise I’ll need a new machine.
During the WinOps conference – http://winops.org/ – I attended a session on DevOps culture. At one point the discussion got on to skill sets.
I introduced the concept of the Y shaped skillset.
You should have a deep understanding on at least one area – C# development, Active Directory, web development, Exchange management – whatever it is you should a ‘go to’ person for that area. That’s represented by the down stroke of the Y
In addition in a devops world you ideally need a bunch of skills that span the devops range. At the top you should have a broad understanding across the range of skills – at least enough to have sensible conversations with other practitioners. Those skills can be backed up with a few areas that complement your main skill as you drop deeper into the Y.
Over time you may see your main skill set change and what was your primary skill migrate into a secondary area to be replaced by something else.
Next time you’re wondering what to learn – think of this model and think about what skills you need to add to complement and build on your current skill set
I discovered that there are 2 container image providers available through the PowerShell gallery.
In TP4 I used the ContainerProvider provider. That still exists BUT only supplies the TP4 images
PS> ContainerProvider\Find-ContainerImage | ft -a
Name Version Source Description
—- ——- —— ———–
NanoServer 10.0.10586.0 Container OS Image of Windows Server 2016 Technical Preview 4 : Nano Server Installation
WindowsServerCore 10.0.10586.0 Container OS Image of Windows Server 2016 Technical Preview : Windows Server Core Installation
If you want the TP5 images you have to use the ContainerImage provider
PS> ContainerImage\Find-ContainerImage | ft -a
Name Version Source Summary
—- ——- —— ——-
NanoServer 10.0.14300.1010 ContainerImageGallery Container OS Image of Windows Server 2016 Technical Preview 5 : Nano Server I…
WindowsServerCore 10.0.14300.1000 ContainerImageGallery Container OS Image of Windows Server 2016 Technical Preview 5 : Windows Serve…
This isn’t very satisfactory and will cause lots of confusion in the long term. I just hope we’re not getting a new provider with every new version of Windows 2016
Cloud Native Applications is a collection of hand-picked chapters presenting five topics that will give you insights into the world of cloud computing. The link is here: https://bit.ly/1T46wP7
This is excellent value – its FREE.
You’ll find chapters on:
Amazon Web Services