I am pushing a script to devices that downloads and executed exe installation, when checking on device, all is good and the app was pushed to uninstall specific application from the device.
$url = "some url to *.zip"
$DownloadFile = "C:\Users\Public\Downloads" $(Split-Path -Path $url -Leaf)
$ExtractPath = "C:\Users\Public\Downloads"
Invoke-WebRequest -Uri $url -OutFile $DownloadFile
$ExtractShell = New-Object -ComObject Shell.Application
$ExtractFiles = $ExtractShell.Namespace($DownloadFile).Items()
$ExtractShell.Namespace($ExtractPath).CopyHere($ExtractFiles)
Start-Process $ExtractPath
Timeout /T 10
Start-Transcript
Start-Process -FilePath "C:\Users\Public\Downloads\*.exe" -ArgumentList "/S" -PassThru
So, the whole process is finished but in the Intune it shows as failed.
This is error log:
DNS detection: WinHttpGetProxyForUrl call failed because of error 12180 DHCP detection: WinHttpGetProxyForUrl call failed because of error 12180
For Intune script, there is no prerequisites for accessing specific link but I guess it is trying to access one: https://fef.msub03.manage.microsoft.com/TrafficGateway/TrafficRoutingService/SideCar/StatelessSideCarGatewayService
Microsoft doc: https://docs.microsoft.com/en-us/managed-desktop/get-ready/network?view=o365-worldwide
Anyone had same issue, how to mitigate this?
CodePudding user response:
Hmm, by bad guys, issue with the script. Removed: Start-Process $ExtractPath All is good now. Also, if anyone will need with implementation of try catch:
Write-Output "-------------------------------------------------------------"
Write-Output "Starting script deployment for myapp"
Write-Output "-------------------------------------------------------------"
try {
#Declare variables
$url = "somelocation.file.zip"
$DownloadFile = "C:\Users\Public\Downloads" $(Split-Path -Path $url -Leaf)
$ExtractPath = "C:\Users\Public\Downloads"
#Removing possible broken file from previous push
Remove-Item "C:\Users\Public\Downloads\myfile.exe"
#Download and extract file
Invoke-WebRequest -Uri $url -OutFile $DownloadFile
$ExtractShell = New-Object -ComObject Shell.Application
$ExtractFiles = $ExtractShell.Namespace($DownloadFile).Items()
$ExtractShell.Namespace($ExtractPath).CopyHere($ExtractFiles)
timeout /T 5
#Installation section of file
Start-Process -FilePath "C:\Users\Public\Downloads\myfile.exe" -Argument '/S','/qn' -PassThru
}
catch {
#If there are errors, catch them and display
Write-Host "The error is:"`n -ForegroundColor Blue
Write-Host "Message: [$($_.Exception.Message)"] -ForegroundColor Red -BackgroundColor DarkBlue
}