Get your public IP Address with PowerShell

Hello,

Not very useful, but, if you ever need to know your public internet IP address, you can use :

Function Get-MyPublicIP {
(Invoke-WebRequest -Uri ifconfig.me).RawContent -match "b(?:d{1,3}.){3}d{1,3}b" | Out-Null
$matches | select -ExpandProperty Values
}
Get-MyPublicIP

 

0 thoughts on “Get your public IP Address with PowerShell

  1. Hi M.DEMILLIERE,

    The website you use (ifconfig.me) seems to be down.
    You can replace it with ifconfig.co directly on your function

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.