Public/Get-UnitySession.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Function Get-UnitySession {

  <#
      .SYNOPSIS
      List the existing sessions.
      .DESCRIPTION
      List the existing sessions.
      .NOTES
      Written by Erwan Quelin under MIT licence
      .LINK
      https://github.com/equelin/Unity-Powershell
      .PARAMETER Server
      IP or FQDN of the Unity array.
      .EXAMPLE
      Get-UnitySession

      List all the existing sessions.
      .EXAMPLE
      Get-UnitySession -Server 192.168.0.1'

      Lists sessions connected the the array '192.168.0.1'
  #>


  [CmdletBinding()]
  Param (
    [Parameter(Mandatory = $false,HelpMessage = 'EMC Unity IP or FQDN')]
    [String]$Server
  )

  Begin {
    Write-Debug -Message "[$($MyInvocation.MyCommand)] Executing function"
  }

  Process {
    If ($Server) {
      Write-Verbose "Return DefaultUnitySession matching the Server IP or FQDN: $Server"
      return $global:DefaultUnitySession | where-object {$_.Server -match $Server}
    } else {
      Write-Verbose "Return DefaultUnitySessionclear"
      return $global:DefaultUnitySession
    }
  }

  End {}
}