4

Im in the proces of learning powershell, so its all new for me. I came across this post: https://www.thelazyadministrator.com/2020/01/26/deploy-intune-applications-with-powershell-and-azure-blob-storage/ I striped down the local part of the location because i want to rely solely on the blob storage.

I tried using this for office pro plus but it does not seem to work. What it currently does: it downloads the required zip from our blob storage and puts it inside folder in %appdata%, it then starts to extract them. When nearing the extraction proces it cuts out and starts removing all the already extracted files.

I cannot seem to wrap my head around this problem.. here is my current itteration of the script:

param ( [System.String]$ZipSourceFiles = "url to zip", [system.string]$IntuneProgramDir = "$env:APPDATA\Intune", [System.String]$FullEXEDir = "$IntuneProgramDir\Intune\setup.exe", [System.String]$ZipLocation = "$IntuneProgramDir\office.zip" ) #Start download of the source files from Azure Blob to the network cache location Start-BitsTransfer -Source $ZipSourceFiles -Destination $ZipLocation #Check to see if the local cache directory is present If ((Test-Path -Path $IntuneProgramDir) -eq $False) { #Create the local cache directory New-Item -ItemType Directory $IntuneProgramDir -Force -Confirm:$False } #Copy the binaries from the network cache to the local computer cache Copy-Item $TempNetworkZip -Destination $IntuneProgramDir -Force #Extract the install binaries Expand-Archive -Path $ZipLocation -DestinationPath $IntuneProgramDir -Force #Install the program Start-Process "$FullEXEDir" -ArgumentList " /S /v/qn" Else { #Check to see if the local cache directory is present If ((Test-Path -Path $IntuneProgramDir) -eq $False) { #Create the local cache directory New-Item -ItemType Directory $IntuneProgramDir -Force -Confirm:$False } #Copy the installer binaries from the network cache location to the local computer cache Copy-Item $TempNetworkZip -Destination $IntuneProgramDir -Force #Extract the install binaries Expand-Archive -Path $ZipLocation -DestinationPath $IntuneProgramDir -Force #Install the program Start-Process "$FullEXEDir" -ArgumentList " /S /v/qn" } 
1
  • 2
    The param section seems to be adapted correctly however there are syntax errors in the script body (something went wrong in copy/paste, e.g. an orphaned else keyword). IMHO the script isn't optimally written at thelazyadministrator… ask at codereview.stackexchange.com for optimization of the final running version. Commented Feb 14, 2020 at 16:51

1 Answer 1

3

You don't need if-else here. Try:

 param ( [System.String]$ZipSourceFiles = "url to zip", [system.string]$IntuneProgramDir = "$env:APPDATA\Intune", [System.String]$FullEXEDir = "$IntuneProgramDir\Intune\setup.exe", [System.String]$ZipLocation = "$IntuneProgramDir\office.zip" ) Start-BitsTransfer -Source $ZipSourceFiles -Destination $ZipLocation #Check to see if the local cache directory is present If ((Test-Path -Path $IntuneProgramDir) -eq $False) { #Create the local cache directory New-Item -ItemType Directory $IntuneProgramDir -Force -Confirm:$False } #Extract the install binaries Expand-Archive -Path $ZipLocation -DestinationPath $IntuneProgramDir -Force #Install the program Start-Process "$FullEXEDir" -ArgumentList " /S /v/qn" 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.