Get Domain from URL in Powershell
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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? $URL = "http://www.domain.com/folder/" (some sort of regex command here to convert/strip $URL into $DOMAIN using PowerShell) $DOMAIN = "domain.com" #<-- taken from $URL I've searched and I've found results for finding the IP address from a domain but I need to establish what the domain is first using regex (or another method). Any suggestions are great. 回答1: Try the Uri class: PS> [System