Skip to content

ConvertTo‑SqlDscFileGroup

dscbot edited this page Dec 5, 2025 · 2 revisions

SYNOPSIS

Converts a DatabaseFileGroupSpec object to a SMO FileGroup object.

SYNTAX

ConvertTo-SqlDscFileGroup [-DatabaseObject] <Database> [-FileGroupSpec] <DatabaseFileGroupSpec>
 [<CommonParameters>]

DESCRIPTION

This command takes a DatabaseFileGroupSpec specification object and converts it to a SMO (SQL Server Management Objects) FileGroup object with all configured data files. This is used internally when creating databases with custom file group configurations.

EXAMPLES

EXAMPLE 1

$fileSpec = New-SqlDscDataFile -Name 'TestDB_Data' -FileName 'C:\SQLData\TestDB.mdf' -AsSpec
$fileGroupSpec = New-SqlDscFileGroup -Name 'PRIMARY' -Files @($fileSpec) -AsSpec
$smoFileGroup = ConvertTo-SqlDscFileGroup -DatabaseObject $database -FileGroupSpec $fileGroupSpec

Converts a DatabaseFileGroupSpec to a SMO FileGroup object with data files.

PARAMETERS

-DatabaseObject

The SMO Database object to which the FileGroup will belong.

Type: Database
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-FileGroupSpec

The DatabaseFileGroupSpec object containing the file group configuration.

Type: DatabaseFileGroupSpec
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

None.

OUTPUTS

Microsoft.SqlServer.Management.Smo.FileGroup

Returns a FileGroup object configured with the specified properties and data files.

NOTES

RELATED LINKS

Home

Commands

Resources

Usage

Clone this wiki locally