Public/Export-FSMShareInventory.ps1

function Export-FSMShareInventory {
    <#
    .SYNOPSIS
        Exports non-special SMB shares from a source file server to CSV.

    .DESCRIPTION
        Connects to the source server, lists every share that isn't an administrative
        or excluded share, and writes the details (name, path, description, enumeration
        mode, caching, availability, encryption) to a CSV you can review or feed into
        New-FSMTargetShares.

    .PARAMETER SourceServer
        The file server to read shares from.

    .PARAMETER OutputPath
        Full path to the CSV file to create.

    .PARAMETER ExcludeShareName
        Share names to skip. Defaults to the standard administrative/system shares.

    .PARAMETER Credential
        Optional credentials for the remote connection.

    .EXAMPLE
        Export-FSMShareInventory -SourceServer oldfs01 -OutputPath C:\Temp\oldfs01-shares.csv
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [string]$SourceServer,

        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [string]$OutputPath,

        [string[]]$ExcludeShareName = (Get-FSMDefaultExclusion),

        [pscredential]$Credential
    )

    $shares = @(Invoke-FSMRemote -ComputerName $SourceServer -Credential $Credential -ArgumentList (,$ExcludeShareName) -ScriptBlock {
        param([string[]]$ExcludeShareName)

        Get-SmbShare |
            Where-Object { -not $_.Special -and $ExcludeShareName -notcontains $_.Name } |
            Select-Object Name, Path, Description, FolderEnumerationMode,
                          CachingMode, ContinuouslyAvailable, EncryptData
    })

    $folder = Split-Path -Path $OutputPath -Parent
    if ($folder -and -not (Test-Path -Path $folder)) {
        New-Item -Path $folder -ItemType Directory -Force | Out-Null
    }

    $shares | Export-Csv -Path $OutputPath -NoTypeInformation -Encoding UTF8
    Write-FSMStatus -Message "Exported $($shares.Count) share(s) from $SourceServer to $OutputPath" -Level Success
    return $shares
}