Public/Test-FSMAdminShareAccess.ps1

function Test-FSMAdminShareAccess {
    <#
    .SYNOPSIS
        Verifies that a server is ready for share migration: reachable over WinRM,
        has the SmbShare cmdlets, and the connecting account has admin rights.

    .DESCRIPTION
        This is the pre-flight check. Before exporting or creating anything, it
        confirms three things on the target server:
          1. PowerShell remoting (WinRM) works.
          2. The SmbShare module is present (Get-SmbShare exists).
          3. The connecting identity is a local administrator there.

        It returns one object so you can check several servers and read the results
        as a table.

    .PARAMETER ComputerName
        The server(s) to test.

    .PARAMETER Credential
        Optional credentials for the remote connection.

    .EXAMPLE
        Test-FSMAdminShareAccess -ComputerName fileserver01

    .EXAMPLE
        'srcfs', 'dstfs' | Test-FSMAdminShareAccess -Credential (Get-Credential)
    #>

    [CmdletBinding()]
    [OutputType([pscustomobject])]
    param(
        [Parameter(Mandatory, ValueFromPipeline)]
        [ValidateNotNullOrEmpty()]
        [string[]]$ComputerName,

        [pscredential]$Credential
    )

    process {
        foreach ($computer in $ComputerName) {
            try {
                $check = Invoke-FSMRemote -ComputerName $computer -Credential $Credential -ScriptBlock {
                    $isAdmin = ([Security.Principal.WindowsPrincipal] `
                        [Security.Principal.WindowsIdentity]::GetCurrent()
                    ).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)

                    [pscustomobject]@{
                        ComputerName    = $env:COMPUTERNAME
                        SmbShareModule  = [bool](Get-Command -Name Get-SmbShare -ErrorAction SilentlyContinue)
                        IsAdministrator = $isAdmin
                    }
                }

                [pscustomobject]@{
                    ComputerName    = $computer
                    WinRM           = $true
                    SmbShareModule  = $check.SmbShareModule
                    IsAdministrator = $check.IsAdministrator
                    Ready           = ($check.SmbShareModule -and $check.IsAdministrator)
                    Status          = if ($check.SmbShareModule -and $check.IsAdministrator) {
                                          'Ready'
                                       } else {
                                          'Reachable but not ready (check SmbShare module / admin rights)'
                                       }
                }
            }
            catch {
                [pscustomobject]@{
                    ComputerName    = $computer
                    WinRM           = $false
                    SmbShareModule  = $false
                    IsAdministrator = $false
                    Ready           = $false
                    Status          = $_.Exception.Message
                }
            }
        }
    }
}