如何从给定的URL解析基本路径?
给定一个这样的 URL: https://xyzt-pbi.co.com/reports/powerbi/Platform%20Status%20Reports/MSAS%20PBI%202019%20v10
我如何在 powershell 中解析服务器,换句话说,我只想要这部分: xyzt-pbi.co.com
回答
转换为[uri]( System.Uri) 并访问结果实例的.Host属性:
PS> (
[uri] 'https://xyzt-pbi.co.com/reports/powerbi/Platform%20Status%20Reports/MSAS%20PBI%202019%20v10'
).Host
xyzt-pbi.co.com