Skip to content

Commit

Permalink
Create How to export Configuration Manager boundaries to Excel
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaidja committed Jul 14, 2017
1 parent d739d5d commit 12cac16
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions How to export Configuration Manager boundaries to Excel
@@ -0,0 +1,43 @@
[Threading.Thread]::CurrentThread.CurrentCulture = 'en-US'
$XLSX = New-Object -ComObject "Excel.Application"
$XLSX.Visible = $True
$NewWorkBook = $XLSX.Workbooks.Add()
$Sheet1 = $NewWorkBook.WorkSheets.item(1)
$Cells = $Sheet1.Cells

$Row = 1
$Cells.Item($Row,1) = "Boundary ID"
$Cells.item($Row,1).Font.Bold = $True
$Cells.Item($Row,2) = "Boundary Type"
$Cells.item($Row,2).Font.Bold = $True
$Cells.Item($Row,3) = "Created By"
$Cells.item($Row,3).Font.Bold = $True
$Cells.Item($Row,4) = "Display Name"
$Cells.item($Row,4).Font.Bold = $True
$Cells.Item($Row,5) = "Group Count"
$Cells.item($Row,5).Font.Bold = $True
$Cells.Item($Row,6) = "Value"
$Cells.item($Row,6).Font.Bold = $True
$Row++

$BoundaryQuery = Get-WmiObject -Namespace "Root\SMS\Site_PRI" -Class SMS_Boundary -ComputerName Server100

foreach($item in $BoundaryQuery)
{
Switch($item.BoundaryType)
{
0 {$Type = "IP Subnet"}
1 {$Type = "Active Directory Site"}
2 {$Type = "IPv6"}
3 {$Type = "Ip Address Range"}
}
$Cells.Item($Row,1) = $item.BoundaryID
$Cells.Item($Row,2) = $Type
$Cells.Item($Row,3) = $item.CreatedBy
$Cells.Item($Row,4) = $item.DisplayName
$Cells.Item($Row,5) = $item.GroupCount
$Cells.Item($Row,6) = $item.Value
$Row++
}

$Cells.EntireColumn.AutoFit()

0 comments on commit 12cac16

Please sign in to comment.