Get Domain from URL in Powershell

前端 未结 3 2031
旧时难觅i
旧时难觅i 2021-01-01 12:24

I\'m looking to strip out the domain in this scenario using PowerShell. What is the most effective method to get \'domain.com\' out of the following variable?



        
3条回答
  •  [愿得一人]
    2021-01-01 13:27

    Like this:

    PS C:\ps> [uri]$URL = "http://www.domain.com/folder/"
    PS C:\ps> $domain = $url.Authority -replace '^www\.'
    PS C:\ps> $domain
    domain.com
    

提交回复
热议问题