Space Engineers

Space Engineers

Not enough ratings
Generate list of MOD IDs from single Mod Collection - PowerShell
By Archimedez
A simple PowerShell script that will generate a list of MOD IDs from a single MOD collection URL so that you can copy and paste the list into your dedicated server MOD list, making life that much easier. :D

Just change the URL to the one of your target MOD collection page, and edit the Output file path and name. Run it!
   
Award
Favorite
Favorited
Unfavorite
Script 1.1
Thanks for the various input from users to help others. Figured it was past due for an update, so here it is. Enjoy.


# =============================================================================
# Generate MOD ID list from a Steam Mod Collection URL
# Created by Archimedez
# Last Modified 2020-01-31
# Version 1.1
# Usage:
# 1) Create a file named: ModIDlist.ps1
# 2) Paste this code into the file
# 3) Edit the $WorkshopCollectionURL value between the '', replacing it with the URL of your mod collection
# 4) Optional: Edit the $ModList value between the '', replacing it with the path of your choice
# 5) Right-Click the file (ModIDlist.ps1), and Click Run With PowerShell
# =============================================================================
# Configurable Options Below
# =============================================================================

# Set the URL of your MOD Collection
$WorkshopCollectionURL = 'https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1981518241'

# Set Output Path and Filename of text file which will contain the MOD ID list
# Note: The MOD ID list will also be displayed on screen
$ModList = 'C:\Users\Public\SE_Mods_list.txt'

# Shouldn't need this, but if you do or need to add additional keys/values, its here....
$headers = @{"Host" = "steamhost.cn/steamcommunity_com"}

# =============================================================================
# Change Nothing Below
# =============================================================================
CLS
$CollectionPage = Invoke-WebRequest -Uri $WorkshopCollectionURL -Headers $headers
$ModURLprefix = 'https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id='
$MODIDs = (($CollectionPage.Links | Where-Object {$_.innerHTML -like "*workshopItemTitle*"} ).href | Where-Object {$_ -like "$ModURLprefix*"} ).replace("$ModURLprefix","")
If (Test-Path -Path $ModList) {del $ModList}
$MODIDs | Out-File -FilePath $ModList
Write-Host "Your MOD ID list is below, and in a file at: $ModList"
$MODIDs
Script 1.0
#========================================================================= # Generate MOD ID List from a Steam Mod Collection URL # Created by Archimedez # Last modified 2017-09-17 # Version 1.0 #========================================================================= cls #Set URL of your Mod Collection for your server $WorkshopCollectionURL = 'https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1039981260' #Set Output Path and Filename of file which will contain MOD ID list #Note: List will also display on screen $modList = 'c:\Users\Public\SE_Server\SE_mods_list.txt' #============================================================================================== #End configurable options #============================================================================================== $getPage = Invoke-WebRequest –Uri $WorkshopCollectionURL $modIDCollection = @() $links = $getPage.Links foreach ($link in $links){ if ($link.innerHTML -like "*workshopItemTitle*" ){ $modID = $link.href.Replace('https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=','') if($modIDCollection -notcontains $modID){ $desc = $link.innerText Write-Host "Found Mod: $desc" $modIDCollection += $modID } } } if (Test-Path $modList) {del $modList} Set-Content -Path $modList $modIDCollection Write-Host "Your mod list is at: $modList" $modIDCollection
15 Comments
Kyru 7 Jan, 2021 @ 1:18pm 
If you're still having issues, you can try replacing "IHTMLDocument2_write" with just "write". Message me if none of these solutions work.
Kyru 7 Jan, 2021 @ 1:17pm 
For those having issues, replace

$getPage = Invoke-WebRequest –Uri $WorkshopCollectionURL

with

$getPageRaw = Invoke-WebRequest –Uri $WorkshopCollectionURL -UseBasicParsing
$getPage = New-Object -Com "HTMLFile"
$getPage.IHTMLDocument2_write($getPageRaw.RawContent)
Kataris 9 Nov, 2020 @ 11:14pm 
This is not working for me. Powershell window hangs after CLS command.
Possemaster 27 Jun, 2020 @ 4:41am 
Invoke-Webrequest does not seem to work anymore in Windows 10 version 2004.
So I created a webbased version in PHP for anyone to use freely with source available;
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2143988926
KaityUK 29 May, 2020 @ 6:19am 
How can I amend this to also include the Mod's Name?
Dobble G1000 1 Mar, 2020 @ 7:29am 
I updated the script to handle having other collection in your collection

https://pastebin.com/Bic9ew8D
Dromus 31 Jan, 2020 @ 11:59am 
dude you are a legend I was trying to setup a gmod server and this helped me so much trying to get fastdl to work and I had to get all the ids of a collection, thank you for saving me the work
IceManRyder 18 Dec, 2019 @ 6:55am 
Just pasted and adapted your code in my PowerShell ISE and it worked perfectly, thank you so much. I need this for Space Engineers Dedicated and copy and paste 122 mods manually is a mayhem :D
Darkly 12 Apr, 2019 @ 11:14pm 
Also, what the heck is that massive frigging hyphen in Uri? it disturbs me with it's presence. and it also ruins powershell scripts. that also needs to be replaced by a normal and much less intimidating hyphen -. nice job other then that btw
Darkly 12 Apr, 2019 @ 11:10pm 
The problem with the script is in line 16,

$getPage = Invoke-WebRequest –Uri $WorkshopCollectionURL

you require additional parameters. you need a Uri, and Headers parameter.

$getPage = Invoke-WebRequest –Uri $WorkshopCollectionURL -Headers @{Authorization ="SubKey $subKey"}

or whateverer to fix this hecking thing. :SBpenguin: