powershell

sethayes

·

step08

·

Powershell

·

Total Size: 5.97 KB

·

·

Created: 3 months ago

·

Edited: 3 months ago

$Log = "C:\Users\Public\Log.txt" [bool]$restart = $false filter timestamp {"$(Get-Date -Format G) | $_"} $os = (Get-WmiObject Win32_OperatingSystem).Version $sp = (Get-WmiObject Win32_OperatingSystem).ServicePackMajorVersion If (Test-Path "C:\Users\Public\Office") { Get-ChildItem -Path "C:\Users\Public\Office" -Recurse | Remove-Item -Force -Recurse -Confirm:$false Remove-Item "C:\Users\Public\Office" -Force -Confirm:$false } If (($os -like "6.1*") -and ($sp -ge "1")) { Write-Output "Installing Office 365 Pro Plus" | timestamp Write-Output "Installing Office 365 Pro Plus" | timestamp | Out-File $Log -Append Write-Output "`tDownloading Office 365 Plus..." | timestamp Write-Output "`tDownloading Office 365 Plus..." | timestamp | Out-File $Log -Append (New-Object System.Net.WebClient).DownloadFile("https://lt.msinetworks.com/labtech/Transfer/Software/Office/O3652016.zip","C:\Users\Public\O3652016.zip") Write-Output "`t...Office 365 Pro Plus has been Downloaded" | timestamp Write-Output "`t...Office 365 Pro Plus has been Downloaded" | timestamp | Out-File $Log -Append Write-Output "`t`tExtracting Office 365 Pro Plus Installer..." | timestamp Write-Output "`t`tExtracting Office 365 Pro Plus Installer..." | timestamp | Out-File $Log -Append Expand-Archive "C:\Users\Public\O3652016.zip" -DestinationPath "C:\Users\Public\Office" -Force Write-Output "`t`t...Office 365 Pro Plus Installer has been Extracted" | timestamp Write-Output "`t`t...Office 365 Pro Plus Installer has been Extracted" | timestamp | Out-File $Log -Append Write-Output "`t`t`tRunning Office 365 Pro Plus Installer..." | timestamp Write-Output "`t`t`tRunning Office 365 Pro Plus Installer..." | timestamp | Out-File $Log -Append cmd.exe /c "C:\Users\Public\Office\setup.exe /configure C:\Users\Public\Office\config.xml" $pID = Get-Process | Where-Object {($_.Name -eq "setup.exe") -and ($_.Description -eq "Microsoft Office")} | Select-Object -ExpandProperty Id Do { $proc = Get-Process | Where-Object {$_.Id -eq $pID} | Select-Object -ExpandProperty Name If ($proc) { Write-Output "...Still Running" | timestamp Write-Output "...Still Running" | timestamp | Out-File $Log -Append Start-Sleep -Seconds 600 } } Until (!$proc) Write-Output "`t`t`t...Office 365 Pro Plus has been Installed" | timestamp Write-Output "`t`t`t...Office 365 Pro Plus has been Installed" | timestamp | Out-File $Log -Append Write-Output "Office Products Need to be Pinned to Taskbar" | timestamp Write-Output "Office needs to be Activated with the User's Account" | timestamp Write-Output "Outlook needs to be configured with the User's Email Account" | timestamp Write-Output "Office Products Need to be Pinned to Taskbar" | timestamp | Out-File $Log -Append Write-Output "Office needs to be Activated with the User's Account" | timestamp | Out-File $Log -Append Write-Output "Outlook needs to be configured with the User's Email Account" | timestamp | Out-File $Log -Append } If (($os -like "6.3*") -or ($os -like "10*")) { Write-Output "Installing Office 365 Pro Plus..." | timestamp Write-Output "Installing Office 365 Pro Plus..." | timestamp | Out-File $Log -Append Write-Output "`tDownloading Office 365 Pro Plus..." | timestamp Write-Output "`tDownloading Office 365 Pro Plus..." | timestamp | Out-File $Log -Append (New-Object System.Net.WebClient).DownloadFile("https://lt.msinetworks.com/labtech/Transfer/Software/Office/O3652016.zip","C:\Users\Public\O3652016.zip") Write-Output "`t...Office 365 Pro Plus has been Downloaded" | timestamp Write-Output "`t...Office 365 Pro Plus has been Downloaded" | timestamp | Out-File $Log -Append Write-Output "`t`tExtracting Office 365 Pro Plus Installer..." | timestamp Write-Output "`t`tExtracting Office 365 Pro Plus Installer..." | timestamp | Out-File $Log -Append Expand-Archive "C:\Users\Public\O3652016.zip" -DestinationPath "C:\Users\Public\Office" -Force Write-Output "`t`t...Office 365 Pro Plus Installer has been Extracted" | timestamp Write-Output "`t`t...Office 365 Pro Plus Installer has been Extracted" | timestamp | Out-File $Log -Append Write-Output "`t`t`tRunning Office 365 Pro Plus Installer..." | timestamp Write-Output "`t`t`tRunning Office 365 Pro Plus Installer..." | timestamp | Out-File $Log -Append cmd.exe /c "C:\Users\Public\Office\setup.exe /configure C:\Users\Public\Office\config.xml" $pID = Get-Process | Where {($_.Name -eq "setup.exe") -and ($_.Description -eq "Microsoft Office")} | Select -ExpandProperty Id Do { $proc = Get-Process | Where {$_.Id -eq $pID} | Select-Object -ExpandProperty Name If ($proc) { $t = (Get-Date -Format g) Write-Output "$t | ...Still Running: $($proc)" | timestamp Write-Output "$t | ...Still Running: $($proc)" | timestamp | Out-File $Log -Append Start-Sleep -Seconds 600 } } Until (!$proc) Write-Output "`t`t`t...Office 365 Pro Plus has been Installed" | timestamp Write-Output "`t`t`t...Office 365 Pro Plus has been Installed" | timestamp | Out-File $Log -Append Write-Output "Office Products Need to be Pinned to Taskbar" | timestamp Write-Output "Office needs to be Activated with the User's Account" | timestamp Write-Output "Outlook needs to be configured with the User's Email Account" | timestamp Write-Output "Office Products Need to be Pinned to Taskbar" | timestamp | Out-File $Log -Append Write-Output "Office needs to be Activated with the User's Account" | timestamp | Out-File $Log -Append Write-Output "Outlook needs to be configured with the User's Email Account" | timestamp | Out-File $Log -Append } If (Test-Path "C:\Users\Public\step09.ps1") { & "C:\Users\Public\step09.ps1" }

1 bit

65 views

Are you sure you want to delete?

User Profile Picture

Thank you for using Code Clippet :)