首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >export-csv无数据问题?

export-csv无数据问题?
EN

Stack Overflow用户
提问于 2017-11-30 11:04:07
回答 0查看 1.5K关注 0票数 0

在我的报告中,当我删除export-csv部分时,数据会正确地显示在屏幕上,当我添加export-csv时,不会导出数据,但会创建文件。下面是我的脚本,以及脚本运行(修改)时数据的外观。

代码语言:javascript
复制
#Get all DHCP Servers
$ServerList = (Get-Content -Path "\\termserv\DHCPServers.txt")
foreach ($server in $serverlist)
{
#Get the scopes from each serve
     Get-DHCPServerv4Scope -ComputerName $server | select ScopeID | 
#Get the lease information for each scope
     ForEach-Object {Get-DHCPServerv4Lease -ScopeId $_.ScopeId -ComputerName 
     $server -AllLeases  | 
        where {$_.AddressState -like "*Reservation"} | Select-Object 
        $server,ScopeId,IPAddress,HostName,ClientID,AddressState | Export-
        Csv "\\termserv\d$\term\User\Reservations1.csv"
   }
  }

不使用export导出时数据的外观-csv

NOPEDH01 : ScopeId : 000.11.2.3 IPAddress : 111.22.3.444 HostName : NOPE00112233 ClientID : 00-11-22-33-44-55 AddressState : ActiveReservation

NOPEDH01 : ScopeId : 000.11.2.3 IPAddress : 111.22.3.445 HostName : NOPE0011223344 ClientID : 00-11-22-33-44-56 AddressState : ActiveReservation

更新:试过了,还是没什么,当我在DH服务器上本地运行脚本的修改版本时,它可以正常工作,但我在我的环境中查看了近100个DH服务器,如下所示

代码语言:javascript
复制
Get-DHCPServerV4Scope | ForEach {

Get-DHCPServerv4Lease -ScopeID $_.ScopeID -AllLeases | where 
{$_.AddressState -like '*Reservation'}

} | Select-Object ScopeId,IPAddress,HostName,ClientID,AddressState | Export-
Csv "\\termserv\d$\term\$($env:COMPUTERNAME)-Reservations1.csv" -
NoTypeInformation
EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47565244

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档