ipcalc in powershell

Last day I wrote how to do it in AIX or Linux ip calc with ifconfig

It isn’t that different in PowerShell, the fun is to the calculation yourself. For translating in 0, we can use [IPADDRESS].

Let’s try‚Ķ

$ip = [IPADDRESS](
(Get-NetIPAddress -AddressFamily "IPv4" -InterfaceAlias "Ethernet*").

$prefix = (
Get-NetIPAddress -AddressFamily "IPv4" -InterfaceAlias "Ethernet*").

The length and the ip of the current interface. In my case I have only one

PS> $ip
Address : 1677830336
AddressFamily : InterNetwork
IPAddressToString :
PS> $prefix

with a prefix length of 24, we need a netmask of 24 bits


which is

11111111.11111111.11111111.11111111 --> 2^32-1
11111111 --> 2^(32-24)-1

to do the math

IPAddressToString :

let’s bitand

$netid = [IPADDRESS]($ip.Address -band $netmask.address)
IPAddressToString :

By Laurent Schneider

Oracle Certified Master


  1. could you please help me to write a code to use dbms_datapump to export only partitions older than n days

Leave a comment

Your email address will not be published.