I did find a lot of examples about how to convert CIDR to a network mask, but not the other way around (at least not using PowerShell).
So getting the data to start working which is easy
$ActiveNic = Get-CimInstance Win32_NetworkAdapterConfiguration | where IPEnabled
[IpAddress]$MyIp = $ActiveNic.IPAddress[0]
[IpAddress]$MyMask = $ActiveNic.IPSubnet[0]
[IpAddress]$NetIp = $MyIp.Address -band $MyMask.Address
Then I need to convert the mask and start counting the 1 which I've already got an answer for below.
But are there any better ways that are still easy to understand?
My own take..