forked from Kaidja/ConfigMgrSDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
How to export Configuration Manager boundaries to Excel
43 lines (39 loc) · 1.34 KB
/
How to export Configuration Manager boundaries to Excel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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()