forked from Kaidja/ConfigMgrSDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HTML Report – Distribution Points
197 lines (165 loc) · 7.84 KB
/
HTML Report – Distribution Points
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,HelpMessage="Please Enter Site Server Name")]
$SiteServer,
[Parameter(Mandatory=$True,HelpMessage="Please Enter Site Server Code")]
$SiteCode,
[Parameter(Mandatory=$True,HelpMessage="Please Enter report destination folder, example c:\temp")]
$FileLocation
)
Function Convert-ContentSchedulePriority
{
Param($Priority)
switch($Priority)
{
4 {$PriorityName = "Lowest"}
5 {$PriorityName = "Low"}
6 {$PriorityName = "Medium"}
7 {$PriorityName = "High"}
8 {$PriorityName = "Highest"}
}
Return $PriorityName
}
Function Convert-DayNumbersToDayName
{
[CmdletBinding()]
Param(
[String]$DayNumber
)
Switch ($DayNumber)
{
"1" {$DayName = "Sunday"}
"2" {$DayName = "Monday"}
"3" {$DayName = "TuesDay"}
"4" {$DayName = "WednesDay"}
"5" {$DayName = "ThursDay"}
"6" {$DayName = "FriDay"}
"7" {$DayName = "Saturday"}
}
Return $DayName
}
Function Convert-MonthToNumbers
{
[CmdletBinding()]
Param(
[String]$MonthNumber
)
Switch ($MonthNumber)
{
"1" {$MonthName = "January"}
"2" {$MonthName = "Feburary"}
"3" {$MonthName = "March"}
"4" {$MonthName = "April"}
"5" {$MonthName = "May"}
"6" {$MonthName = "June"}
"7" {$MonthName = "July"}
"8" {$MonthName = "August"}
"9" {$MonthName = "September"}
"10" {$MonthName = "October"}
"11" {$MonthName = "November"}
"12" {$MonthName = "December"}
}
Return $MonthName
}
Function Convert-WeekOrderNumber
{
[CmdletBinding()]
Param(
[String]$WeekOrderNumber
)
Switch ($WeekOrderNumber)
{
0 {$WeekOrderName = "Last"}
1 {$WeekOrderName = "First"}
2 {$WeekOrderName = "Second"}
3 {$WeekOrderName = "Third"}
4 {$WeekOrderName = "Fourth"}
}
Return $WeekOrderName
}
Function Convert-ScheduleString
{
Param(
$ScheduleString,
$SiteCode,
$SiteServer
)
$Class = "SMS_ScheduleMethods"
$Method = "ReadFromString"
$Colon = ":"
$WMIConnection = [WMIClass]"\\$SiteServer\root\SMS\Site_$SiteCode$Colon$Class"
$String = $WMIConnection.psbase.GetMethodParameters($Method)
$String.StringData = $ScheduleString
$ScheduleData = $WMIConnection.psbase.InvokeMethod($Method,$String,$null)
$ScheduleClass = $ScheduleData.TokenData
switch($ScheduleClass[0].__CLASS)
{
"SMS_ST_RecurWeekly"
{
$ContentValidationShedule = "Recure every: $($ScheduleClass[0].ForNumberOfWeeks) weeks on " + (Convert-DayNumbersToDayName -DayNumber $ScheduleClass[0].Day)
Return $ContentValidationShedule
}
"SMS_ST_RecurInterval"
{
$ContentValidationShedule = "Occures every $($ScheduleClass[0].DaySpan) days"
Return $ContentValidationShedule
}
"SMS_ST_RecurMonthlyByDate"
{
If($ScheduleClass[0].MonthDay -eq 0){
$ContentValidationShedule = "Occures the last day of every " + (Convert-MonthToNumbers -MonthNumber $ScheduleClass[0].ForNumberOfMonths)
Return $ContentValidationShedule
}
Else{
$ContentValidationShedule = "Occures day $($ScheduleClass[0].MonthDay) of every " + (Convert-MonthToNumbers -MonthNumber $ScheduleClass[0].ForNumberOfMonths)
Return $ContentValidationShedule
}
}
"SMS_ST_RecurMonthlyByWeekday"
{
$ContentValidationShedule = "Occures the " + (Convert-WeekOrderNumber -weekordernumber $ScheduleClass[0].WeekOrder) + " " + (Convert-DayNumbersToDayName -DayNumber $ScheduleClass[0].Day) + " of every " + (Convert-MonthToNumbers -MonthNumber $ScheduleClass[0].ForNumberOfMonths)
Return $ContentValidationShedule
}
"SMS_ST_NonRecurring"
{
$ContentValidationShedule = "No Schedule"
Return $ContentValidationShedule
}
}
}
#HTML style
$HeadStyle = "<style>"
$HeadStyle = $HeadStyle + "BODY{background-color:peachpuff;}"
$HeadStyle = $HeadStyle + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$HeadStyle = $HeadStyle + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
$HeadStyle = $HeadStyle + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:palegoldenrod}"
$HeadStyle = $HeadStyle + "</style>"
$CurrentDate = Get-Date
$EmptyArray = @()
$Class = "SMS_DistributionPointInfo"
$FileName = "DP_Audit.Html"
$DPQuery = Get-WmiObject -Namespace "root\sms\site_$SiteCode" -Class $Class -ErrorAction STOP -ComputerName $SiteServer
foreach($Item in $DPQuery)
{
$DObject = New-Object PSObject
$DObject | Add-Member -MemberType NoteProperty -Name "Server" -Value $($Item.ServerName)
$DObject | Add-Member -MemberType NoteProperty -Name "AddressScheduleEnabled" -Value $($Item.AddressScheduleEnabled)
$DObject | Add-Member -MemberType NoteProperty -Name "BitsEnabled" -Value $($Item.BitsEnabled)
$DObject | Add-Member -MemberType NoteProperty -Name "Communication" -Value $(if($Item.Communication -eq 0) {"HTTP"} Else{"HTTPS"})
$DObject | Add-Member -MemberType NoteProperty -Name "GroupCount" -Value $($Item.GroupCount)
$DObject | Add-Member -MemberType NoteProperty -Name "HealthCheckEnabled" -Value $($Item.HealthCheckEnabled)
$DObject | Add-Member -MemberType NoteProperty -Name "HealthCheckPriority" -Value (Convert-ContentSchedulePriority -Priority $Item.HealthCheckPriority)
$DObject | Add-Member -MemberType NoteProperty -Name "HealthCheckSchedule" -Value (Convert-ScheduleString -SiteCode $SiteCode -SiteServer $SiteServer -ScheduleString $Item.HealthCheckSchedule)
$DObject | Add-Member -MemberType NoteProperty -Name "InternetFacing" -Value $($Item.InternetFacing)
$DObject | Add-Member -MemberType NoteProperty -Name "IsMulticast" -Value $($Item.IsMulticast)
$DObject | Add-Member -MemberType NoteProperty -Name "IsPeerDP" -Value $($Item.IsPeerDP)
$DObject | Add-Member -MemberType NoteProperty -Name "IsProtected" -Value $($Item.IsProtected)
$DObject | Add-Member -MemberType NoteProperty -Name "IsPXE" -Value $($Item.IsPXE)
$DObject | Add-Member -MemberType NoteProperty -Name "PreStagingAllowed" -Value $($Item.PreStagingAllowed)
$DObject | Add-Member -MemberType NoteProperty -Name "RateLimitsEnabled" -Value $($Item.RateLimitsEnabled)
$DObject | Add-Member -MemberType NoteProperty -Name "SiteName" -Value $($Item.SiteName)
$DObject | Add-Member -MemberType NoteProperty -Name "SupportUnknow" -Value $($Item.SupportUnknownMachines)
$DObject | Add-Member -MemberType NoteProperty -Name "UdaSetting" -Value $($Item.UdaSetting)
$EmptyArray += $DObject
}
$EmptyArray | ConvertTo-Html -Head $HeadStyle -Body "<h2>Distribution Point Audit: $CurrentDate</h2>" -ErrorAction STOP | Out-File "$FileLocation\$FileName"