Get-ComputerManagement.psm1

function Get-ComputerManagement {
    <#
.SYNOPSIS
    Open Computer Management Console on local or remote computer.
.DESCRIPTION
    Open Computer Management Console on local or remote computer.
.PARAMETER ComputerName
    Name of server to open Computer Management Console on remote computer.
.PARAMETER ADSearchBase
    Active Directory SearchBase of server to open Computer Management Console on remote computer.
.EXAMPLE
    Get-ComputerManagement
    Open Computer Management Console on local computer.
.EXAMPLE
    Get-ComputerManagement -ComputerName pc1
    Open Computer Management Console on remote computer.
.EXAMPLE
    Get-ComputerManagement -ComputerName pc1,pc2
    Open Computer Management Console on multiple remote computer.
#>

[CmdletBinding(DefaultParameterSetName = "ParS1")]
param (
    [parameter(Position = 0, ParameterSetName = "ParS1", Mandatory = $false, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
    [string[]] $ComputerName = "localhost",
    [parameter(ParameterSetName = "ParS2", Mandatory = $false, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
    [string] $ADSearchBase
)
    # Variables
    $PsVm = $PsVersionTable.PSVersion.Major
    # Test PsVersion
    if ($PsVm -ge 5) {
        # ADSearchBase
        if ($ADSearchBase) {
            if (Get-Command Get-AD* -ErrorAction SilentlyContinue) {
                if (Get-ADOrganizationalUnit -Filter "distinguishedName -eq '$ADSearchBase'" -ErrorAction SilentlyContinue) {
                    $Table = Get-ADComputer -SearchBase $ADSearchBase -Filter *
                    $ComputerName = $Table.Name
                }
                else {Write-Warning "No SearchBase found"}
            }
            else {Write-Warning "No AD Cmdlet found"}
        }
        # Loop ComputerName
        $ComputerName = $ComputerName.ToUpper()
        foreach ($Computer in $ComputerName) {
            if ($ComputerName -like "localhost") {
                $TestLocal = $true
            }
            else {
                $TestWinRM = Test-NetConnection -CommonTCPPort WINRM -ComputerName $Computer -ErrorAction SilentlyContinue -ErrorVariable EV01
            }
            if ($TestWinRM.TcpTestSucceeded -or $TestLocal) {
                Start-Process "compmgmt.msc" -ArgumentList "/Computer=$Computer"
            }
        }

    }
    else {
        Write-Warning "PSVersion $PsVm to low"
    }
}