Type conversion treats an existing value as a specified type, sometimes producing a new object. In PowerShell, casting a URI-shaped string with [Uri] turns it into a System.Uri object with useful properties such as Host, Port, and Scheme. section 11.2
Use these forms when working with different types:
- Use -as to attempt conversion: 1000 / 3 -as [int]. Converting to an integer rounds the fractional value rather than simply truncating it. section 26.2.1
- Place the value before -as and the target type in brackets, such as [string], [xml], [int], [double], or [datetime]. section 26.2.1
- Use -is when you only need a True or False type check, such as "SRV02" -is [string] or (Get-Date) -is [datetime]. section 26.2.1
Convert a URL into a Uri object
Run [Uri]"https://github.com". PowerShell displays the resulting object's URI properties, including Scheme=https, Host=github.com, Port=443, and AbsoluteUri=https://github.com/.




















