#powershell #skype4b Scheduled Task Does Not Work

You tested your #skype4b script from the PowerShell command line and are satisfied that everything works as expected. Next, you create a regular Windows scheduled task to run the script at a specific time of a day. However, you are surprised that no results are returned from simple cmdlets like Get-CsUser. You even wrap similar code in Invoke-Command and purposely target remote hosts with -ComputerName with no success.

Ultimately… Continue reading

#powershell Start-Job -ArgumentList Bug?

Irrespective of the position of -ArgumentList, including the intentional placement at the end of the statement per documentation for Start-Job, a string array will be treated as a single string object when passed to this cmdlet using the aforementioned parameter:

$arr = "a","b","c","d"
Start-Job -ScriptBlock {
param($a) $items = @(); $a | % { $items += $_; }; $items; } -ArgumentList $arr
$result = Receive-Job -id 2
$result
#a
$result.GetType()
#String
$result.count
#1

Continue reading

#skype4b #powershell *-CsDatabase Common Error Messages (and Fix)

Even with the right administrative account and permissions, and proper network as well as firewall (port) settings provisioned, a number of common error messages when working with *-CsDatabase cmdlets in Skype for Business Server prove to be rather challenging to decipher and resolve:

PS C:\> Install-CsDatabase -SqlServerFqdn sql01.leedesmond.com -SqlInstanceName sql01inst01 -Update -ConfiguredDatabases
Install-CsDatabase : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ Install-CsDatabase -SqlServerFqdn sql01.leedesmond.com -SqlInstanceName sql01inst01 -Update -ConfiguredDatabases
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Install-CsDatabase], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.Rtc.Management.Deployment.InstallDatabaseCmdlet

Continue reading

#skype4B/Lync #powershell Script: Compare User Policy (Update v1.10)

This revised version of Compare-Skype4BUserPolicy adds the option to include items that hold the same values. It 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.

Have fun!

################################################################################
# Copyright (c) 201x-2017 leedesmond.com
# All Rights Reserved. Use at your own risk and responsibility.
# Compare-Skype4BUserPolicy.ps1
# Version 1.10
# Continue reading

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