将App Service VM中的控制台输出提取到本地PC

时间:2017-02-27 07:46:07

标签: powershell powershell-v4.0 azure-powershell

我想获取HTML本地输出$htmlpart。如何在“试用”部分编码?

步骤

  • 登录Kudu https://(App Service name).scm.azurewebsites.net/
  • [Debug Console],[PowerShell]
    • https://(App Service name).scm.azurewebsites.net/DebugConsole/?shell=powershell
  • 运行一行命令,如:
    • (Get-Item D:\home\site\wwwroot\bin\Microsoft.Data.OData.dll).VersionInfo
  • 将结果作为对象获取并转换为$htmlpart

预期输出(HTML格式)

ProductVersion   FileVersion      FileName
--------------   -----------      --------
5.6.4.62175      5.6.4.62175      D:\home\site\wwwroot\bin\Microsoft.Data.OD...

尝试

$username = "(username)"
$password = "(password)"
$secpassword = ConvertTo-SecureString -String $password -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential($username, $secpassword)
Add-AzureRMAccount -Credential $Credential
Write-Output "Done: Add-AzureRMAccount"

$appservicename = "(App Service Name)"
$command = '(Get-Item D:\home\site\wwwroot\bin\Microsoft.Data.OData.dll).VersionInfo'

# 
# I don't know how to deploy `$command` to `$appservicename`
# `$command` includes local path (D:\ ...) in `$appservicename` VM
# 

$result = (Object shown in "Expected output" section)

$htmlpart = $result `
  | Sort-Object -property FileName `
  | ConvertTo-Html `
     -Fragment `
     -PreContent "<h4>file list</h4>" `
     -Property * `
     -As Table

环境 - $PsVersionTable

Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.42000
BuildVersion                   6.3.9600.16406
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2

0 个答案:

没有答案