move check values to left side of comparison
This commit is contained in:
@@ -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 }
|
||||
+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)
|
||||
|
||||
Reference in New Issue
Block a user