Skip to content

PowerShell v2.0 Compliance Issue - Bitwise Shift Operators #32

@cobbr

Description

@cobbr

It seems as if a bitwise shift operator, -shl, is being used in Test-Subnet:

function Test-Subnet ([string]$cidr, [string]$ip)
{
    $network, [int]$subnetlen = $cidr.Split('/')
    $a = [uint32[]]$network.split('.')
    [uint32] $unetwork = ($a[0] -shl 24) + ($a[1] -shl 16) + ($a[2] -shl 8) + $a[3]

    $mask = (-bnot [uint32]0) -shl (32 - $subnetlen)

    $a = [uint32[]]$ip.split('.')
    [uint32] $uip = ($a[0] -shl 24) + ($a[1] -shl 16) + ($a[2] -shl 8) + $a[3]

    $unetwork -eq ($mask -band $uip)
}

This shift operator is PowerShell 3.0+ only. Which breaks PowerUpSQL on PowerShell v2.0 :(

Have a PR coming in shortly that should make this PowerShell v2.0 compliant :)

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions