Generating a List of Available Skype for Business Online PowerShell Cmdlets with Documentation

The Skype for Business Online (SfBO) PowerShell Module is the primary command line management tool for Administrators.

New users of this module are often surprised to learn that the cmdlets exposed by this module are not defined in the Skype for Business Online PowerShell module itself. Instead, the SfBO PowerShell Module creates an implicit remote PowerShell session and imports the cmdlet definitions from the Online SfBO tenant. The cmdlet’s made available in this module therefore could vary by tenant (i.e. based on the type of licensed Office 365 tenant), and be changed online in the tenant (i.e. by Microsoft) without releasing a new PowerShell module (which is installed locally).

Significant changes to the online cmdlet’s are usually well communicated, but as the SfB online service quickly evolves, changes can happen before they are well communicated. For this reason, and to learn what cmdlet’s are available for SfBO administration, I often enumerate the available cmdlet’s in several of my tenants.

The available cmdlet’s in any SfBO tenant can be easily retrieved using PowerShell by finding the associated local temporary PowerShell module associated with any current SfBO PowerShell session and enumerating the cmdlet’s available in that module.  Displaying a list of cmdlet’s to the PowerShell console is not much use however – it is hard to get a handle on what cmdlet’s are available, what they do, and what differences might exist between tenants (since the last time the cmdlet’s were enumerated).

Inspired by fellow MVP Pat Richard’s script for retrieving a convenient list of Skype for Business on-premises PowerShell cmdlet (see “All Skype for Business 2015 Cmdlets and the Default RBAC Roles That Can Use Them”) which includes help information such as the Synopsis and a link the online TechNet help for that cmdlet, I wrote a script which does the following:

  1. Retrieves all of the SfB online cmdlets available in the tenant – including the help descriptions and links to the online help for that cmdlet (if it exists).
  2. Optionally produces a nice HTML report of all the available SfBO cmdlet’s using a really useful PowerShell module named “ReportHTML” by Matthew Quickenden (See PowerShell module called Generate HTML Reports by Matthew Quickenden to get this module).
  3. Optionally saves it to a CSV file

The script is below. By default both the HTML and CSV reports are produced but this can be easily changed with two boolean input parameters to the script representing each type of report.

Some notes on using this script:

  1. It can take a long time (~10 minutes) to finish – why?  The script is calling Get-Help on every cmdlet it finds to get the description and links to online help. This can take awhile.
  2. Make sure the ReportHTML module installed to make the HTML reporting work.
  3. If you are in a SfB hybrid configuration, the OverrideAdminDomain parameter in the New-CSOnlineSession call will likely be required for the remote SfBO session to be established.  See the nodes in the script.
  4. Some cmdlet’s do not have TechNet documentation. Other cmdlet’s have a TechNet link but it is broken – nothing is posted at that link. Most do have links and they open a separate window with the help.

An recent example of the HTML report – which represents all of the SfBO cmdlet’s available on an E3 tenant as of March 2017 - is here:

> http://insidelync.com/Tools/SfBO_Cmdlets.html.

image

 

The Script

The script is published on the TechNet script gallery here: https://gallery.technet.microsoft.com/Get-a-List-of-Available-6de74e51. This is where I will keep it up-to-date.

<#
.SYNOPSIS
    Get-SfBOCmdlets.ps1 – Get’s all the cmdlet’s availalble and their help informaiton for an Online Tenant.

.DESCRIPTION
    This powershell script retrieves all the cmdlet’s available in an SfBO tenants,
    including the help description, and link to online cmdlet help, and optionally
    produces a nicely formatted HTML report and CSV file with all the cmdlet information.

    See http://blog.insidelync.com/2017/03/generating-a-list-of-available-skype-for-business-online-powershell-cmdlets-help-information/

.INPUT
    Skype for Business Online Administrative Username/Password for the tenant (manual prompt), and
    optional parameters for the type of output reports desired.

.PARAMS
    ProduceHTMLReport – Boolean to produce an HTML report (default = true)
    ProduceHTMLReport – Boolean to produce an HTML report (default = true)

.OUTPUTS
    All the cmdlet’s and information about each one.

.NOTES
    ** Need to modify the New-CSOnlineSession session (see below) for a hybrid SfB domain

.EXAMPLE
   .\Get-SfBOCmdlets.ps1 -ProduceHTMLReport $true -ProduceCSVReport $false

Written by: Curtis Johnstone
    www.InsideSkype.com
    www.InsideMicrosoft.com

Special Thanks to Pat Richards for this script: https://www.ucunleashed.com/3691.
   
#>

param (
    [bool] $ProduceHTMLReport = $true,
    [bool] $ProduceCSVReport = $true
    )

