利用ems实现mailgroup member 导出到excel,并设置格式 # This script should be run in Exchange powershell Environment.It will export # members of mailgroup that start with manu、 pc、 qa、and pe into the excel. ################################ #open a excel file ################################ $exl = new-object -comobject excel.application $exl.visible = $true $wb = $exl.workbooks.add() $ws = $wb.worksheets.Item(1) ################################################################ #get distributionggroups that start with ################################################################ $mailgp = get-distributiongroup |select-string "^manu|^pc|^qa|^pe" ############################################################### #get members of the distributiongroup ############################################################### $y=1 foreach ($gp in $mailgp) { $title = get-distributiongroup -identity "$gp" |select name $ws.cells.item(1,$y)= $title.name $members = get-distributiongroupmember -identity "$gp" |select name $x=2 foreach ($member in $members) { $ws.cells.item($x,$y) = $member.name $x++ } $y++ } ##################################################################### #set the excel style ##################################################################### $lineStyle = "microsoft.office.interop.excel.xlLineStyle" -as [type] $colorIndex = "microsoft.office.interop.excel.xlColorIndex" -as [type] $borderWeight = "microsoft.office.interop.excel.xlBorderWeight" -as [type] $chartType = "microsoft.office.interop.excel.xlChartType" -as [type] $colcon=$mailgp.count for($b = 1 ; $b -le $colcon ; $b++) { $ws.cells.item(1,$b).columnWidth= 14 # $ws.item(1,$b).font.bold = $true $ws.cells.item(1,$b).borders.LineStyle = $lineStyle::xlcontinuous $ws.cells.item(1,$b).borders.ColorIndex = $colorIndex::xlColorIndexAutomatic $ws.cells.item(1,$b).borders.weight = $borderWeight::xlMedium }
MailGorupMemeber Export to excel
原创
©著作权归作者所有:来自51CTO博客作者paniho的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
数据库导出神器:Database-Export
一款强大的数据库导出工具!
数据库 Database -
Excel-Export导出批注报错
Excel-Export导出批注报错
Excel Export 导出