#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

#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))

#skype4b #powershell Auto Enforce User-defined Lync/Skype Presence Status

Code sample to automatically maintain a user-defined Presence status in Lync / Skype for Business desktop client. Works even when the Windows computer is locked i.e. ignore PC lock and override Lync / Skype4b ‘s presence auto-reset.

Enjoy!
Continue reading

#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.

#powershell Script: Find Active Directory User II (Update v1.10)

The Find-AdUserII function listed here is an update to this. It now accepts a text parameter which is used to search for an AD user based on a number of common properties like displayname or samaccountname. Using this as a starting point, … Continue reading

#skype4b Reset Presence Status with PowerShell (and LyncSdk)

UPDATE
#skype4b #powershell Auto Enforce User-defined Lync/Skype Presence Status

———-
You may notice that since the launch of Lync 2010 client to the latest Skype for Business 2016 (desktop) client, user’s manually configured Presence Status automatically reverts to Available after some predetermined time-out period [1]. This is unlike system managed status such as In a call or In a conference* which remains unchanged as long as the session is active (even with a locked computer).

To regain control over presence status set explicitly by hand, you can deploy PowerShell in combination with … Continue reading