我在下面的这些代码都可以正常工作 - 但是当我尝试导出到 xls 时它不会导出任何东西 - 我现在变得失明......任何人都可以帮忙吗?
$StoppedInstances = (Get-EC2Instance).instances | Where-Object {$_.State.Name -eq "stopped" -or $_.State.Name -eq "running"}
$VPCS = Get-EC2Vpc
foreach ($VPC in $VPCS) {
$StoppedInstances | Where-Object {$_.VpcId -eq $VPC.VpcId} | foreach {
New-Object -TypeName PSObject -Property @{
'InstanceId' = $_.InstanceId
'InstanceName' = ($_.Tags | Where-Object {$_.Key -eq 'Name'}).Value
'LaunchTime' = $_.LaunchTime
'State' = $_.State.Name
#'State1' = $_.State.GetType()
'Private IP' = $_.PrivateIpAddress
'Public IP' = $_.PublicIpAddress
'Public Dns' = $_.PublicDnsName
'loadbalace' = $_.AmiLaunchIndex
'vpcID' = $_.VpcId
'instancetype' = $_.InstanceType
'EBSDISK' = $_.BlockDeviceMappings.Count
'ELB' = $_.NetworkInterfaces
} | Format-Table -GroupBy date -Wrap | Export-Csv C:\temp\test4.csv
}
}