change logging method, update nextcloud installer and url

This commit is contained in:
2020-09-10 13:28:30 -04:00
parent eec3875a10
commit 5694bd0842
4 changed files with 16 additions and 13 deletions
+13 -10
View File
@@ -1,26 +1,29 @@
## Run enhanced DISM for Windows 8 and higher endpoints ## Run enhanced DISM for Windows 8 and higher endpoints
If ( IsWindowsVersion -ge "6.2" ) If ( IsWindowsVersion -ge "6.2" )
{ {
## The name of the log file for this script
$LogName = "Fix-WindowsHealth"
$BeginDISMRun = $(Get-Date).AddSeconds(-1) $BeginDISMRun = $(Get-Date).AddSeconds(-1)
## Scan the Windows Component Store for problems ## Scan the Windows Component Store for problems
Log "Beginning Windows Component Store scan" $LogFile Log "Beginning Windows Component Store scan" $LogName
Start-Process "dism.exe" -ArgumentList "/online /cleanup-image /scanhealth" -Wait Start-Process "dism.exe" -ArgumentList "/online /cleanup-image /scanhealth" -Wait
Log "Completed Windows Component Store scan" $LogFile Log "Completed Windows Component Store scan" $LogName
## Check to see if the previous command recorded any problems that need repairing ## Check to see if the previous command recorded any problems that need repairing
Log "Beginning Windows Component Store health check" $LogFile Log "Beginning Windows Component Store health check" $LogName
$CheckHealthOutput = $(dism /online /cleanup-image /checkhealth) | Out-String $CheckHealthOutput = $(dism /online /cleanup-image /checkhealth) | Out-String
If ( $CheckHealthOutput -match "repairable" ) If ( $CheckHealthOutput -match "repairable" )
{ {
Log "Completed Windows Component Store health check: Problems found" $LogFile Log "Completed Windows Component Store health check: Problems found" $LogName
## Repair problems with the Windows Component Store ## Repair problems with the Windows Component Store
Log "Beginning Windows Component Store restoration" $LogFile Log "Beginning Windows Component Store restoration" $LogName
Start-Process "dism.exe" -ArgumentList "/online /cleanup-image /restorehealth" -Wait Start-Process "dism.exe" -ArgumentList "/online /cleanup-image /restorehealth" -Wait
Log "Completed Windows Component Store restoration" $LogFile Log "Completed Windows Component Store restoration" $LogName
} }
Else { Log "Completed Windows Component Store health check: No problems found" $LogFile } Else { Log "Completed Windows Component Store health check: No problems found" $LogName }
$EndDISMRun = $(Get-Date).AddSeconds(1) $EndDISMRun = $(Get-Date).AddSeconds(1)
@@ -28,12 +31,12 @@ If ( IsWindowsVersion -ge "6.2" )
$DISMLogFile = "${MSPLogs}\Fix-WindowsHealth_DISM.log" $DISMLogFile = "${MSPLogs}\Fix-WindowsHealth_DISM.log"
If ( Test-Path $DISMLogFile ) { Remove-Item $DISMLogFile -Force } If ( Test-Path $DISMLogFile ) { Remove-Item $DISMLogFile -Force }
New-Item -Path $DISMLogFile -ItemType File New-Item -Path $DISMLogFile -ItemType File
Log "Beginning Windows Component Store log data collection" $LogFile Log "Beginning Windows Component Store log data collection" $LogName
Get-Content -Path "${Env:WinDir}\Logs\DISM\dism.log" | Select-String -Pattern '^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})' | Get-Content -Path "${Env:WinDir}\Logs\DISM\dism.log" | Select-String -Pattern '^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})' |
% { If ( ((Get-Date $_.Line.Substring(0,19)) -gt $BeginDISMRun) -and ((Get-Date $_.Line.Substring(0,19)) -le $EndDISMRun) ) { % { If ( ((Get-Date $_.Line.Substring(0,19)) -gt $BeginDISMRun) -and ((Get-Date $_.Line.Substring(0,19)) -le $EndDISMRun) ) {
Add-Content -Path $DISMLogFile -Value $_.Line Add-Content -Path $DISMLogFile -Value $_.Line
} }
} }
Log "Completed Windows Component Store log data collection" $LogFile Log "Completed Windows Component Store log data collection" $LogName
} }
Else { Log "Online image cleanup and restoration is only supported on Windows 8 and higher" $LogFile } Else { Log "Online image cleanup and restoration is only supported on Windows 8 and higher" $LogName }
+2 -2
View File
@@ -1,6 +1,6 @@
## Define URL for downloading the installer ## Define URL for downloading the installer
$URL = 'https://download.nextcloud.com/desktop/releases/Windows/Nextcloud-3.0.1-setup.exe' $URL = 'https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/resources/Nextcloud-3.0.1-setup.exe'
$FILE = '{0}\{1}.exe' -f $Env:TEMP,(Split-Path $URL -Leaf) $FILE = Split-Path $URL -Leaf
## Remove previous package ## Remove previous package
If ( Test-Path $FILE ) { Remove-Item -Path $FILE -Force | Out-Null} If ( Test-Path $FILE ) { Remove-Item -Path $FILE -Force | Out-Null}
+1 -1
View File
@@ -25,7 +25,7 @@ If ( !(Test-Path $MSPLogs) )
Function Log Function Log
{ {
param([string]$Message,[string]$LogName) param([string]$Message,[string]$LogName)
$LogEntry = "{0} - {1}" -f (Get-Date -Format "yyyy-MM-dd HH:mm:ss"),$Message $LogEntry = "{0} - {1}" -f (Get-Date -Format "yyyy-MM-dd HH:mm:ss"), $Message
If ($LogName ) If ($LogName )
{ {
$LogFile = "${MSPLogs}\${LogFilePrefix}-${LogName}.log" $LogFile = "${MSPLogs}\${LogFilePrefix}-${LogName}.log"
Binary file not shown.