Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create How to export Configuration Manager boundaries to Excel
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |