Powershell script for 7-zip

Karthik 1 Reputation point
2022-08-06T19:32:04.81+00:00

Hello

I'm very much new to the scripting world. I don't know basics of scripting. I have an assignment on my course, where i have been provided with a script to install 7-zip on my test computer using intune.

The following is the script given

$url = "https: //www.7-zip.org/a/721900-x64.exe"
$filePath = "c: \windows\temp\7z1900-×64. exe"
$ProgressPreference = 0
Invoke-WebRequest $url -OutFile $filePath -UseBasicParsing
& $filePath /quiet

I tried to find solution to work on. I have to use either the scripting method or .intunewin to install. I have succeeded with .intunewin method to install on remote computer with intune. I'm wondering what is wrong with the script and what correction to be made with the script to make it work. I tried all forums and the language used is very new and hard to understand. As I said i'm very new (Not scripting is my plate) to the scripting world. My instructor wants us to know how efficient we use the internet platform to find solution. This is my one hope to find solution.

Thanks in advance.

Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Andreas Baumgarten 123.4K Reputation points MVP Volunteer Moderator
    2022-08-06T20:05:33.267+00:00

    Hi @Karthik ,

    maybe this helps to get it started (I changed the folder where the exe will be downloaded to, the url to get the file and also the switch to install):

    $url = "https://d3.7-zip.org/a/7z2201-x64.exe"  
    $filePath = "C:\Junk\7z1900-×64.exe"  
    $ProgressPreference = 0  
    Invoke-WebRequest $url -OutFile $filePath  
    & $filePath /S  
    

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


  2. Rich Matheisen 47,901 Reputation points
    2022-08-06T22:52:47.18+00:00

    If you're unfamiliar with PowerShell you should download this free PDF: Windows-PowerShell-4

    Read the 1st half of the book and do the exercises before doing anything in the 2nd half. Once you're familiar with PowerShell you can move on to the 2nd half which covers the use of PowerShell to perform common administrative tasks.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.