腾讯云Windows服务器获取os-name

2023-05-24 16:46:51 浏览数 (1)

代码语言:javascript复制
(Invoke-WebRequest 'http://169.254.10.10/meta-data/instance/os-name' -UseBasicParsing).Content
或者
$url = "http://169.254.10.10/meta-data/instance/os-name"
$webRequest = [System.Net.WebRequest]::Create($url)
$webResponse = $webRequest.GetResponse()
$streamReader = New-Object System.IO.StreamReader($webResponse.GetResponseStream())
$content = $streamReader.ReadToEnd()
$streamReader.Close()
$webResponse.Close()
$content

0 人点赞