Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Standardmäßig formatieren Azure PowerShell-Cmdlets ihre Ausgabe für eine einfache Lesbarkeit. Sie können das Ausgabeformat jedoch ändern oder anpassen, indem Sie die Cmdlet-Ausgabe an eines der folgenden Cmdlets weiterleiten:
Formatierung | Umwandlung |
---|---|
Format-Custom | ConvertTo-Csv |
Format-Liste | ConvertTo-Html |
Format-Tabelle | ConvertTo-Json |
Formatübergreifend | ConvertTo-Xml |
Formatierung zeigt Informationen in der PowerShell-Konsole an, während die Konvertierung Daten für andere Skripts oder Programme generiert.
Tabellenausgabeformat
Die Ausgabe von Azure PowerShell-Cmdlets erfolgt standardmäßig im Tabellenformat. In diesem Format werden nicht alle Informationen der angeforderten Ressource angezeigt:
Get-AzVM
ResourceGroupName Name Location VmSize OsType NIC ProvisioningState Zone
----------------- ---- -------- ------ ------ --- ----------------- ----
QueryExample ExampleLinuxVM westus2 Basic_A0 Linux examplelinuxvm916 Succeeded
QueryExample RHELExample westus2 Standard_D2_v3 Linux rhelexample469 Succeeded
QueryExample WinExampleVM westus2 Standard_DS1_v2 Windows winexamplevm268 Succeeded
Die Datenmenge, die von Format-Table
angezeigt wird, kann durch die Breite des Fensters Ihrer PowerShell-Sitzung beeinflusst werden. Um die Ausgabe auf bestimmte Eigenschaften zu beschränken und zu sortieren, können Eigenschaftennamen als Argumente für Format-Table
bereitgestellt werden:
Get-AzVM -ResourceGroupName QueryExample |
Format-Table -Property Name, ResourceGroupName, Location
Name ResourceGroupName Location
---- ----------------- --------
ExampleLinuxVM QueryExample westus2
RHELExample QueryExample westus2
WinExampleVM QueryExample westus2
Ausgabeformat „List“
Beim Ausgabeformat „List“ (Liste) werden zwei Spalten erstellt, die den Eigenschaftennamen bzw. den zugehörigen Wert enthalten. Für komplexe Objekte wird stattdessen der Typ des Objekts angezeigt.
Get-AzVM | Format-List
In der folgenden Ausgabe wurden einige Felder entfernt.
ResourceGroupName : QueryExample
Id : /subscriptions/.../resourceGroups/QueryExample/providers/Microsoft.Compute/virtualMachines/ExampleLinuxVM
VmId : ...
Name : ExampleLinuxVM
Type : Microsoft.Compute/virtualMachines
Location : westus2
...
HardwareProfile : Microsoft.Azure.Management.Compute.Models.HardwareProfile
InstanceView :
NetworkProfile : Microsoft.Azure.Management.Compute.Models.NetworkProfile
OSProfile : Microsoft.Azure.Management.Compute.Models.OSProfile
...
StatusCode : OK
ResourceGroupName : QueryExample
Id : /subscriptions/.../resourceGroups/QueryExample/providers/Microsoft.Compute/virtualMachines/RHELExample
VmId : ...
Name : RHELExample
Type : Microsoft.Compute/virtualMachines
Location : westus2
...
Wie bei Format-Table
auch, können Eigenschaftennamen angegeben werden, um die Ausgabe zu sortieren und zu beschränken:
Get-AzVM | Format-List -Property ResourceGroupName, Name, Location
ResourceGroupName : QueryExample
Name : ExampleLinuxVM
Location : westus2
ResourceGroupName : QueryExample
Name : RHELExample
Location : westus2
ResourceGroupName : QueryExample
Name : WinExampleVM
Location : westus2
Breites Ausgabeformat
Beim Ausgabeformat „Wide“ (Breit) wird nur ein Eigenschaftenname pro Abfrage erstellt. Indem eine Eigenschaft als Argument angegeben wird, kann gesteuert werden, welche Eigenschaft angezeigt wird.
Get-AzVM | Format-Wide
ExampleLinuxVM RHELExample
WinExampleVM
Get-AzVM | Format-Wide -Property ResourceGroupName
QueryExample QueryExample
QueryExample
Ausgabeformat „Custom“
Der Ausgabetyp Custom-Format
dient zum Formatieren von benutzerdefinierten Objekten. Ohne Parameter entspricht das Verhalten Format-List
, aber es werden die Eigenschaftennamen von benutzerdefinierten Klassen angezeigt.
Get-AzVM | Format-Custom
In der folgenden Ausgabe wurden einige Felder entfernt.
ResourceGroupName : QueryExample
Id : /subscriptions/.../resourceGroups/QueryExample/providers/Microsoft.Compute/virtualMachines/ExampleLinuxVM
VmId : ...
Name : ExampleLinuxVM
Type : Microsoft.Compute/virtualMachines
Location : westus2
Tags : {}
HardwareProfile : {VmSize}
NetworkProfile : {NetworkInterfaces}
OSProfile : {ComputerName, AdminUsername, LinuxConfiguration, Secrets,
AllowExtensionOperations}
ProvisioningState : Succeeded
StorageProfile : {ImageReference, OsDisk, DataDisks}
...
Wenn Eigenschaftennamen als Argumente für Custom-Format
angegeben werden, werden die Eigenschafts-/Wert-Paare für benutzerdefinierte Objekte, die als Werte gesetzt sind, angezeigt.
Get-AzVM | Format-Custom -Property Name, ResourceGroupName, Location, OSProfile
In der folgenden Ausgabe wurden einige Felder entfernt.
class PSVirtualMachineList
{
Name = ExampleLinuxVM
ResourceGroupName = QueryExample
Location = westus2
OSProfile =
class OSProfile
{
ComputerName = ExampleLinuxVM
AdminUsername = ...
AdminPassword =
CustomData =
WindowsConfiguration =
LinuxConfiguration =
class LinuxConfiguration
{
DisablePasswordAuthentication = False
Ssh =
ProvisionVMAgent = True
}
Secrets =
[
]
AllowExtensionOperations = True
}
}
...
class PSVirtualMachineList
{
Name = WinExampleVM
ResourceGroupName = QueryExample
Location = westus2
OSProfile =
class OSProfile
{
ComputerName = WinExampleVM
AdminUsername = ...
AdminPassword =
CustomData =
WindowsConfiguration =
class WindowsConfiguration
{
ProvisionVMAgent = True
EnableAutomaticUpdates = True
TimeZone =
AdditionalUnattendContent =
WinRM =
}
LinuxConfiguration =
Secrets =
[
]
AllowExtensionOperations = True
}
}
Konvertierung in andere Datenformate
Die Cmdlet-Familie ConvertTo-*
ermöglicht das Konvertieren der Ergebnisse von Azure PowerShell-Cmdlets in computerlesbare Formate. Leiten Sie an das Cmdlet Select-Object
weiter, bevor Sie die Konvertierung durchführen, um nur einige Eigenschaften aus den Azure PowerShell-Ergebnissen abzurufen. In den folgenden Beispielen werden die unterschiedlichen Ausgabearten veranschaulicht, die bei der Konvertierung jeweils erzeugt werden.
Konvertierung in CSV
Get-AzVM | ConvertTo-CSV
#TYPE Microsoft.Azure.Commands.Compute.Models.PSVirtualMachineList
"ResourceGroupName","Id","VmId","Name","Type","Location","LicenseType","Tags","AvailabilitySetReference","DiagnosticsProfile","Extensions","HardwareProfile","InstanceView","NetworkProfile","OSProfile","Plan","ProvisioningState","StorageProfile","DisplayHint","Identity","Zones","FullyQualifiedDomainName","AdditionalCapabilities","RequestId","StatusCode"
"QUERYEXAMPLE","/subscriptions/.../resourceGroups/QUERYEXAMPLE/providers/Microsoft.Compute/virtualMachines/ExampleLinuxVM","...","ExampleLinuxVM","Microsoft.Compute/virtualMachines","westus2",,"System.Collections.Generic.Dictionary`2[System.String,System.String]",,,"System.Collections.Generic.List`1[Microsoft.Azure.Management.Compute.Models.VirtualMachineExtension]","Microsoft.Azure.Management.Compute.Models.HardwareProfile",,"Microsoft.Azure.Management.Compute.Models.NetworkProfile","Microsoft.Azure.Management.Compute.Models.OSProfile",,"Succeeded","Microsoft.Azure.Management.Compute.Models.StorageProfile","Compact",,"System.Collections.Generic.List`1[System.String]",,,"...","OK"
"QUERYEXAMPLE","/subscriptions/.../resourceGroups/QUERYEXAMPLE/providers/Microsoft.Compute/virtualMachines/RHELExample","...","RHELExample","Microsoft.Compute/virtualMachines","westus2",,"System.Collections.Generic.Dictionary`2[System.String,System.String]",,,"System.Collections.Generic.List`1[Microsoft.Azure.Management.Compute.Models.VirtualMachineExtension]","Microsoft.Azure.Management.Compute.Models.HardwareProfile",,"Microsoft.Azure.Management.Compute.Models.NetworkProfile","Microsoft.Azure.Management.Compute.Models.OSProfile",,"Succeeded","Microsoft.Azure.Management.Compute.Models.StorageProfile","Compact",,"System.Collections.Generic.List`1[System.String]",,,"...","OK"
"QUERYEXAMPLE","/subscriptions/.../resourceGroups/QUERYEXAMPLE/providers/Microsoft.Compute/virtualMachines/WinExampleVM","...","WinExampleVM","Microsoft.Compute/virtualMachines","westus2",,"System.Collections.Generic.Dictionary`2[System.String,System.String]",,,"System.Collections.Generic.List`1[Microsoft.Azure.Management.Compute.Models.VirtualMachineExtension]","Microsoft.Azure.Management.Compute.Models.HardwareProfile",,"Microsoft.Azure.Management.Compute.Models.NetworkProfile","Microsoft.Azure.Management.Compute.Models.OSProfile",,"Succeeded","Microsoft.Azure.Management.Compute.Models.StorageProfile","Compact",,"System.Collections.Generic.List`1[System.String]",,,"...","OK"
Konvertierung in JSON
In der JSON-Ausgabe werden standardmäßig nicht alle Eigenschaften erweitert. Verwenden Sie den Parameter Depth
, um die Tiefe für die Erweiterung der Eigenschaften zu ändern. Standardmäßig wird die Erweiterungstiefe 2
verwendet.
Get-AzVM | ConvertTo-JSON
In der folgenden Ausgabe wurden einige Felder entfernt.
[
{
"ResourceGroupName": "QUERYEXAMPLE",
"Id": "/subscriptions/.../resourceGroups/QUERYEXAMPLE/providers/Microsoft.Compute/virtualMachines/ExampleLinuxVM",
"VmId": "...",
"Name": "ExampleLinuxVM",
"Type": "Microsoft.Compute/virtualMachines",
"Location": "westus2",
...
"OSProfile": {
"ComputerName": "ExampleLinuxVM",
"AdminUsername": "...",
"AdminPassword": null,
"CustomData": null,
"WindowsConfiguration": null,
"LinuxConfiguration": "Microsoft.Azure.Management.Compute.Models.LinuxConfiguration",
"Secrets": "",
"AllowExtensionOperations": true
},
"Plan": null,
"ProvisioningState": "Succeeded",
"StorageProfile": {
"ImageReference": "Microsoft.Azure.Management.Compute.Models.ImageReference",
"OsDisk": "Microsoft.Azure.Management.Compute.Models.OSDisk",
"DataDisks": ""
},
"DisplayHint": 0,
"Identity": null,
"Zones": [
],
"FullyQualifiedDomainName": null,
"AdditionalCapabilities": null,
"RequestId": "...",
"StatusCode": 200
},
...
]
Konvertierung in XML
Mit dem Cmdlet ConvertTo-XML
wird das Azure PowerShell-Antwortobjekt in ein reines XML-Objekt konvertiert, das wie jedes andere XML-Objekt in PowerShell verarbeitet werden kann.
Get-AzVM | ConvertTo-XML
xml Objects
--- -------
version="1.0" encoding="utf-8" Objects
Konvertierung in HTML
Beim Konvertieren eines Objekts in HTML wird eine Ausgabe erzeugt, die als HTML-Tabelle gerendert wird. Das Rendern der HTML-Daten richtet sich danach, wie Ihr Browser Tabellen rendert, die keine Informationen zur Breite enthalten. Es werden keine Objekte erweitert, bei denen es sich um benutzerdefinierte Klassen handelt.
Get-AzVM | ConvertTo-HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML TABLE</title>
</head><body>
<table>
<colgroup><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/></colgroup>
<tr><th>ResourceGroupName</th><th>Id</th><th>VmId</th><th>Name</th><th>Type</th><th>Location</th><th>LicenseType</th><th>Tags</th><th>AvailabilitySetReference</th><th>DiagnosticsProfile</th><th>Extensions</th><th>HardwareProfile</th><th>InstanceView</th><th>NetworkProfile</th><th>OSProfile</th><th>Plan</th><th>ProvisioningState</th><th>StorageProfile</th><th>DisplayHint</th><th>Identity</th><th>Zones</th><th>FullyQualifiedDomainName</th><th>AdditionalCapabilities</th><th>RequestId</th><th>StatusCode</th></tr>
<tr><td>QUERYEXAMPLE</td><td>/subscriptions/.../resourceGroups/QUERYEXAMPLE/providers/Microsoft.Compute/virtualMachines/ExampleLinuxVM</td><td>...</td><td>ExampleLinuxVM</td><td>Microsoft.Compute/virtualMachines</td><td>westus2</td><td></td><td>System.Collections.Generic.Dictionary`2[System.String,System.String]</td><td></td><td></td><td>System.Collections.Generic.List`1[Microsoft.Azure.Management.Compute.Models.VirtualMachineExtension]</td><td>Microsoft.Azure.Management.Compute.Models.HardwareProfile</td><td></td><td>Microsoft.Azure.Management.Compute.Models.NetworkProfile</td><td>Microsoft.Azure.Management.Compute.Models.OSProfile</td><td></td><td>Succeeded</td><td>Microsoft.Azure.Management.Compute.Models.StorageProfile</td><td>Compact</td><td></td><td>System.Collections.Generic.List`1[System.String]</td><td></td><td></td><td>...</td><td>OK</td></tr>
<tr><td>QUERYEXAMPLE</td><td>/subscriptions/.../resourceGroups/QUERYEXAMPLE/providers/Microsoft.Compute/virtualMachines/RHELExample</td><td>...</td><td>RHELExample</td><td>Microsoft.Compute/virtualMachines</td><td>westus2</td><td></td><td>System.Collections.Generic.Dictionary`2[System.String,System.String]</td><td></td><td></td><td>System.Collections.Generic.List`1[Microsoft.Azure.Management.Compute.Models.VirtualMachineExtension]</td><td>Microsoft.Azure.Management.Compute.Models.HardwareProfile</td><td></td><td>Microsoft.Azure.Management.Compute.Models.NetworkProfile</td><td>Microsoft.Azure.Management.Compute.Models.OSProfile</td><td></td><td>Succeeded</td><td>Microsoft.Azure.Management.Compute.Models.StorageProfile</td><td>Compact</td><td></td><td>System.Collections.Generic.List`1[System.String]</td><td></td><td></td><td>...</td><td>OK</td></tr>
<tr><td>QUERYEXAMPLE</td><td>/subscriptions/.../resourceGroups/QUERYEXAMPLE/providers/Microsoft.Compute/virtualMachines/WinExampleVM</td><td>...</td><td>WinExampleVM</td><td>Microsoft.Compute/virtualMachines</td><td>westus2</td><td></td><td>System.Collections.Generic.Dictionary`2[System.String,System.String]</td><td></td><td></td><td>System.Collections.Generic.List`1[Microsoft.Azure.Management.Compute.Models.VirtualMachineExtension]</td><td>Microsoft.Azure.Management.Compute.Models.HardwareProfile</td><td></td><td>Microsoft.Azure.Management.Compute.Models.NetworkProfile</td><td>Microsoft.Azure.Management.Compute.Models.OSProfile</td><td></td><td>Succeeded</td><td>Microsoft.Azure.Management.Compute.Models.StorageProfile</td><td>Compact</td><td></td><td>System.Collections.Generic.List`1[System.String]</td><td></td><td></td><td>...</td><td>OK</td></tr>
</table>
</body></html>
Azure PowerShell