Compare commits
5
Commits
5f4b4565de
...
72445c1701
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72445c1701 | ||
|
|
983952ee99 | ||
|
|
ab2a1821d5 | ||
|
|
df7f635e26 | ||
|
|
c628f60289 |
@@ -36,7 +36,7 @@ If ( $CBSLogs ) {
|
||||
}
|
||||
|
||||
# Remove all system temp files older than 7 days
|
||||
$OldTempFiles = Get-ChildItem -Path "${Env:SystemRoot}\TEMP" | Where { $_.LastWriteTime -lt ((Get-Date) - $TimeDelta) }
|
||||
$OldTempFiles = Get-ChildItem -Path "${Env:SystemRoot}\TEMP" | Where-Object { $_.LastWriteTime -lt ((Get-Date) - $TimeDelta) }
|
||||
If ( $OldTempFiles ) {
|
||||
Write-Output "Deleting all temp files not modified in ${OlderThan} day(s) from ${Env:SystemRoot}\TEMP"
|
||||
ForEach ( $OldTempFile in $OldTempFiles ) { Remove-Item $OldTempFile -Force -Recurse -ErrorAction SilentlyContinue }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
If ( $(Get-ComputerRestorePoint) -ne $null ) { Write-Output "System Restore is already enabled" ; Exit }
|
||||
If ( $null -ne $(Get-ComputerRestorePoint) ) { Write-Output "System Restore is already enabled" ; Exit }
|
||||
Write-Output "Enabling System Restore"
|
||||
Try { Enable-ComputerRestore -Drive $Env:SystemDrive }
|
||||
Catch { Write-Error $_.Exception.Message }
|
||||
@@ -35,6 +35,6 @@ Else { Write-Output "Online image cleanup and restoration is only supported on W
|
||||
|
||||
# Schedule Check Disk if needed
|
||||
If ( $ScheduleCheckDisk ) {
|
||||
Write-Output "Check Disk scheduled to repair disk at next boot"
|
||||
& echo y | chkdsk /F /R /X
|
||||
Write-Output "Scheduling disk repair at next boot"
|
||||
Start-Process "cmd.exe" -ArgumentList '/C echo y | chkdsk /F /R /X' -Wait
|
||||
}
|
||||
+1
-2
@@ -26,7 +26,7 @@ $Logs = Get-WinEvent -ListLog *
|
||||
ForEach ($Log in $Logs) {
|
||||
$LogName = $Log.LogName
|
||||
Write-Output "Exporting events from: ${LogName}"
|
||||
Try { Get-WinEvent -LogName $LogName -FilterXPath "Event/System[Level=1 or Level=2 or Level=3]" -ErrorAction Stop | Select LogName,ProviderName,Level,Id,Message | Export-Csv -Path "${ExportedEvents}" -Append -NoTypeInformation -ErrorAction Stop }
|
||||
Try { Get-WinEvent -LogName $LogName -FilterXPath "Event/System[Level=1 or Level=2 or Level=3]" -ErrorAction Stop | Select-Object LogName,ProviderName,Level,Id,Message | Export-Csv -Path "${ExportedEvents}" -Append -NoTypeInformation -ErrorAction Stop }
|
||||
Catch { Write-Error $_.Exception.Message }
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ Catch { Write-Error $_.Exception.Message }
|
||||
# Upload to SFTP site
|
||||
If ( Test-Path $ExportedEvents ) {
|
||||
$SFTPCred = New-Object System.Management.Automation.PSCredential($SFTPUser,$SFTPPass)
|
||||
$DestinationFile = $(Split-Path -Path $ExportedEvents -Leaf)
|
||||
|
||||
# Wait for a random amount of time before starting the connection and uploading
|
||||
Start-Sleep -Seconds $(Get-Random -Minimum 1 -Maximum 120)
|
||||
|
||||
@@ -22,7 +22,7 @@ Function Test-ItemProperty {
|
||||
param([Parameter(Mandatory=$true)][string]$Path,[Parameter(Mandatory=$true)][string]$Name)
|
||||
Try {
|
||||
$test = Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue
|
||||
If (($test -eq $null) -or ($test.Length -eq 0)) { Return $false } Else { Return $true }
|
||||
If (($null -eq $test) -or ($test.Length -eq 0)) { Return $false } Else { Return $true }
|
||||
}
|
||||
Catch { Return $false }
|
||||
}
|
||||
@@ -59,7 +59,7 @@ Function Get-ItemPropertyInfo {
|
||||
|
||||
## Make sure $formatstring has a value, if not just try to cast directly to a datetime
|
||||
Try {
|
||||
If ( $formatstring -eq $null ) {
|
||||
If ( $null -eq $formatstring ) {
|
||||
$date = [datetime]$retval
|
||||
} Else {
|
||||
$date = [datetime]::ParseExact($retval,$formatstring,$null)
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
If ( $OlderThanDays -is [int] ) {
|
||||
If ( Test-Path $Path ) {
|
||||
Write-Output "Deleting all items older than ${OlderThanDays} days in ""${Path}"""
|
||||
$files = Get-ChildItem $Path | Where { !$_.PSIsContainer -and $_.LastWriteTime -lt (Get-Date).AddDays(-${OlderThanDays}) }
|
||||
$files = Get-ChildItem $Path | Where-Object { !$_.PSIsContainer -and $_.LastWriteTime -lt (Get-Date).AddDays(-${OlderThanDays}) }
|
||||
Foreach ( $f in $files ) {
|
||||
$msg = "Deleting {0}" -f $f.FullName ; Write-Output $msg
|
||||
Try { Remove-Item $f -Force | Out-Null }
|
||||
|
||||
@@ -14,8 +14,8 @@ If ( $PATH )
|
||||
Write-Output "Stopping processes"
|
||||
Try
|
||||
{
|
||||
Get-Process | Where { $_.Name -like "AdAppMgr" } | Stop-Process -Force
|
||||
Get-Process | Where { $_.Name -like "AutodeskDesktopApp" } | Stop-Process -Force
|
||||
Get-Process | Where-Object { $_.Name -like "AdAppMgr" } | Stop-Process -Force
|
||||
Get-Process | Where-Object { $_.Name -like "AutodeskDesktopApp" } | Stop-Process -Force
|
||||
}
|
||||
Catch { Write-Output $_.Exception.Message }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user