Function GetSfBOCmdlets
{
    Write-Output "About to retrieve available online cmdlets and associated help information"

    Import-Module -Name SkypeOnlineConnector

    $Credential = Get-Credential

    # use the -OverrideAdminDomain parameter for a hybrid SfB domain; see http://www.ucblog.co.uk/?p=25
    $sfBOSession = New-CSOnlineSession -credential $Credential # -OverrideAdminDomain
   
    $implicit_PS = Import-PSSession $SFBOSession -AllowClobber

    if ($SFBOSession -eq $null)
    {
        Write-Error "There was a problem establishing the remote session to the SfBO tenant. Aborting"
        exit
    }

    $global:objectCollection = @()

    $all_cmdlets = Get-Command -Module $implicit_PS.Name | Sort-Object Name

    foreach ($cmdlet in $all_cmdlets)
    {

        $cmdletHelp = $(Get-Help $cmdlet)
  
        [string] $synopsis = $cmdletHelp.Synopsis
        if ($synopsis -eq $null) { $synopsis = "" }
        if ($synopsis -eq "Provide the topic introduction here.")
            { $synopsis = "" }
   
        [string] $description = $cmdletHelp.Description
        if ($description -eq $null)
            { $description = "<blank>" }      

        [string] $onlineHelpURI = (($cmdletHelp.relatedLinks.navigationLink | Where-Object {$_.linkText -match "Online Version"}).uri) `
            -replace "EN-US/",""

        $onlineHelpURI = $onlineHelpURI.Trim();

        if ($onlineHelpURI -eq "")
        {
            $hyperLink = "Not available";
        }
        else
        {
            $hyperLinkName = $cmdlet.Name

            # these are magic keywords that the ReportHTML module uses to create hyuperlinks – use the Get-HTMLReportHelp cmdlet for more info
            [string] $hyperLink = "URL01NEW{0}URL02{1}URL03" -f $onlineHelpURI, $hyperLinkName
        }

        $object = New-Object –Type PSObject
        $object | Add-Member –Type NoteProperty –Name CmdletName -Value $cmdlet.Name
        $object | Add-Member –Type NoteProperty –Name Synopsis -Value $synopsis
        $object | Add-Member –Type NoteProperty –Name "TechNet Documentation Link" -Value $hyperLink

        $global:objectCollection += $object
    }

    # clean up remote powershell sessions and resources

    if ($implicit_PS -ne $null)
        { $implicit_PS = $null }

    if ($sfBOSession -ne $null)
        { Remove-PSSession $SFBOSession }
   
    Write-Output "Finished retrieving online cmdlets"

}

Function ProduceHTMLReport
{
    # requires the ReportHTML module (https://www.powershellgallery.com/packages/ReportHTML)
    Import-Module ReportHTML

    $htmlReportPath = $env:UserProfile + "\Documents"
    $htmlReportFile = $htmlReportPath + "\SfBO_Cmdlets.html"

    # $nc = $global:objectCollection | select CmdletName, Synopsis, "TechNet Documentation Link"

    $nc = $global:objectCollection

    $rpt = @()
    $rpt += Get-HtmlOpenPage -TitleText  ("Skype for Business Online Cmdlets") -LeftLogoName Blank -RightLogoName Blank

    $rpt += Get-HtmlContentOpen -HeaderText "Cmdlets"
    $rpt += Get-HtmlContentTable $nc
    $rpt += Get-HtmlContentClose
    $rpt += Get-HtmlClosePage

    Write-Output "Producing HTML report here: $htmlReportFile"

    $rpt > $htmlReportFile

    # display html report
    Invoke-Item $htmlReportFile
    Sleep 1
}

Function ProduceCSVReport
{
    $csvReportPath = $env:UserProfile + "\Documents"
    $csvReportFile = $csvReportPath + "\SfBO_Cmdlets.csv"

    Write-Output "Producing csv report here: $csvReportFile"

    $global:objectCollection | Export-Csv -Path $csvReportFile -NoTypeInformation -Encoding UTF8
}

Write-Output "Script is Starting"
Write-Output "Produce HTML Report? $produceHTMLReport"
Write-Output "Produce CSV Report? $produceCSVReport"

# retrieve the cmdlet listing
GetSfBOCmdlets

if ($produceHTMLReport)
    { ProduceHTMLReport }

if ($produceCSVReport)
    { ProduceCSVReport }

Write-Output "Script complete"

 

References and More Information

The Microsoft Skype for Business Online (SfBO) PowerShell Module

The ReportHTML PowerShell Module in the PowerShell Gallery – by Matthew Quickenden

Pat Richards All Skype for Business 2015 Cmdlets and the Default RBAC Roles That Can Use Them

Be Sociable, Share!

1 comment to Generating a List of Available Skype for Business Online PowerShell Cmdlets with Documentation

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>