Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cd4e99465 | ||
|
|
8962142931 |
@@ -11,6 +11,7 @@ If ( $SFCOutput -contains 'Windows Resource Protection did not find any integrit
|
||||
# Run enhanced DISM for Windows 8 and higher endpoints
|
||||
If ( IsWindowsVersion -ge "6.2" )
|
||||
{
|
||||
# Record start of DISM repair
|
||||
$BeginDISMRun = (Get-Date)
|
||||
|
||||
Write-Output "Beginning repair of Windows Component Store"
|
||||
@@ -19,9 +20,10 @@ If ( IsWindowsVersion -ge "6.2" )
|
||||
Write-Output "Beginning cleanup of superceded components in Windows Component Store"
|
||||
Start-Process "dism.exe" -ArgumentList "/online /cleanup-image /startcomponentcleanup" -Wait
|
||||
|
||||
$EndDISMRun = $(Get-Date).AddSeconds(1)
|
||||
# Record end of DISM repair
|
||||
$EndDISMRun = (Get-Date)
|
||||
|
||||
# Adding results of DISM log file to this log file
|
||||
# Extract results of DISM repair from system log and add them to this log
|
||||
Write-Output "Beginning Windows Component Store log data collection"
|
||||
Get-Content -Path "${Env:WinDir}\Logs\DISM\dism.log" | Select-String -Pattern '^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})' |
|
||||
ForEach-Object {
|
||||
|
||||
@@ -59,17 +59,15 @@ Function Setup-LogFile {
|
||||
# Start-Process "cmd.exe" -ArgumentList '/C echo y | some-command'
|
||||
Function Write-Output {
|
||||
param([Parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$Message)
|
||||
$Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||
$LogEntry = "${Timestamp} - ${Message}"
|
||||
Add-Content -Path $Global:LogFile -Value $LogEntry
|
||||
Add-Content -Path $Global:LogFile -Value "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") - ${Message}"
|
||||
Microsoft.Powershell.Utility\Write-Output $Message
|
||||
}
|
||||
|
||||
# Log an error to the log file
|
||||
Function Write-Error {
|
||||
param([Parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$Message)
|
||||
$Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||
$LogEntry = "${Timestamp} - Error: ${Message}"
|
||||
Add-Content -Path $Global:LogFile -Value $LogEntry
|
||||
Add-Content -Path $Global:LogFile -Value "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") - Error: ${Message}"
|
||||
Microsoft.Powershell.Utility\Write-Error $Message
|
||||
}
|
||||
|
||||
# Function to determine if the current user context is an Administrator
|
||||
@@ -155,14 +153,6 @@ Function Run-Script {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$LogFileContent = (Get-Content $LogFile)
|
||||
|
||||
# Write the log file output to the console
|
||||
If ( $LogFileContent ) { Write-Output $LogFileContent }
|
||||
|
||||
# Delete the log file if it's empty
|
||||
Else { Remove-Item $LogFile -Force }
|
||||
}
|
||||
|
||||
# Return a Powershell version object from a string
|
||||
|
||||
Reference in New Issue
Block a user