diff --git a/Fix-EnableSystemRestore.ps1 b/Fix-EnableSystemRestore.ps1 index 9d7f2f2..2c06b55 100644 --- a/Fix-EnableSystemRestore.ps1 +++ b/Fix-EnableSystemRestore.ps1 @@ -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 } \ No newline at end of file diff --git a/Get-EventData.ps1 b/Get-EventData.ps1 index bcaedc1..43b3340 100644 --- a/Get-EventData.ps1 +++ b/Get-EventData.ps1 @@ -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) diff --git a/Get-InstalledSoftware.ps1 b/Get-InstalledSoftware.ps1 index e708fd6..c400c67 100644 --- a/Get-InstalledSoftware.ps1 +++ b/Get-InstalledSoftware.ps1 @@ -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)