Convert filescrn filegroup list output to an Array - Can't use the CmdLets FsrmF

Is there a easier or better more flexible way of doing the following?

$ServerName = 'Server1'

$data = Invoke-Command -Credential $cre -ScriptBlock {
    filescrn filegroup list /filegroup:"FileGroup 1a"
} -ComputerName $ServerName

$data now contains the following list in the below format.

File groups on machine MHJ-PSRV106:

File Group Name: “FileGroup 1a”
Members: *.ZIP
.RAR
*.JPG
.Doc

The only way I have figured it out, so it will take the inviduels Members, in to one Object in a array, is by using the below LONG no flexible thing…

[System.Array]$FileGroup = ( ( ( ( $data -replace "File groups on machine $($ServerName):","" -replace "File Group Name:","" -replace "Members:","" -replace '"FileGroup 1a"',"" ) -replace " +",",") -split "," ).trim() )

$FileGroup.Count

Can anyone tell me a bether more flexible way of duing this ?

It should be possible to use the Fsrm.FsrmFileGroupManager COM object on Windows Server 2008 instead.

Something like below (not tested):

$fsrmGroupManager = New-Object -ComObject 'FsrmFileGroupManager'

$groupList = $nil
$fsrmGroupManager.EnumFileGroups(0, [ref] $groupList)

# Loop over group list

https://msdn.microsoft.com/en-us/library/bb625544(v=vs.85).aspx

Here an example which should work:

$fsrmGroupManager = New-Object -ComObject 'Fsrm.FsrmFileGroupManager'
$groupList = @( $fsrmGroupManager.EnumGroups() )
$data = $groupList | Select-Object -Property Name, @{ Name='Members'; Expression={ @($_.Members) }}, @{ Name='NonMembers'; Expression={ @($_.NonMembers) }}
$data

Thank you so much Daniel! Is was 99% what I was looking for.

There was a little error in your ex.

If you make a Get-Member on $fsrmGroupManager, EnumGroups is not listed, but EnumFileGroups is. After I change EnumGroups with EnumFileGroups I just worked… And then a little where, and select-object -expand I got the list… Sweet!

The code that works is:

$fsrmGroupManager = New-Object -ComObject 'Fsrm.FsrmFileGroupManager'
$groupList = @( $fsrmGroupManager.EnumFileGroups() )
$data = $groupList | Select-Object -Property Name, @{ Name='Members'; Expression={ @($_.Members) }}, @{ Name='NonMembers'; Expression={ @($_.NonMembers) }}
$data

Thanks you again so much, @Daniel

Great. Thanks for your reply and apologies for the typo in the method name. I’ve retyped the script from another machine into the forum which introduced the mistake. I’m glad you were able to find the correct method name.