Creating NIC team without knowing the team members

I was asked how to create a NIC team only using the 1GB adapters without knowing how many 1gb NICs were on the server.


I think this should solve the problem


New-NetLbfoTeam -TeamMembers (Get-NetAdapter | where Speed -ge 1gb | select -ExpandProperty Name) -Name MyTeam


Use New-NetLbfoTeam to create the team. The team member names are generated by


Get-NetAdapter | where Speed -ge 1gb | select -ExpandProperty Name


By putting that statement in parentheses as the value for the –TeamMembers parameter the results are used as the value for the parameter.  Shouldn’t matter now how many NICs or what they are called.  You can modify the filter criteria as required.

Posted in Networking, PowerShell V3, PowerShell v4 | Leave a comment

PowerShell books = Deal of the Day

Manning’s Deal of the Day for 18 November 2014 includes PowerShell in Depth, second edition and PowerShell and WMI

Posted in Books, Powershell | Leave a comment

PowerShell is 8 years old this month

Strange as it may seem PowerShell 1.0 was release in November 2006. In that time we’ve had a lot of changes:

- PowerShell support added to all major Microsoft products – except Office!

- Third party adoption of PowerShell – I am now disappointed if a product doesn’t have PowerShell support rather than being surprised that it does


Version 2.0

- PowerShell remoting

- Background jobs

- More WMI cmdlets

- More cmdlets


Version 3.0

- CIM cmdlets

- CIM sessions


- PowerShell workflow


Version 4.0

- Desired State configuration


Version 5.)

- Oneget

- PowerShell get


The PowerShell community has grown phenomenally:


- PowerShell Summits in North America & Europe

- User groups across the world


Really looking forward to the next 8 years

Posted in Powershell | Leave a comment

PowerShell in Depth, second edition in print

I received my copies of the print version of PowerShell in Depth, second edition today.  Amazon shows it being available in a couple of days


Posted in Books, Powershell | Leave a comment


The ability to create transcripts of your PowerShell activity is great for keeping track of what you’ve done. They are also very useful when testing as you can keep a record of your results. 

There’s one problem though – transcripts don’t work in the ISE.  Try this in PowerShell 4.0 or earlier:

Start-Transcript -Path C:\Temp\tran1.txt

You’ll get an error like this:

Start-Transcript : This host does not support transcription.
At line:1 char:1
+ Start-Transcript -Path C:\Temp\tran1.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotImplemented: (:) [Start-Transcript], PSNotSup
    + FullyQualifiedErrorId : NotSupported,Microsoft.PowerShell.Commands.Start

Your script will run then you’ll get another error:

Stop-Transcript : This host does not support transcription.
At line:3 char:1
+ Stop-Transcript
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : NotImplemented: (:) [Stop-Transcript], PSNotSupp
    + FullyQualifiedErrorId : NotSupported,Microsoft.PowerShell.Commands.StopT


Now try the same in PowerShell 5.0 and you’ll get this:

Transcript started, output file is C:\Temp\tran1.txt


Your script will run and you’ll see this at the end:

Transcript stopped, output file is C:\Temp\tran1.txt


Your transcript file will will be created and contain the desired output.

Another useful addition to your PowerShell tool kit – transcripts now work in ISE

Posted in PowerShell v5 | Leave a comment

PowerShell classes – - static classes

A static class is one that you don’t need to create  an instance of the object to use – the [math] class provides many examples e.g.

£> [math]::pi

You can create a class with static methods using PowerShell classes:

class stest {

static [int] doubleup ([int] $in){

return $in * 2


Its used like this:

£> [stest]::doubleup(2)

Where could you use this – possibly to resolve look up values for instance when decoding WMI integer values or if you have a series of calculations you’ll be using in several select statements

Posted in PowerShell v5, WMFv5 | Leave a comment

WMI integer properties – alternative decoding options


WMI has many properties where the the value is an integer:

£> Get-CimInstance -ClassName Win32_LogicalDisk | Format-Table DeviceId, DriveType, Size, FreeSpace -a

DeviceId DriveType         Size    FreeSpace
——– ———         —-    ———
C:               3 135810510848 120492625920
D:               5


In the example drive type 3 is a standard hard disk and drive type 5 is defined as a compact disk



Remembering these can be a pain – there are a couple of ways to decode these values.


You could use a hash table – I showed many examples of this in PowerShell and WMI –


$dtype = DATA {ConvertFRom-StringData -StringData @’
3 = Hard Drive
5 = Compact Disk
Get-CimInstance -ClassName Win32_LogicalDisk |
Format-Table DeviceId, DriveTYpe, @{N=’TYpe’; E={$dtype["$($_.DriveType)"]}}, Size, FreeSpace –a



DeviceId DriveTYpe TYpe                 Size    FreeSpace
——– ——— —-                 —-    ———
C:               3 Hard Drive   135810510848 120495980544
D:               5 Compact Disk



Define the hash table via ConvertFrom-StringData . You can then just use the hash table as a look up to convert the numeric value of drive type into a descriptive name.

With WMF 5.0 and PowerShell classes there is another option


enum dtype {
HardDrive = 3
CompactDisk = 5

Get-CimInstance -ClassName Win32_LogicalDisk |
Format-Table DeviceId, DriveTYpe, @{N=’TYpe’; E={[dtype]$($_.DriveType)}}, Size, FreeSpace –a


DeviceId DriveTYpe        TYpe         Size    FreeSpace
——– ———        —-         —-    ———
C:               3   HardDrive 135810510848 120496607232
D:               5 CompactDisk


Create a enumeration using the enum keyword. The descriptive text CANNOT have spaces (delimited strings don’t work either). You can then substitute the enum value into your calculated field.

Posted in PowerShell and WMI, PowerShell v5 | Leave a comment