#powershell One-liner Code: Event Logs Overview

One liner #powershell code to list the frequency of most recent events generated for the specified EventViewer log file type.

( can you spot an “error”? )
Get-EventLog -ComputerName (hostname) -LogName system |
Group-Object EntryType |
% `
-Begin { "-begin '$($_.name)'" } `
-Process {
"-process '$($_.name)'";
$_.group | group EventId |
sort count -desc |
select count, name,
@{l='TimeGenerated';e={$_.group[0].TimeGenerated}},
@{l='Message';e={$_.group[0].Message}}} |
ft -au

#skype4b #powershell Event ID and Provider “Crash” (Source)

Certain third party software programs may use the same Event ID to write entries in the Application event log. An example is Event ID 10 used by the source “Verba System Monitor” (now part of Actiance) which crashes with information logged by Windows system providers like WMI.

Hence, when gathering logs with Get-EventLog and Get-WinEvent, remember to check not just the Event ID but also that of the Provider (Source).

Actiance Vantage and/or Verba are software applications typically deployed in a Skype for Business environment where ethical firewalls are erected for the purpose of segregating communications between (internal) business units.

#skype4b #powershell Compare (Any) Lync/Skype Policy

Compare-SfbAnyPolicy is one of the many PowerShell functions/utilities in my personal script toolbox repository designed to help simplify the management and administration of just about any Lync / Skype for Business Server environments.

Enjoy!

################################################################################
# Copyright (c) 201x-2017 leedesmond.com
# All Rights Reserved. Use at your own risk and responsibility.
# Compare-SfbAnyPolicy.ps1
# Version 1.00
# Continue reading “#skype4b #powershell Compare (Any) Lync/Skype Policy”

#powerShell Inhibit Output Echo from ArrayList Method

For optimal performance, creation of an empty array using
$a = New-Object System.Collections.ArrayList

is, for instance, preferred over
$a = @()

However, putting a single element into the array with the former’s Add() method will auto output the index of the just inserted item. If left unchecked, this can become part of the output in a PowerShell function call which may not be desirable.

To resolve this, simply pipe the call to Out-Null like
$a.Add((Get-Date)) | Out-Null

or prefix with [void] to suppress the echo:
[void]$a.Add((Get-Date))

#powershell Write-Progress Suppress Status Bar Display

By default with the Write-Progress cmdlet,

$ProgressPreference -eq “Continue”   #$true

where the progress bar display (status) in a Windows PowerShell command window can be suppressed with

$ProgressPreference = “SilentlyContinue”

Note that this setting apparently works only in a regular remote RDP session but not over a PS Remoting session, a fact that the official documentation does not mention.

Hence, Write-Verbose or Write-Host may be your only options to provide a visual status indication.

#skype4b #powershell Watch Those Temporary Files!

Certain cmdlets in the SkypeForBusiness PowerShell module appear to have the need to write temporary files to the $env:temp folder in order to correctly function.

Over time, disk space consumption can add up, particularly when this path points to the default location, namely on the same drive where the operating system is installed. Needless to say, regular manual or scheduled clean-up of the temp directory is generally recommended to ensure continuous and trouble-free operations.