Advertisement
marcd2k20

Distribution Point Content Validation Tool

Nov 4th, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.52 KB | None | 0 0
  1. Add-Type -AssemblyName PresentationFramework, WindowsBase, System.Windows.Forms
  2. $xaml=@"
  3. <Window Name='Window' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' WindowStartupLocation='CenterScreen' WindowStyle='None' WindowState='Normal' SizeToContent='WidthAndHeight' Background='#FFFFFF' ResizeMode='NoResize' AllowsTransparency='True'>
  4. <Border Name='bdr_Border' BorderThickness='2' VerticalAlignment='Top'>
  5. <Grid>
  6. <StackPanel>
  7.  
  8. <DockPanel Name='dck_TitleBar' DockPanel.Dock='Top'>
  9. <Button Name='btn_Close' Content='X' DockPanel.Dock='Right' Width='Auto' Padding='15,0' FontSize='18' Foreground='White' Margin='5' Background='#EB3C01'/>
  10. <Button Name='btn_Minimize' Content='_' DockPanel.Dock='Right' Width='Auto' Padding='15,0' FontSize='18' Foreground='White' Margin='5,5,0,5' Background='Gray'/>
  11. <Label Name = 'lbl_AppTitle' HorizontalAlignment='Left' VerticalAlignment='Center' FontSize='18' Foreground='White' DockPanel.Dock='Left' Padding='10'/>
  12. </DockPanel>
  13. <DockPanel LastChildFill='False' Margin='10'>
  14. <Border DockPanel.Dock='Top' BorderThickness='1' BorderBrush='#CCCCCC'>
  15. <DockPanel Margin='10'>
  16. <StackPanel>
  17. <DockPanel>
  18.  
  19. <StackPanel Margin='0,0,10,0'>
  20. <Label Content='Site Server' FontSize='14'/>
  21. <TextBox Name='txt_SiteServer' Width='350' FontSize='14' Height='25'/>
  22. </StackPanel>
  23.  
  24. <StackPanel Margin='0,0,10,0'>
  25. <Label Content='Site Code' FontSize='14'/>
  26. <TextBox Name='txt_SiteCode' Width='70' FontSize='14' Height='25'/>
  27. </StackPanel>
  28.  
  29. </DockPanel>
  30.  
  31. <StackPanel Margin='0,0,10,0'>
  32. <Label Content='Package Exclusions (Comma separated)' FontSize='14'/>
  33. <TextBox Name='txt_PkgExclusions' Width='430' FontSize='14' Height='25'/>
  34. </StackPanel>
  35. </StackPanel>
  36.  
  37. <StackPanel Height='110'>
  38. <Button Name='btn_Load' Content='Load' Width='50' Height='20' FontSize='12' Margin='0,29,0,0'/>
  39. <Button Name='btn_Save' Content='Save' Width='50' Height='20' FontSize='12' Margin='0,8,0,0'/>
  40. <Button Name='btn_Refresh' Content='Refresh' Width='50' Height='20' FontSize='12' Margin='0,8,0,0'/>
  41. </StackPanel>
  42. </DockPanel>
  43. </Border>
  44. </DockPanel>
  45.  
  46. <DockPanel Margin='20,0,20,0'>
  47.  
  48. <StackPanel Margin='0,0,10,0'>
  49. <Label Content='Distribution Point' FontSize='14'/>
  50. <ComboBox Name='cmb_DistributionPoint' Width='360' FontSize='14' Height='25'/>
  51. </StackPanel>
  52.  
  53. <Button Name='btn_Check' Content='Check' VerticalAlignment='Bottom' Width='50' FontSize='12' Height='25' Margin='0,0,10,0' IsEnabled='False'/>
  54. <Button Name='btn_Validate' Content='Validate' VerticalAlignment='Bottom' Width='60' FontSize='12' Height='25' IsEnabled='False'/>
  55.  
  56. </DockPanel>
  57.  
  58. <DockPanel Margin='20,0,20,0' LastChildFill='False'>
  59. <Label Content='DP Status:' FontSize='12' Height='30' VerticalContentAlignment='Center'/>
  60. <Label Name='lbl_DPStatus' Content='---' FontSize='12' Width='80' Height='30' VerticalContentAlignment='Center'/>
  61. <MediaElement Name='med_DPStatus' UnloadedBehavior='Manual' Source='$($PSScriptRoot)\loading.GIF' LoadedBehavior='Play' Stretch='Uniform' Visibility='Collapsed' Width='80' Height='30' HorizontalAlignment='Left'/>
  62. <Label Content='Deployed Packages:' FontSize='12' Height='30' VerticalContentAlignment='Center'/>
  63. <Label Name='lbl_Deployed' Content='---' FontSize='12' Width='30' Height='30' VerticalContentAlignment='Center'/>
  64. <MediaElement Name='med_Deployed' UnloadedBehavior='Manual' Source='$($PSScriptRoot)\loading.GIF' LoadedBehavior='Play' Stretch='Uniform' Visibility='Collapsed' Width='30' Height='30'/>
  65.  
  66. </DockPanel>
  67.  
  68. <DockPanel Margin='20,0,20,0' LastChildFill='False'>
  69.  
  70. <Label Content='Packages in WMI:' FontSize='12' Height='30'/>
  71. <Label Name='lbl_WMI' Content='---' FontSize='12' Width='40' Height='30'/>
  72. <MediaElement Name='med_WMI' UnloadedBehavior='Manual' Source='$($PSScriptRoot)\loading.GIF' LoadedBehavior='Play' Stretch='Uniform' Visibility='Collapsed' Width='40' Height='30'/>
  73.  
  74. <Label Content='Packages in PkgLib: ' FontSize='12' Height='30'/>
  75. <Label Name='lbl_PkgLib' Content='---' FontSize='12' Width='30' Height='30'/>
  76. <MediaElement Name='med_PkgLib' UnloadedBehavior='Manual' Source='$($PSScriptRoot)\loading.GIF' LoadedBehavior='Play' Stretch='Uniform' Visibility='Collapsed' Width='30' Height='30'/>
  77.  
  78. </DockPanel>
  79.  
  80. <DockPanel Margin='20,10,20,20' LastChildFill='False' HorizontalAlignment='Center'>
  81.  
  82. <StackPanel Margin='0,0,20,0'>
  83. <Label Content='Invalid WMI Entries' FontSize='14' HorizontalAlignment='Center'/>
  84. <ListBox Name='lst_InvalidWMI' FontSize='14' Height='200' Width='150' SelectionMode='Multiple'/>
  85. <Button Name='btn_InvalidWMI' Content='Remove Selected' FontSize='12' Margin='0,10,0,0' Height='25' IsEnabled='False'/>
  86. </StackPanel>
  87.  
  88. <StackPanel Margin='0,0,20,0'>
  89. <Label Content='Invalid PkgLib Entries' FontSize='14' HorizontalAlignment='Center'/>
  90. <ListBox Name='lst_InvalidPkgLib' FontSize='14' Height='200' Width='150'/>
  91. <Button Name='btn_InvalidPkgLib' Content='Remove Selected' FontSize='12' Margin='0,10,0,0' Height='25' IsEnabled='False'/>
  92. </StackPanel>
  93.  
  94. <StackPanel>
  95. <Label Content='Missing Content' FontSize='14' HorizontalAlignment='Center'/>
  96. <ListBox Name='lst_MissingContent' FontSize='14' Height='200' Width='150' SelectionMode='Multiple'/>
  97. <Button Name='btn_MissingContent' Content='Redistribute Selected' FontSize='12' Margin='0,10,0,0' Height='25' IsEnabled='False'/>
  98. </StackPanel>
  99.  
  100. </DockPanel>
  101.  
  102. </StackPanel>
  103. </Grid>
  104. </Border>
  105. </Window>
  106. "@
  107.  
  108. $xaml=[xml]$xaml
  109. $Form = [Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader $xaml))
  110. $Controls = @{}
  111. $xaml.SelectNodes("//*[@Name]") | ForEach-Object {$Controls.Add($_.Name,$Form.FindName($_.Name))}
  112.  
  113. $Controls.lbl_AppTitle.Content="Distribution Point Content Validation Tool"
  114. $Controls.Window.Title="Distribution Point Content Validation Tool"
  115. $Controls.dck_TitleBar.Add_MouseDown{$Controls.Window.DragMove()}
  116. $Controls.btn_Minimize.Add_Click{$Form.WindowState='Minimized'}
  117. $Controls.btn_Close.Add_Click{$Form.close()}
  118. $Controls.btn_Save.Add_Click{Save-Config}
  119. $Controls.btn_Check.Add_Click{Check-DistributionPoint}
  120. $Controls.btn_InvalidWMI.Add_Click{Remove-InvalidWMI}
  121. $Controls.btn_InvalidPkgLib.Add_Click{Remove-InvalidPkgLib}
  122. $Controls.btn_Validate.Add_Click{Start-Validation}
  123. $Controls.cmb_DistributionPoint.Add_SelectionChanged{Reset-Form;Validate-Buttons}
  124. $Controls.btn_Load.Add_Click{
  125. Get-Config
  126. Connect-ConfigMgr
  127. Get-DistributionPoints
  128. }
  129.  
  130. $Controls.btn_Refresh.Add_Click{
  131. Connect-ConfigMgr
  132. Get-DistributionPoints
  133. }
  134.  
  135. $Controls.btn_MissingContent.Add_Click{
  136. Redist-MissingContent
  137. }
  138.  
  139. Foreach ($Control in $Controls.med_DPStatus,$Controls.med_Deployed,$Controls.med_WMI,$Controls.med_PkgLib){
  140. $Control.Add_MediaEnded{
  141. If ($args[0].Visibility -eq "Visible"){
  142. $args[0].Position=New-TimeSpan -Seconds 1
  143. $args[0].Play()
  144. }
  145. }
  146. }
  147.  
  148. $Script:Running=$False
  149.  
  150. $Controls.Window.Add_Loaded{
  151. Get-Config
  152. Connect-ConfigMgr
  153. Get-DistributionPoints
  154. Get-FailedContent
  155. }
  156.  
  157. $ThemeColour=[System.Windows.SystemParameters]::WindowGlassBrush
  158. Foreach ($Control in $Controls.btn_Save,$Controls.btn_Load,$Controls.btn_Refresh,$Controls.btn_Check,$Controls.btn_InvalidWMI,$Controls.btn_MissingContent,$Controls.btn_InvalidPkgLib,$Controls.btn_Validate){
  159. $Control.Background=$ThemeColour
  160. $Control.Foreground='White'
  161. }
  162. $Controls.dck_TitleBar.Background=$ThemeColour
  163. $Controls.bdr_Border.BorderBrush=$ThemeColour
  164.  
  165. Function Save-Config
  166. {
  167. Try{
  168. $Controls.txt_SiteServer.Text | Out-File "$($PSScriptRoot)\CMSite.dat" -Force -ErrorAction Stop
  169. $Controls.txt_SiteCode.Text | Out-File "$($PSScriptRoot)\CMSite.dat" -Append -ErrorAction Stop
  170. $Controls.txt_PkgExclusions.Text | Out-File "$($PSScriptRoot)\CMSite.dat" -Append -ErrorAction Stop
  171. [System.Windows.MessageBox]::Show('Configuration Saved','Success','OK','Information')
  172. }
  173. Catch{
  174. [System.Windows.MessageBox]::Show('Error Saving Configuration','Error','OK','Error')
  175. }
  176. }
  177.  
  178. Function Get-Config
  179. {
  180. If (Test-Path "$($PSScriptRoot)\CMSite.dat"){
  181. $Config=Get-Content "$($PSScriptRoot)\CMSite.dat"
  182. $Controls.txt_SiteServer.Text=$Config[0]
  183. $Controls.txt_Sitecode.Text=$Config[1]
  184. $Controls.txt_PkgExclusions.Text=$Config[2]
  185. }
  186. }
  187.  
  188. Function Connect-ConfigMgr
  189. {
  190. $SiteCode = $Controls.txt_SiteCode.Text
  191. $ProviderMachineName = $Controls.txt_SiteServer.Text
  192.  
  193. if($null -eq (Get-Module ConfigurationManager)) {
  194. Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1"
  195. }
  196.  
  197. if($null -eq (Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue)) {
  198. New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName
  199. }
  200. }
  201.  
  202. Function Get-DistributionPoints
  203. {
  204. $Controls.cmb_DistributionPoint.Items.Clear()
  205. Set-Location "$($Controls.txt_SiteCode.Text):"
  206. Get-CMDistributionPointInfo | where {$_.OperatingSystem -notlike "*Azure*"} | Foreach-Object {$Controls.cmb_DistributionPoint.Items.Add($_.Name)}
  207. }
  208.  
  209. Function Get-FailedContent
  210. {
  211. $SiteCode = $Controls.txt_SiteCode.Text
  212. $Script:failedContent = Get-WmiObject -Namespace root\sms\site_$SiteCode -Query "SELECT * FROM SMS_PackageStatusDistPointsSummarizer WHERE State > 1" | Select-Object ServerNALPath,PackageID
  213. }
  214.  
  215. Function Check-DistributionPoint
  216. {
  217. $Script:Running=$True
  218. $Controls.btn_Check.IsEnabled=$False
  219. Reset-Form
  220. Get-DPStatus
  221. Get-DeployedPackages
  222. Get-WMIPackages
  223. Get-PkgLibPackages
  224. Populate-MissingContent
  225. $Script:Running=$False
  226. Validate-Buttons
  227. }
  228.  
  229. Function Get-DPStatus
  230. {
  231.  
  232. $Controls.lbl_DPStatus.Visibility="Collapsed"
  233. $Controls.med_DPStatus.Visibility="Visible"
  234. $Controls.med_DPStatus.Position=New-TimeSpan -Seconds 1
  235. $Controls.med_DPStatus.Play()
  236. [System.Windows.Forms.Application]::DoEvents()
  237.  
  238. if ( -not(Test-Connection $Controls.cmb_DistributionPoint.Text -Quiet -Count 1)) {
  239. $Controls.lbl_DPStatus.Content="Offline"
  240. $Controls.lbl_DPStatus.Foreground="Red"
  241. Break
  242. } else {
  243. Set-Location "$($Controls.txt_SiteCode.Text):"
  244. $Script:ContentLibDrive=(Get-CMDistributionPoint $Controls.cmb_DistributionPoint.Text | Get-CMDistributionPointDriveInfo).Drive
  245.  
  246. If ($Script:ContentLibDrive.Count -ne 1){
  247.  
  248. $Script:ContentLibDrive=Invoke-Command -ComputerName $Controls.cmb_DistributionPoint.Text -ArgumentList $Script:ContentLibDrive -ScriptBlock {
  249. If ($Args.count -gt 0){
  250. Foreach ($Item in $Args){
  251. If (Test-Path -Path "$($Item):\SCCMContentLib\PkgLib"){
  252. return $Item
  253. break
  254. }
  255. }
  256. } else {
  257. $Drives = (Get-Volume | Where-Object {$_.DriveType -eq "Fixed" -and $_.DriveLetter}).DriveLetter
  258. foreach ($Item in $Drives){
  259. If (Test-Path -Path "$($Item):\SCCMContentLib\PkgLib"){
  260. return $Item
  261. break
  262. }
  263. }
  264. }
  265. }
  266. }
  267.  
  268. $Controls.lbl_DPStatus.Content="Online"
  269. $Controls.lbl_DPStatus.Foreground="Green"
  270. }
  271. $Controls.lbl_DPStatus.Visibility="Visible"
  272. $Controls.med_DPStatus.Visibility="Collapsed"
  273. [System.Windows.Forms.Application]::DoEvents()
  274. }
  275.  
  276. Function Get-PkgLibPackages
  277. {
  278. $Controls.lbl_PkgLib.Visibility="Collapsed"
  279. $Controls.med_PkgLib.Visibility="Visible"
  280. $Controls.med_PkgLib.Position=New-TimeSpan -Seconds 1
  281. $Controls.med_PkgLib.Play()
  282. [System.Windows.Forms.Application]::DoEvents()
  283.  
  284. Set-Location C:
  285. $Script:PkgLibPackageList = @(Invoke-Command -ComputerName $Controls.cmb_DistributionPoint.Text -ArgumentList $Script:ContentLibDrive -ScriptBlock {
  286. Get-ChildItem "$($args[0]):\SCCMContentLib\PkgLib" | Select -ExpandProperty Name
  287. })
  288. $Script:PkgLibPackageList = $Script:PkgLibPackageList | ForEach-Object {$_.replace('.INI',"")}
  289. $Script:PkgLibPackageList = $Script:PkgLibPackageList | Where-Object {$_ -notin $Exclusions}
  290. $Controls.lbl_PkgLib.Content="$($Script:PkgLibPackageList.Count)"
  291.  
  292. If ($Controls.lbl_PkgLib.Content -ne $Controls.lbl_Deployed.Content){
  293. $Controls.lbl_PkgLib.Foreground='Red'
  294. } else {
  295. $Controls.lbl_PkgLib.Foreground='Green'
  296. }
  297. $Controls.lbl_PkgLib.Visibility="Visible"
  298. $Controls.med_PkgLib.Visibility="Collapsed"
  299. [System.Windows.Forms.Application]::DoEvents()
  300. Populate-InvalidPkgLib
  301. }
  302.  
  303. Function Get-DeployedPackages
  304. {
  305. $Controls.lbl_Deployed.Visibility="Collapsed"
  306. $Controls.med_Deployed.Visibility="Visible"
  307. $Controls.med_Deployed.Position=New-TimeSpan -Seconds 1
  308. $Controls.med_Deployed.Play()
  309. [System.Windows.Forms.Application]::DoEvents()
  310.  
  311. Set-Location "$($Controls.txt_SiteCode.Text):"
  312. $Script:Exclusions=$Controls.txt_PkgExclusions.Text.Split(",")
  313.  
  314. $Script:DPPackageList=Get-CMDeploymentPackage -DistributionPointName $Controls.cmb_DistributionPoint.Text | where {$_.PackageID -notin $Exclusions} | Select-Object -ExpandProperty PackageID
  315. $Controls.lbl_Deployed.Content= "$($Script:DPPackageList.count)"
  316. $Controls.lbl_Deployed.Visibility="Visible"
  317. $Controls.med_Deployed.Visibility="Collapsed"
  318. [System.Windows.Forms.Application]::DoEvents()
  319. }
  320.  
  321. Function Get-WMIPackages
  322. {
  323. $Controls.lbl_WMI.Visibility="Collapsed"
  324. $Controls.med_WMI.Visibility="Visible"
  325. $Controls.med_WMI.Position=New-TimeSpan -Seconds 1
  326. $Controls.med_WMI.Play()
  327. [System.Windows.Forms.Application]::DoEvents()
  328.  
  329. Set-Location "C:\"
  330. $Script:WMIPackageList = Invoke-Command -ComputerName $Controls.cmb_DistributionPoint.Text -ScriptBlock {@(Get-WMIObject -Namespace "root\sccmdp" -Query "Select * from SMS_PackagesInContLib " | Select-Object -ExpandProperty PackageID)}
  331.  
  332. $Script:WMIPackageList = $Script:WMIPackageList | Where-Object {$_ -notin $Exclusions}
  333. $Controls.lbl_WMI.Content="$($Script:WMIPackageList.Count)"
  334.  
  335. If ($Controls.lbl_WMI.Content -ne $Controls.lbl_Deployed.Content){
  336. $Controls.lbl_WMI.Foreground='Red'
  337. } else {
  338. $Controls.lbl_WMI.Foreground='Green'
  339. }
  340. $Controls.lbl_WMI.Visibility="Visible"
  341. $Controls.med_WMI.Visibility="Collapsed"
  342. [System.Windows.Forms.Application]::DoEvents()
  343. Populate-InvalidWMI
  344. }
  345.  
  346. Function Populate-InvalidWMI
  347. {
  348. $Controls.lst_InvalidWMI.Items.Clear()
  349. Foreach ($WMIPackage in $Script:WMIPackageList){
  350. if ($Script:DPPackageList -notcontains $WMIPackage){
  351. $Controls.lst_InvalidWMI.Items.Add($WMIPackage)
  352. }
  353. }
  354. [System.Windows.Forms.Application]::DoEvents()
  355. }
  356.  
  357. Function Remove-InvalidWMI{
  358.  
  359. Invoke-command -ComputerName $Controls.cmb_DistributionPoint.Text -ArgumentList $Controls.lst_InvalidWMI.SelectedItems -ScriptBlock {
  360. Foreach ($Item in $Args){
  361. Get-WMIObject -Namespace "root\sccmdp" -Query ("Select * from SMS_PackagesInContLib where PackageID = '" + ([string]($Item)) + "'") | Remove-WmiObject
  362. }
  363. }
  364.  
  365. Get-WMIPackages
  366. Validate-Buttons
  367. }
  368.  
  369. Function Populate-InvalidPkgLib
  370. {
  371. $Controls.lst_InvalidPkgLib.Items.Clear()
  372.  
  373. Foreach ($PkgLibPackage in $Script:PkgLibPackageList){
  374. if ($Script:DPPackageList -notcontains $PkgLibPackage){
  375. $Controls.lst_InvalidPkgLib.Items.Add($PkgLibPackage)
  376. }
  377. }
  378. [System.Windows.Forms.Application]::DoEvents()
  379. }
  380.  
  381. Function Remove-InvalidPkgLib
  382. {
  383. Set-Location C:
  384. Invoke-Command -ComputerName $Controls.cmb_DistributionPoint.Text -ArgumentList $Script:ContentLibDrive,$Controls.lst_InvalidPkgLib.SelectedItems -ScriptBlock {
  385. Foreach ($Item in $Args[1..$Args.Length]){
  386. If (Test-Path "$($Args[0]):\SCCMContentLib\PkgLib\$($Item).INI"){
  387. Remove-Item "$($Args[0]):\SCCMContentLib\PkgLib\$($Item).INI"
  388. }
  389. }
  390. }
  391.  
  392. Get-PkgLibPackages
  393. Validate-Buttons
  394. }
  395.  
  396. Function Populate-MissingContent
  397. {
  398. $Controls.lst_MissingContent.Items.Clear()
  399.  
  400. Foreach ($DPPackage in $Script:DPPackageList){
  401. if ($Script:WMIPackageList -notcontains $DPPackage -and $ScriptLPkgLibPackageList -notcontains $DPPackage){
  402. $Controls.lst_MissingContent.Items.Add($DPPackage)
  403. }
  404. }
  405.  
  406.  
  407.  
  408. Foreach ($Package in $Script:FailedContent){
  409. if ( $Package.ServerNalPath -like "*$($Controls.cmb_DistributionPoint.Text)*"){
  410. $Controls.lst_MissingContent.Items.Add($Package.PackageID)
  411. }
  412. }
  413.  
  414.  
  415. }
  416.  
  417. Function Redist-MissingContent
  418. {
  419. $SiteCode = $Controls.txt_SiteCode.Text
  420. Foreach ($Item in $Controls.lst_MissingContent.SelectedItems){
  421. $RedistPackage = Get-WmiObject -Namespace "root\SMS\Site_$Sitecode" -Query "Select * From SMS_DistributionPoint WHERE PackageID='$Item' AND ServerNALPath like '%$($Controls.cmb_DistributionPoint.Text)%'"
  422. $RedistPackage.RefreshNow = $True
  423. $RedistPackage.Put() |out-null
  424. }
  425.  
  426. Get-WMIPackages
  427. Get-PkgLibPackages
  428. Validate-Buttons
  429. }
  430.  
  431. function Start-Validation
  432. {
  433. $Response=[System.Windows.MessageBox]::Show("Start the Content Validation Scheduled task on $($Controls.cmb_DistributionPoint.Text)?",'Content Validation','YesNo','Question')
  434. If ($Response="Yes"){
  435. $smsdpmonRunning=Invoke-Command -ComputerName $Controls.cmb_DistributionPoint.Text -ScriptBlock {If ((Get-Process | Where-Object {$_.Name -eq "smsdpmon"}).Count -gt 0){$True}else{$False}}
  436. If ($smsdpmonRunning -ne $True){
  437. Try{
  438. Invoke-Command -ComputerName $Controls.cmb_DistributionPoint.Text -ScriptBlock {Get-ScheduledTask -TaskName "Content Validation" | Start-ScheduledTask} -ErrorAction Stop
  439. [System.Windows.MessageBox]::Show('Content Validation started','Success','OK','Information')
  440. }
  441. Catch{
  442. [System.Windows.MessageBox]::Show('Error starting Content Validation','Error','OK','Error')
  443. }
  444. } else {
  445. [System.Windows.MessageBox]::Show("Content Validation is already running on $($Controls.cmb_DistributionPoint.Text).",'Error','OK','Error')
  446. }
  447. }
  448. }
  449.  
  450. function Validate-Buttons
  451. {
  452. If ($Controls.cmb_DistributionPoint.SelectedIndex -ge 0 -and $Script:Running -eq $False){
  453. $Controls.btn_Check.IsEnabled=$True
  454. } else {
  455. $Controls.btn_Check.IsEnabled=$False
  456. }
  457.  
  458. If (($Controls.lbl_DPStatus.Content -eq "Online") -and ($Controls.lbl_PkgLib.Content-eq $Controls.lbl_Deployed.Content) -and ($Controls.lbl_PkgLib.Content-eq $Controls.lbl_Deployed.Content)){
  459. $Controls.btn_Validate.IsEnabled=$True
  460. } else {
  461. $Controls.btn_Validate.IsEnabled=$False
  462. }
  463.  
  464. If ($Controls.lst_InvalidWMI.Items.Count -gt 0){$Controls.btn_InvalidWMI.IsEnabled = $True} else {$Controls.btn_InvalidWMI.IsEnabled = $False}
  465. If ($Controls.lst_InvalidPkgLib.Items.Count -gt 0){$Controls.btn_InvalidPkgLib.IsEnabled = $True} else {$Controls.btn_InvalidPkgLib.IsEnabled = $False}
  466. If ($Controls.lst_MissingContent.Items.Count -gt 0){$Controls.btn_MissingContent.IsEnabled = $True} else {$Controls.btn_MissingContent.IsEnabled = $False}
  467.  
  468. }
  469.  
  470. Function Reset-Form
  471. {
  472. Foreach ($Control in $Controls.lbl_DPStatus,$Controls.lbl_Deployed,$Controls.lbl_WMI,$Controls.lbl_PkgLib){
  473. $Control.Content="---"
  474. $Control.Visibility="Visible"
  475. $Control.Foreground="Black"
  476. }
  477.  
  478. Foreach ($Control in $Controls.med_DPStatus,$Controls.med_Deployed){
  479. $Control.Visibility="Collapsed"
  480. }
  481.  
  482. $Controls.lst_InvalidWMI.Items.Clear()
  483. $Controls.lst_InvalidPkgLib.Items.Clear()
  484. $Controls.lst_MissingContent.Items.Clear()
  485.  
  486. [System.Windows.Forms.Application]::DoEvents()
  487. }
  488.  
  489. [void]$Form.Showdialog()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement