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 Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,418 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Andreas Baumgarten 98,791 Reputation points MVP
    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 45,261 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.