Created
April 18, 2019 00:12
-
-
Save ParadoxGuitarist/923306c6d2f3b1f1941994c407839210 to your computer and use it in GitHub Desktop.
SCCM-Powershell (maybe the worst)
This file contains hidden or 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
# So this has to be run through SCCM. Both by packaging an "App" and calling powershell.exe to run the script, or by adding a script and running it. | |
# Variables | |
# So here's a webpage you want to scrape: | |
$Source = "http://download.videolan.org/pub/videolan/vlc/last/win64/" | |
# This will run locally and give you the latest version of the win64.exe installer. Something like: vlc-3.0.6-win64.exe | |
$Installer = ( Invoke-WebRequest $Source | fl * | Out-String -Stream | sls -Pattern 'win64.exe"' | select-object -First 1 | %{$_ -replace ".*href=.",""} | %{$_ -replace '".*',''} ) | |
# But If you run that same line through SCCM your Installer Variable will be null. | |
# Actually something like this would be the page source code: | |
$SourceCode = ( Invoke-WebRequest "$Source" ) | |
# Again in SCCM this will be null, but running it locally will be fine. | |
# What is weird is that this will produce the webpage both locally and in SCCM | |
Invoke-WebRequest "$Source" -OutFile "C:\example1.html" | |
# But this only works locally: | |
Invoke-WebRequest "$Source" -OutVariable SourceCode | |
Add-content "C:\example2.html" -value $SourceCode | |
# So in SCCM example1.html will have code, but example2.html will be empty. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment