首页 > 解决方案 > 微软office 16补丁安装

问题描述

 $source1 = "https://www.microsoft.com/en-us/download/details.aspx?id=36805"    #KB267083## $destination1 = "C:\Users\cdac\Desktop\Shravan\shravan_data_backup\PowerShell_Scripts\Windows_7_Automation_Scripts\KB2670838.exe"    ### KB2670838 ###
Invoke-WebRequest -Uri $source1 -OutFile  $destination1
[Hashtable[]]$Installers = @();
 $Installers += @{
        SoftwareName = "KB2670838"
        Url = "https://www.microsoft.com/en-us/download/details.aspx?id=36805"
        Destination = "C:\Users\cdac\Desktop\Shravan\shravan_data_backup\PowerShell_Scripts\Windows_7_Automation_Scripts\KB2670838.exe"
        Arguments = '/s'
        InstalledPath = 'C:\Program Files\KB2670838.exe'
    }
    function Install-Software([Hashtable]$installer)
     {
        Write-Host "Installing $($installer.SoftwareName)"
        Write-Host "Invoke-WebRequest -Uri $($installer.Url) -OutFile $($installer.Destination)"
        Write-Host "Start-Process -FilePath $($installer.Destination) -ArgumentList $($installer.Arguments) -Wait"  
        Invoke-WebRequest -Uri $installer.Url -OutFile $installer.Destination
        Start-Process -FilePath $installer.Destination -ArgumentList $installer.Arguments -Wait
        
    }
    
    
    foreach($installer in $Installers)
     {
        if (Test-Path -LiteralPath $installer.InstalledPath)
        {
             Write-Verbose -Verbose "$($installer.SoftwareName) is already installed."
        }
    
             else 
             {  
                 Install-Software -installer $installer
             }
    }

我已经编写了一个用于下载和安装 Microsoft Office 16 补丁程序的 PowerShell 脚本,该脚本还可以下载补丁程序并生成 exe,但是当我双击 exe 文件时,我收到以下消息,因为此应用程序无法在此 Windows 平台上支持(我是使用 Windows 10)但是当我手动下载它时,它正在安装。如果是,请告诉我,他们在剧本中是否有任何错误。感谢您

标签: powershell

解决方案


推荐阅读