Created
February 20, 2022 10:49
-
-
Save jazzbanzai/36f81008429724134b2a39fe72b3e521 to your computer and use it in GitHub Desktop.
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
#REF1: https://www.dell.com/support/kbdoc/en-in/000126566/windows-how-to-identify-your-dell-docking-station-using-powershell | |
Set-Location -Path C:\temp | |
$dellcabURL = 'https://downloads.dell.com/catalog/DellSDPCatalogPC.cab' | |
$fileName = $dellcabURL.Substring($dellcabURL.LastIndexOf('/') + 1) | |
#Download Dell Cab | |
Invoke-WebRequest -URI $dellcabURL -UseBasicParsing -OutFile "c:\temp\$fileName" | |
#Extact DellSDPCatalogPC.xml | |
& extrac32.exe "c:\temp\$fileName" DellSDPCatalogPC.xml /Y | |
#find the line (would be beettr ro pharse the XML) | |
$MSIregex = 'https:\/\/.*DSIA.*.msi' | |
$DellMSI = Get-Content -Path "c:\temp\DellSDPCatalogPC.xml" | Select-String -pattern $MSIregex | foreach {$_.Matches.Value} | |
#Download install the Dell-MSI (dell client system inventory agent) | |
$fileName = $DellMSI.Substring($DellMSI.LastIndexOf('/') + 1) | |
Invoke-WebRequest -Uri $DellMSI -UseBasicParsing -OutFile "c:\temp\$fileName" | |
Start-Process msiexec.exe -Wait -ArgumentList "/i `"C:\temp\$fileName`" /qn /l*v `"C:\temp\$fileName.log`" " | |
#get inventory +dock | |
gwmi -n root\dell\sysinv dell_softwareidentity | select * | where elementname -like "*WD*" |
Was just posted here for this reddit thread:
https://www.reddit.com/r/Dell/comments/glmgge/tip_how_to_get_a_docking_station_serial_number/
I'm sure there are definitely better ways to-do it. (Including correcting all my spelling mistakes)
PS. If its a new'er' dock - like the WD19 - can use the Firmware tool to scrape the Serial Number info.
That is the thread that I'd gotten the gist from :D
I was looking for a way to do the same thing programmatically as I have too
many machines to do that in a time effective manner by hand.
I'll use your code as a basis to make a batch (or learn powershell) and
have it usable in remote management systems. Might be a while cause I suck
at coding these days -- dont use it, lose it.
…On Tue, Nov 29, 2022 at 3:07 PM jazzbanzai ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Was just posted here for this reddit thread:
https://www.reddit.com/r/Dell/comments/glmgge/tip_how_to_get_a_docking_station_serial_number/
I'm sure there are definitely better ways to-do it. (Including correcting
all my spelling mistakes)
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/36f81008429724134b2a39fe72b3e521#gistcomment-4385261>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALOXK27ZENLURVLD4PB35UTWKZO6ZBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTCNBYGI2TMMZTU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
I know this is a tad old, just came across this and modified it for our use, figured I'd share.
#REF1: https://www.dell.com/support/kbdoc/en-in/000126566/windows-how-to-identify-your-dell-docking-station-using-powershell
$path = "$env:temp"
Set-Location -Path $path
$dellcabURL = 'https://downloads.dell.com/catalog/DellSDPCatalogPC.cab'
$fileName = "$path\$($dellcabURL.Substring($dellcabURL.LastIndexOf('/') + 1))"
#Download Dell Cab
(New-Object net.webclient).Downloadfile($dellcabURL, $fileName) #I find this is faster than Invoke-WebRequest
#Extact DellSDPCatalogPC.xml
Start-Process extrac32.exe -Wait -ArgumentList "$fileName DellSDPCatalogPC.xml /Y"
#find the line (would be beettr ro pharse the XML)
$MSIregex = 'https:\/\/.*DSIA.*.msi'
$DellMSI = Get-Content -Path "$path\DellSDPCatalogPC.xml" | Select-String -pattern $MSIregex | foreach {$_.Matches.Value}
#Install the Dell-MSI (dell client system inventory agent)
Start-Process msiexec.exe -Wait -ArgumentList "/i $DellMSI /qn /l*v `"$path\DSIA.log`" " #MSIs can be installed via url
do{
$error.clear
try{
#get inventory +dock
Get-CimInstance -Namespace root\dell\sysinv -ClassName dell_softwareidentity -ErrorAction Stop | select ElementName,SerialNumber | where elementname -like "*WD*"
}
catch{
Write-Output "CimInstance not ready"
Start-Sleep -Seconds 5
}
} while ($error) #found that it would take time for the namespace to be available.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey.
Love that this is automated to the point it could potentially run as a script for an MSP or company; however, it seems that you have to run the script multiple times - the failures seem to indicate that the commands are not waiting for completion before continuing execution.
Unfortunately I'm not versed enough in powershell to correct this. Any possibility that you might be able to update this to make the commands execute and wait?
I could possibly re-write this to use batch and helper programs like wget, but powershell seems like a more elegant solution.