-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDownload_Manager_Dell_App_V1_3_8.ps1
1283 lines (937 loc) · 54.6 KB
/
Download_Manager_Dell_App_V1_3_8.ps1
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<#
_author_ = Sven Riebe <[email protected]>
_twitter_ = @SvenRiebe
_version_ = 1.3.8
_Dev_Status_ = Test
Copyright ©2023 Dell Inc. or its subsidiaries. All Rights Reserved.
No implied support and test in test environment/device before using in any production environment.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#>
<#Version Changes
1.0.0 inital version
1.0.1 Install.XML with Command Line Informations will now saved in Installer directory
1.0.2 download_log_date(yyyymmdd).xml loging details
1.0.3 Archiving old catalog XML to a Archiving folder if a new catalog will be downloaded
1.1.0 Add Application download for Dell Trusted Device and change Dell Display Manager download for Version 1.x to 2.x
1.1.1 Correction Function function Download-Dell unplaned delete of folders if delete older folders is enabled.
1.1.2 Correction failure if no Temp folder is exist
1.2.0 Updating Download function Dell-Download
1.3.1 Move to selenius browser automation for download of Trusted Device / Display Manager 2.x
migrate single Var´s to Arrays
integrate Dell Display Manager 1.x download
1.3.2 Issue for DTD and DDM Download www.dell.com/support switch to dynamic xPath. Change query concept to cover this by element search.
1.3.3 add Dell Peripheral Manager
1.3.4 Update Trusted Device download from old .ZIP to new.EXE for new Package Format.
1.3.5 Update function Create-Browser
1.3.6 Dell website using wrong format for version of Display Manager 2x. filter and correct this informations now if needed
1.3.7 correction of downloading Dell Trusted Device Agent to cover diverend default languages of browser
1.3.8 delete DDM legacy, correction download catalog file, update function create-browser
Knowing Issues
- If a app in catalog is changed from published to expired the deletion of this folder be script does not work anymore.
The reason is the function made a preselection and ignore all expired apps the $App_Folder will be empty for this version
and deletion need to do manual.
- If you using Version older than 1.0.3 you need to delete the Software Repository to generate Install.XML
#>
<#
.Synopsis
This PowerShell is checking the DellSDPCatalogPC.CAB form Https://Downloads.dell.com and online dell.com/support. This script will generated new folders and downloading Dell Tools in specific Versions direct from the Dell Support Webpage. Older Files will be ignored or if downloaded in the past the folder will be delete.
IMPORTANT: This scipt need internet connection and https://downloads.dell.com need to be reachable.
IMPORTANT: This script does not reboot the system to apply or query system.
IMPORTANT: Dell Display Manager / Dell Trusted Device using selenius browser automation to download informations from dell.com/support
.DESCRIPTION
Powershell is generate a Dell App repository managed by App Name and Version. Software downloads could be enabled by Software.
#>
#########################################################################################################
#### Variable Section ####
#########################################################################################################
################################################
#### Download selected Applications ####
################################################
##########################################
#### possible Value: Enabled/Disabled ####
##########################################
$DownloadSoftware = @(
[PSCustomObject]@{Name = "Dell Command | Monitor"; UpdateStatus = $true; Version = "10.5.1.114"; Matchcode = "*Command*Monitor*"; Source = "SCCM"; Foldername = "Dell Command Monitor"}
[PSCustomObject]@{Name = "Dell Command | Configure"; UpdateStatus = $true; Version = "4.5.0.205"; Matchcode = "*Command*Configure*"; Source = "SCCM"; Foldername = "Dell Command Configure"}
[PSCustomObject]@{Name = "Dell Command | Update Legacy"; UpdateStatus = $true; Version = "4.3.0"; Matchcode = "*Command*Update*"; Source = "SCCM"; Foldername = "Dell Command Update W32"}
[PSCustomObject]@{Name = "Dell Command | Update UWP"; UpdateStatus = $true; Version = "4.3.0"; Matchcode = "*Command*Update*Windows*"; Source = "SCCM"; Foldername = "Dell Command Update UWP"}
[PSCustomObject]@{Name = "Dell Digital Delivery"; UpdateStatus = $true; Version = "5.0.49.0"; Matchcode = "Dell*Digital*Delivery*"; Source = "SCCM"; Foldername = "Dell Digital Deliver"}
[PSCustomObject]@{Name = "Dell Optimizer"; UpdateStatus = $true; Version = "2.0.753.0"; Matchcode = "Dell Optimizer*"; Source = "SCCM"; Foldername = "Dell Optimizer"}
[PSCustomObject]@{Name = "Dell Power Manager"; UpdateStatus = $true; Version = "3.9"; Matchcode = "*Power*Manager*"; Source = "SCCM"; Foldername = "Dell Power Manager"}
[PSCustomObject]@{Name = "Dell PremierColor"; UpdateStatus = $true; Version = "6.0.152.0"; Matchcode = "Dell PremierColor*"; Source = "SCCM"; Foldername = "Dell PremierColor"}
[PSCustomObject]@{Name = "Dell RuggedControl Center"; UpdateStatus = $true; Version = "4.3.55.0"; Matchcode = "Dell*Rugged*Control*"; Source = "SCCM"; Foldername = "Dell Rugged Control Center"}
[PSCustomObject]@{Name = "Dell Trusted Device"; UpdateStatus = $true; Version = "3.7.89.0"; Matchcode = "*Dell*Trusted*Device*"; Source = "SCCM"; Foldername = "Dell Trusted Device"}
[PSCustomObject]@{Name = "Dell Display Manager"; UpdateStatus = $true; Version = "2.0.0.135"; Matchcode = "*Display Manager*"; Source = "Online"; Foldername = "Dell Display Manager"}
[PSCustomObject]@{Name = "Dell Peripheral Manager"; UpdateStatus = $true; Version = "1.6.4.0"; Matchcode = "*Peripheral Manager*"; Source = "Online"; Foldername = "Dell Peripheral Manager"}
)
################################################
#### Automatically delete outdated programs ####
################################################
##########################################
#### possible Value: Y/N ####
##########################################
$Folder_Delete = "Y"
##########################################
#### prefered Browser ####
##########################################
$SelectBrowser = "Edge" # Chrome, Edge or Firefox
################################################
#### Names of SCCM Update Catalog Files ####
################################################
$Catalog_Name = "DellSDPCatalogPC.cab"
$Catalog_XML = "DellSDPCatalogPC.xml"
################################################
#### Time variables ####
################################################
$date = Get-Date -Format yyyyMMdd
################################################
#### Webpages used for download ####
################################################
$downloadpages = @(
[PSCustomObject]@{Name = "CatalogFile"; WebPath = "https://downloads.dell.com/catalog/$Catalog_Name"}
[PSCustomObject]@{Name = "Dell Trusted Device"; WebPath = "https://www.dell.com/support/home/de-de/product-support/product/trusted-device/drivers"}
[PSCustomObject]@{Name = "Dell Display Manager"; WebPath = "https://www.dell.com/support/home/de-de/product-support/product/dell-display-peripheral-manager/drivers"}
[PSCustomObject]@{Name = "Dell Peripheral Manager"; WebPath = "https://www.dell.com/support/home/de-de/product-support/product/dell-display-peripheral-manager/drivers"}
)
################################################
#### local Folders ####
################################################
$ENVFolder = @(
[PSCustomObject]@{Name = "Software Repository"; FSPath = "C:\Dell\SoftwareRepository"} # Software folder
[PSCustomObject]@{Name = "Temporary Folder"; FSPath = "C:\Temp"} # Logging folder
[PSCustomObject]@{Name = "Archive Folder"; FSPath = "C:\Dell\SoftwareRepository\Catalog_Archive"} # Archive folder for older catalogs
)
#########################################################################################################
#### Function Section ####
#########################################################################################################
#####################################################
#### Function preparation for Browser automation ####
#### SOURCE: ####
#### https://administrator.de/tutorial/powershell-einfuehrung-in-die-webbrowser-automation-mit-selenium-webdriver-1197173647.html ####
#####################################################
function Create-Browser
{
param(
[Parameter(mandatory=$true)][ValidateSet('Chrome','Edge','Firefox')][string]$browser,
[Parameter(mandatory=$false)][bool]$HideCommandPrompt = $true,
[Parameter(mandatory=$false)][string]$driverversion = '',
[Parameter(mandatory=$false)][object]$options = $null
)
$driver = $null
function Load-NugetAssembly {
[CmdletBinding()]
param(
[string]$url,
[string]$name,
[string]$zipinternalpath,
[switch]$downloadonly
)
if($psscriptroot -ne ''){
$localpath = join-path $psscriptroot $name
}else{
$localpath = join-path $env:TEMP $name
}
$tmp = "$env:TEMP\$([IO.Path]::GetRandomFileName())"
$zip = $null
try{
if(!(Test-Path $localpath)){
Add-Type -A System.IO.Compression.FileSystem
write-host "Downloading and extracting required library '$name' ... " -F Green -NoNewline
(New-Object System.Net.WebClient).DownloadFile($url, $tmp)
$zip = [System.IO.Compression.ZipFile]::OpenRead($tmp)
$zip.Entries | ?{$_.Fullname -eq $zipinternalpath} | %{
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($_,$localpath)
}
write-host "OK" -F Green
}
if (Get-Item $localpath -Stream zone.identifier -ea SilentlyContinue){
Unblock-File -Path $localpath
}
if(!$downloadonly.IsPresent){
Add-Type -Path $localpath -EA Stop
}
}catch{
throw "Error: $($_.Exception.Message)"
}finally{
if ($zip){$zip.Dispose()}
if(Test-Path $tmp){del $tmp -Force -EA 0}
}
}
# Load Selenium Webdriver .NET Assembly and dependencies
Load-NugetAssembly 'https://www.nuget.org/api/v2/package/Newtonsoft.Json' -name 'Newtonsoft.Json.dll' -zipinternalpath 'lib/net45/Newtonsoft.Json.dll' -EA Stop
Load-NugetAssembly 'https://www.nuget.org/api/v2/package/Selenium.WebDriver/4.23.0' -name 'WebDriver.dll' -zipinternalpath 'lib/netstandard2.0/WebDriver.dll' -EA Stop
if($psscriptroot -ne ''){
$driverpath = $psscriptroot
}else{
$driverpath = $env:TEMP
}
switch($browser){
'Chrome' {
$chrome = Get-Package -Name 'Google Chrome' -EA SilentlyContinue | select -F 1
if (!$chrome){
throw "Google Chrome Browser not installed."
return
}
Load-NugetAssembly "https://www.nuget.org/api/v2/package/Selenium.WebDriver.ChromeDriver/$driverversion" -name 'chromedriver.exe' -zipinternalpath 'driver/win32/chromedriver.exe' -downloadonly -EA Stop
# create driver service
$dService = [OpenQA.Selenium.Chrome.ChromeDriverService]::CreateDefaultService($driverpath)
# hide command prompt window
$dService.HideCommandPromptWindow = $HideCommandPrompt
# create driver object
if ($options){
$driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver $dService,$options
}else{
$driver = New-Object OpenQA.Selenium.Chrome.ChromeDriver $dService
}
}
'Edge' {
$edge =Get-Package -Name 'Microsoft Edge' -EA SilentlyContinue | select -F 1
if (!$edge){
throw "Microsoft Edge Browser not installed."
return
}
Load-NugetAssembly "https://www.nuget.org/api/v2/package/Selenium.WebDriver.MSEdgeDriver.win32/$driverversion" -name 'msedgedriver.exe' -zipinternalpath 'driver/win32/msedgedriver.exe' -downloadonly -EA Stop
# create driver service
$dService = [OpenQA.Selenium.Edge.EdgeDriverService]::CreateDefaultService($driverpath)
# hide command prompt window
$dService.HideCommandPromptWindow = $HideCommandPrompt
# create driver object
if ($options){
$driver = New-Object OpenQA.Selenium.Edge.EdgeDriver $dService,$options
}else{
$driver = New-Object OpenQA.Selenium.Edge.EdgeDriver $dService
}
}
'Firefox' {
$ff = Get-Package -Name "Mozilla Firefox*" -EA SilentlyContinue | select -F 1
if (!$ff){
throw "Mozilla Firefox Browser not installed."
return
}
Load-NugetAssembly "https://www.nuget.org/api/v2/package/Selenium.WebDriver.GeckoDriver/$driverversion" -name 'geckodriver.exe' -zipinternalpath 'driver/win64/geckodriver.exe' -downloadonly -EA Stop
# create driver service
$dService = [OpenQA.Selenium.Firefox.FirefoxDriverService]::CreateDefaultService($driverpath)
# hide command prompt window
$dService.HideCommandPromptWindow = $HideCommandPrompt
# create driver object
if($options){
$driver = New-Object OpenQA.Selenium.Firefox.FirefoxDriver $dService, $options
}else{
$driver = New-Object OpenQA.Selenium.Firefox.FirefoxDriver $dService
}
}
}
return $driver
}
#####################################################
#### Function check environment folder exit ####
#####################################################
function get-Folderstatus {
param(
[Parameter(mandatory=$true)][string]$FolderName,
[Parameter(mandatory=$false)][string]$FolderPath
)
#Check if Folder is availible, if not it will generate a new folder
If((Test-Path $FolderPath) -ne $true)
{
Write-Output "Folder is not availble will now generate $FolderName"
New-Item -Path $FolderPath -itemType Directory
}
Else
{
Write-Output "$FolderName is available"
}
}
#####################################################
#### Function download Dell Catalog file ####
#####################################################
function get-DellCatalog {
param(
[Parameter(mandatory=$true)][string]$url
)
##############################################################
#Checking if the newest version of catalogs was stored locally
# Checking Header of webpage when last-modified of CAB-File
$result = Invoke-WebRequest -Method HEAD -Uri $url -UseBasicParsing
[datetime]$Catalog_DateOnline = get-date ($result.Headers.'Last-Modified')[0]
#Checking date of modified of local stored catalog files
Set-Location ($ENVFolder | Where-Object Name -eq "Temporary Folder").FSPath
If ((Test-Path $Catalog_Name) -ne "True")
{
[datetime]$Catalog_DateLocal = $Catalog_DateOnline.AddDays(-1)
}
else
{
[datetime]$Catalog_DateLocal = Get-ItemProperty $Catalog_Name | Select-Object -ExpandProperty LastWriteTime
}
# New Catalog will only download and extract the Catalog if Online version is newer than local version
If ($Catalog_DateOnline -gt $Catalog_DateLocal)
{
# Download the catalog File newest version
Invoke-WebRequest -Uri $url -OutFile ($ENVFolder | Where-Object Name -eq "Temporary Folder").FSPath -Headers @{ "User-Agent" = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3" }
#checking if XML file exist in ($ENVFolder | Where-Object Name -eq "Temporary Folder").FSPath
$FileCheck = ($ENVFolder | Where-Object Name -eq "Temporary Folder").FSPath+"\"+$Catalog_XML
$Catalog_XML_Check = Test-Path -Path $FileCheck
If ($Catalog_XML_Check -eq "True")
{
#Archiving old Catalog XML to Software Repository Archiving folder
#Source and destination string prepare
$Archive_Source = ($ENVFolder | Where-Object Name -eq "Temporary Folder").FSPath+"\"+$Catalog_XML
$Archive_Destination = ($ENVFolder | Where-Object Name -eq "Archive Folder").FSPath+"\"+$date+$Catalog_XML
#move file to repository
write-host "Older $Catalog_XML is existing and will be archived now to $Archive_Destination"
Move-Item $Archive_Source -Destination $Archive_Destination -Force
# Extract Catalog XML-File form existing CAB-File
# Change directory
Set-Location ($ENVFolder | Where-Object Name -eq "Temporary Folder").FSPath
Write-Output "Catalog XML will be extracted to Temporary Folder"
# Extract DellSDPCatalogPC.xml from CAB-File
expand $Catalog_Name . -f:$Catalog_XML
}
Else
{
Write-Output "Temporary Folder do not include an old file $Catalog_XML for archiving"
# Extract Catalog XML-File form existing CAB-File
# Change directory
Set-Location ($ENVFolder | Where-Object Name -eq "Temporary Folder").FSPath
Write-Output "Catalog XML will be extracted to Temporary Folder"
# Extract DellSDPCatalogPC.xml from CAB-File
expand $Catalog_Name . -f:$Catalog_XML
}
}
Else
{
Write-Output "No newer Catalog is availible"
Write-Output "Checking if XML is stored in Temporary Folder"
#checking if XML file exist in ($ENVFolder | Where-Object Name -eq "Temporary Folder").FSPath
$FileCheck = ($ENVFolder | Where-Object Name -eq "Temporary Folder").FSPath+"\"+$Catalog_XML
$Catalog_XML_Check = Test-Path -Path $FileCheck
If ($Catalog_XML_Check -eq "True")
{
Write-Output "Catalog XML is existing in Temporary Folder"
}
Else
{
Write-Output "Temporary Folder do not include an $Catalog_XML"
# Extract Catalog XML-File form existing CAB-File
# Change directory
Set-Location ($ENVFolder | Where-Object Name -eq "Temporary Folder").FSPath
Write-Output "Catalog XML will be extracted to Temporary Folder"
# Extract DellSDPCatalogPC.xml from CAB-File
expand $Catalog_Name . -f:$Catalog_XML
}
}
}
#####################################################
#### Function download with SCCM Catalog ####
#####################################################
### Function is for all Applications excl. Dell Trusted Device and Dell Display Manager 2.x and newer
function get-SCCMSoftware
{
# Parameter
param(
[Parameter(mandatory=$true)][string]$Software_Name,
[Parameter(mandatory=$true)][version]$Software_Version,
[Parameter(mandatory=$true)][string]$App_Folder_Main
)
#Prepare Download struture
Set-Location ($ENVFolder | Where-Object Name -eq "Software Repository").FSPath
Write-Host "Checking if Application folder exist"
If ((Test-Path $App_Folder_Main) -ne "True")
{
# generate new main software folder
Write-Host "New $App_Folder_Main will generate"
New-Item $App_Folder_Main -ItemType Directory
}
else
{
Write-Host "$App_Folder_Main is availible"
}
Set-Location $App_Folder_Main
#Prepare Download details
$Dell_App_Select = $Catalog_DATA.SystemsManagementCatalog.SoftwareDistributionPackage | Where-Object{$_.LocalizedProperties.Title -like "$Software_Name"}
$Dell_App_Download = $Dell_App_Select | Where-Object {$_.Properties.PublicationState -ne "Expired"}
#Checking Dell Command Update Win32 or UWP App - Deselect not relevant Software first before prepare download
If ($Software_Name -eq ($DownloadSoftware | Where-Object Name -eq "Dell Command | Update Legacy").Matchcode)
{
$Dell_App_Download = $Dell_App_Download | Where-Object {$_.LocalizedProperties.Description -notlike "*Universal*"}
}
foreach ($i in $Dell_App_Download)
{
# Taking Version number form Title String
[Version]$App_Folder = ($i.LocalizedProperties.title -split ",")[1]
If ($Software_Version -le $App_Folder)
{
# Checking how much files are stored in this folder. If 0 the file will reload again
$File_Count = Get-ChildItem -Path $App_Folder -Recurse | Measure-Object | Select-Object -ExpandProperty Count
if ($File_Count -lt 1)
{
New-Item $App_Folder -ItemType Directory
Set-Location $App_Folder
# download files
Invoke-WebRequest -Uri $i.InstallableItem.OriginFile.OriginUri -OutFile .\ -Headers @{ "User-Agent" = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3" }
Write-Output $i.localizedproperties.title "was downloaded to machine"
#generate a XML with install instructions selected of Dell SCCM catalog file
$XMLInstallFile = ($ENVFolder | Where-Object Name -eq "Software Repository").FSPath+"\"+$App_Folder_Main+"\"+$App_Folder+"\Install.xml"
$xmlInstComm = New-Object System.Xml.XmlTextWriter($XMLInstallFile,$null)
#Formating XML File
$xmlInstComm.Formatting = "Indented"
$xmlInstComm.Indentation = "1"
$xmlInstComm.IndentChar = "`t"
#writing datas
$xmlInstComm.WriteStartDocument()
$xmlInstComm.WriteStartElement("InstallInformations")
$xmlInstComm.WriteStartElement("Application")
$xmlInstComm.WriteStartElement("CommandLineData")
$xmlInstComm.WriteAttributeString("Name",$i.Localizedproperties.title)
$xmlInstComm.WriteAttributeString("Arguments",$i.InstallableItem.CommandLineInstallerData.Arguments)
$xmlInstComm.WriteAttributeString("DefaultResult",$i.InstallableItem.CommandLineInstallerData.DefaultResult)
$xmlInstComm.WriteAttributeString("RebootByDefault",$i.InstallableItem.CommandLineInstallerData.RebootByDefault)
$xmlInstComm.WriteAttributeString("Program",$i.InstallableItem.CommandLineInstallerData.Program)
$xmlInstComm.WriteEndElement()
$xmlInstComm.WriteStartElement("PackageData")
$xmlInstComm.WriteAttributeString("VendorName",$i.Properties.VendorName)
$xmlInstComm.WriteAttributeString("CreationDate",$i.Properties.CreationDate)
$xmlInstComm.WriteAttributeString("PackageID",$i.Properties.PackageID)
$xmlInstComm.WriteAttributeString("InfoURL",$i.Properties.MoreInfoUrl)
$xmlInstComm.WriteEndElement()
$xmlInstComm.WriteStartElement("UpdateData")
$xmlInstComm.WriteAttributeString("Severity",$i.UpdateSpecificData.MsrcSeverity)
$xmlInstComm.WriteAttributeString("DriverID",$i.UpdateSpecificData.KBArticleID)
$xmlInstComm.WriteAttributeString("DownloadLink",$i.InstallableItem.OriginFile.OriginUri)
$xmlInstComm.WriteAttributeString("Modified",$i.InstallableItem.OriginFile.Modified)
$xmlInstComm.WriteEndElement()
$xmlInstComm.WriteEndElement()
#Close Document and delete buffer
$xmlInstComm.WriteEndDocument()
$xmlInstComm.Flush()
$xmlInstComm.Close()
Set-Location ..
}
Else
{
Write-Output $i.localizedproperties.title "is existing on the machine"
}
}
Else
{
# Checking how much files are stored in this folder. If 0 the file will reload again
$File_Count = Get-ChildItem -Path $App_Folder -Recurse | Measure-Object | Select-Object -ExpandProperty Count
if ($File_Count -ge 1)
{
#Deleting old Data if $Folder_Delete = Y
If ($Folder_Delete -match "Y")
{
Remove-Item $App_Folder -Force -Recurse
Write-Output $i.localizedproperties.title "is outdated and is now deleted from this device"
}
Else
{
Write-Output $i.localizedproperties.title "is outdated but file is stored on this machine"
}
}
Else
{
Write-Output $i.localizedproperties.title "is outdated and is not downloaded"
}
}
}
Return $Value
}
############################################################
#### Function download with Browser on Dell.com/support ####
############################################################
### Function is for Dell Trusted Device and Dell Display Manager 2.x and newer
function get-OnlineSoftware
{
param
(
[Parameter(mandatory=$true)][string]$Webpage,
[Parameter(mandatory=$true)][string]$Software_Name,
[Parameter(mandatory=$true)][string]$App_Folder_Main,
[Parameter(mandatory=$true)][version]$Software_Version,
[Parameter(mandatory=$true)][string]$Browser
)
#Prepare Download struture
Set-Location ($ENVFolder | Where-Object Name -eq "Software Repository").FSPath
Write-Host "Checking if Application folder exist"
If ((Test-Path $App_Folder_Main) -ne "True")
{
# generate new main software folder
Write-Host "New $App_Folder_Main will generate"
New-Item $App_Folder_Main -ItemType Directory
}
else
{
Write-Host "$App_Folder_Main is availible"
}
Set-Location $App_Folder_Main
### Start install selenium for download Webpage informations and files
$EdgeAuto = Create-Browser -browser Edge #$Browser
$EdgeAuto.Manage().Window.Minimize()
$EdgeAuto.Url = $Webpage
# wait stepp to be secure website is full loaded
Start-Sleep -Seconds 5
#expand driver informations in browser
if ($App_Folder_Main -like "*Trusted*")
{
# open drop down menue on webpage
($EdgeAuto.FindElements([OpenQA.Selenium.By]::TagName("button")) | where-Object ComputedAccessibleLabel -Like "*Trusted*Agent*" | Where-Object ComputedAccessibleLabel -notlike "*Scripts*").click()
# get version of app from dell.com/support for Trusted Device Agent
Write-Host "Search online for newest software version"
$AppVersionOnlineTemp = ($EdgeAuto.FindElements([OpenQA.Selenium.By]::Classname("mb-0")) | where-object text -Clike "*.*,*" | Where-Object Text -notlike "*Agent*").Text.Split(",")
#exclude Revision and store Version in format version
[Version]$AppVersionOnline = $AppVersionOnlineTemp[0]
}
if ($App_Folder_Main -like "*Peripheral*")
{
# used for Dell Peripheral Manager
# open drop down menue on webpage
($EdgeAuto.FindElements([OpenQA.Selenium.By]::TagName("button")) | where-Object ComputedAccessibleLabel -Like "*Dell*Peripheral*Manager*" | Where-Object ComputedAccessibleLabel -Notlike "*Dell*Display*Manager*").click()
# get version of app from dell.com/support for Dell Peripheral Manager
Write-Host "Search online for newest software version"
$AppVersionOnlineTemp = ($EdgeAuto.FindElements([OpenQA.Selenium.By]::Classname("mb-0")) | where-object text -like "*|*").Text.Split(",")
#exclude Revision and store Version in format version
[Version]$AppVersionOnline = $AppVersionOnlineTemp[0]
}
if ($App_Folder_Main -like "*Display Manager*")
{
# used for Dell Display Manager 2.x and newer
# open drop down menue on webpage
($EdgeAuto.FindElements([OpenQA.Selenium.By]::TagName("button")) | where-Object ComputedAccessibleLabel -Like "*Dell*Display*Manager*" | Where-Object ComputedAccessibleLabel -Notlike "*Peripheral*").click()
# get version of app from dell.com/support for Trusted Device Agent
Write-Host "Search online for newest software version"
$AppVersionOnlineTemp = ($EdgeAuto.FindElements([OpenQA.Selenium.By]::Classname("mb-0")) | where-object text -like "*|*").text
$AppVersionOnlineTemp = $AppVersionOnlineTemp.Replace("v","")
$AppVersionOnlineTemp =$AppVersionOnlineTemp.Split(",")
#exclude Revision and store Version in format version
[Version]$AppVersionOnline = $AppVersionOnlineTemp[0]
}
### Check if folder with same Version is still existing
Write-Host "Checking if Subfolder is availible"
If ((Test-Path $AppVersionOnline) -ne $true)
{
Write-Host "New Subfolder $AppVersionOnline will generate"
# generate new Version folder
New-Item $AppVersionOnline -ItemType Directory
}
else
{
Write-Host "Subfolder $AppVersionOnline is available"
}
Set-Location $AppVersionOnline
# Checking how much files are stored in this folder. If 0 the file will reload again
$File_Count = Get-ChildItem -Path $App_Folder -Recurse | Measure-Object | Select-Object -ExpandProperty Count
if($File_Count -gt 1)
{
Write-Output "$App_Folder_Main $AppVersionOnline" "is existing on the to machine"
# Close Browser
$EdgeAuto.Close()
}
Else
{
Write-Output "$App_Folder_Main $AppVersionOnline is downloading to machine"
# get download path of app from dell.com/support
if ($App_Folder_Main -like "*Trusted*")
{
# Download Dell Trusted Device Agent
($EdgeAuto.FindElements([OpenQA.Selenium.By]::Classname("btn-download-lg"))| Where-Object ComputedAccessibleLabel -like "*Trusted*Agent*")[0].click()
}
if ($App_Folder_Main -like "*Peripheral*")
{
# Download Dell Peripheral Manager
($EdgeAuto.FindElements([OpenQA.Selenium.By]::Classname("btn-download-lg"))| Where-Object ComputedAccessibleLabel -like "*Peripheral*" ).click()
}
if ($App_Folder_Main -like "*Display Manager*")
{
# Download Dell Display Manager 2.x
($EdgeAuto.FindElements([OpenQA.Selenium.By]::Classname("btn-download-lg"))| Where-Object ComputedAccessibleLabel -like "*Display*" ).click()
}
Write-Host "File Download is startet, please do not close the Browser"
# wait of finializing download
Start-Sleep -Seconds 15
### handling file copy different between DTD and DDM
If ($Software_Name -like "*Trusted Device*")
{
Set-Location $env:USERPROFILE\Downloads
#checking if download is final if not add 10 sec download time
$checkDownload = Test-Path -Path .\Trusted-Device-Agent*.exe
If ($checkDownload -eq $true)
{
$FileName = Get-ChildItem -Path .\Trusted-Device-Agent*.exe
Write-Host $FileName.Name "is finished to download"
}
else
{
# download is not finished yet extand time before closing browser
Write-Host "Download is not finished yet, please wait"
Start-Sleep -Seconds 15
}
$checkDownload = $checkDownload = Test-Path -Path .\Trusted-Device-Agent*.exe
If ($checkDownload -eq $true)
{
$TargetFS = ($ENVFolder | Where-Object Name -eq "Software Repository").FSPath+"\"+$App_Folder_Main+"\"+$AppVersionOnline
Write-Host "move File $FileName to $TargetFS"
Move-Item $FileName -Destination $TargetFS -Force
# xml parameter for this application install.xml
$Argument = "/qn REBOOT=R"
$RebootbyDefault = $true
# Close Browser
$EdgeAuto.close()
}
else
{
# download takes to long or automation does not working correctly
Write-Host "Dell Trusted Device is not downloaded, please check if you have a problem with internet connection or browser automation works correctly"
# Close Browser
$EdgeAuto.close()
}
}
If ($Software_Name -like "*Display Manager*")
{
Set-Location $env:USERPROFILE\Downloads
# Name of file to download
$fileName64Bit = "ddmsetup.exe"
#checking if download is final if not add 10 sec download time
$checkDownload = Test-Path -Path .\$fileName64Bit
If ($checkDownload -eq $true)
{
Write-Host ".\ddmsetup.exe is finished to download"
}
else
{
# download is not finished yet extand time before closing browser
Write-Host "Download is not finished yet, please wait"
Start-Sleep -Seconds 15
}
$checkDownload = Test-Path -Path .\$fileName64Bit
If ($checkDownload -eq $true)
{
$TargetFS = ($ENVFolder | Where-Object Name -eq "Software Repository").FSPath+"\"+$App_Folder_Main+"\"+$AppVersionOnline
Write-Host "move File ddmsetup.exe to $TargetFS"
Move-Item $fileName64Bit -Destination $TargetFS -Force
# xml parameter for this application install.xml
$Argument = '/verysilent Silent /TelemetryConsent="false" /noupdate'
$RebootbyDefault = $false
# Close Browser
$EdgeAuto.close()
}
else
{
# download takes to long or automation does not working correctly
Write-Host ".\ddmsetup.exe is not downloaded, please check if you have a problem with internet connection or browser automation works correctly"
# Close Browser
$EdgeAuto.close()
}
}
If ($Software_Name -like "*Peripheral*")
{
Set-Location $env:USERPROFILE\Downloads
# Name of file to download
$fileName64Bit = "DPeM*.exe"
#checking if download is final if not add 15 sec download time
$checkDownload = Test-Path -Path .\$fileName64Bit
If ($checkDownload -eq $true)
{
$fileName64Bit = get-Item -Path '.\DPeM*.exe' | Select-Object -ExpandProperty Name
Write-Host "$fileName64Bit is finished to download" -BackgroundColor Green
}
else
{
# download is not finished yet extand time before closing browser
Write-Host "Download is not finished yet, please wait" -BackgroundColor Yellow
Start-Sleep -Seconds 15
}
$checkDownload = Test-Path -Path .\$fileName64Bit
If ($checkDownload -eq $true)
{
$fileName64Bit = get-Item -Path '.\DPeM*.exe' | Select-Object -ExpandProperty Name
$TargetFS = ($ENVFolder | Where-Object Name -eq "Software Repository").FSPath+"\"+$App_Folder_Main+"\"+$AppVersionOnline
Write-Host "move File $fileName64Bit to $TargetFS"
Move-Item $fileName64Bit -Destination $TargetFS -Force
# xml parameter for this application install.xml
$Argument = '/S'
$RebootbyDefault = $false
# Close Browser
$EdgeAuto.close()
}
else
{
# download takes to long or automation does not working correctly
Write-Host "Dell Peripheral Manager is not downloaded, please check if you have a problem with internet connection or browser automation works correctly"
# Close Browser
$EdgeAuto.close()
}
}
#generate a XML with install instructions
$XMLInstallFile = ($ENVFolder | Where-Object Name -eq "Software Repository").FSPath+"\"+$App_Folder_Main+"\"+$AppVersionOnline+"\Install.xml"
$xmlInstComm = New-Object System.Xml.XmlTextWriter($XMLInstallFile,$null)
#Formating XML File
$xmlInstComm.Formatting = "Indented"
$xmlInstComm.Indentation = "1"
$xmlInstComm.IndentChar = "`t"
#writing datas
$xmlInstComm.WriteStartDocument()
$xmlInstComm.WriteStartElement("InstallInformations")
$xmlInstComm.WriteStartElement("Application")
$xmlInstComm.WriteStartElement("CommandLineData")
$xmlInstComm.WriteAttributeString("Name",$App_Folder_Main)
$xmlInstComm.WriteAttributeString("Arguments",$Argument)
$xmlInstComm.WriteAttributeString("DefaultResult","")
$xmlInstComm.WriteAttributeString("RebootByDefault",$RebootbyDefault)
$xmlInstComm.WriteAttributeString("Program",$fileName64Bit)
$xmlInstComm.WriteEndElement()
$xmlInstComm.WriteStartElement("PackageData")
$xmlInstComm.WriteAttributeString("VendorName","Dell Inc.")
$xmlInstComm.WriteAttributeString("CreationDate","")
$xmlInstComm.WriteAttributeString("PackageID","")
$xmlInstComm.WriteAttributeString("InfoURL",$Webpage)
$xmlInstComm.WriteEndElement()
$xmlInstComm.WriteStartElement("UpdateData")
$xmlInstComm.WriteAttributeString("Severity","")
$xmlInstComm.WriteAttributeString("DriverID","")
$xmlInstComm.WriteAttributeString("DownloadLink","")
$xmlInstComm.WriteAttributeString("Modified","")
$xmlInstComm.WriteEndElement()
$xmlInstComm.WriteEndElement()
#Close Document and delete buffer
$xmlInstComm.WriteEndDocument()
$xmlInstComm.Flush()
$xmlInstComm.Close()
}
If ($Folder_Delete -match "Y")
{
Set-Location ($ENVFolder | Where-Object Name -eq "Software Repository").FSPath
Set-Location $App_Folder_Main
### Delete older folder if deletion is selected
$FolderNameOld = Get-ChildItem | Select-Object -ExpandProperty Name
foreach ($Name in $FolderNameOld)
{
[Version]$Name = $Name
if($Name -ge $Software_Version)
{
Write-Output "$App_Folder_Main $Name" "is outdated/UptoDate and not deleted from this device"
}
Else
{
Write-Output "$App_Folder_Main $Name" "is outdated and is now deleted from this device"
Remove-Item $Name -Recurse -Force
}
}
}
}
############################################################
#### Function download delldisplaymanager.com ####
############################################################
### Function is for Dell Display Manager 1.x
function get-ddmlegacy
{