New‑SqlDscFileGroup - dsccommunity/SqlServerDsc GitHub Wiki
Creates a new FileGroup object for a SQL Server database.
New-SqlDscFileGroup -Name <String> [-WhatIf] [-Confirm]
[<CommonParameters>]
New-SqlDscFileGroup -Database <Database> -FileGroupSpec <DatabaseFileGroupSpec> [-Force]
[-WhatIf] [-Confirm] [<CommonParameters>]
New-SqlDscFileGroup -Database <Database> -Name <String> [-Force] [-WhatIf]
[-Confirm] [<CommonParameters>]
New-SqlDscFileGroup -Name <String> [-AsSpec] [-Files <DatabaseFileSpec[]>] [-ReadOnly] [-IsDefault]
[-WhatIf] [-Confirm] [<CommonParameters>]
This command creates a new FileGroup object that can be used when creating or modifying SQL Server databases. The FileGroup object can contain DataFile objects. The FileGroup can be created with or without an associated Database, allowing it to be added to a Database later using Add-SqlDscFileGroup.
$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$database = $serverObject.Databases['MyDatabase']
$fileGroup = New-SqlDscFileGroup -Database $database -Name 'MyFileGroup'
Creates a new FileGroup named 'MyFileGroup' for the specified database.
$serverObject = Connect-SqlDscDatabaseEngine -InstanceName 'MyInstance'
$database = $serverObject.Databases['MyDatabase']
$fileGroup = New-SqlDscFileGroup -Database $database -Name 'PRIMARY'
Creates a new PRIMARY FileGroup for the specified database.
$fileGroup = New-SqlDscFileGroup -Name 'MyFileGroup'
Add-SqlDscFileGroup -Database $database -FileGroup $fileGroup
Creates a standalone FileGroup that can be added to a Database later.
$fileGroupSpec = New-SqlDscFileGroup -Name 'PRIMARY' -AsSpec
Creates a DatabaseFileGroupSpec object that can be passed to New-SqlDscDatabase.
$primaryFile = New-SqlDscDataFile -Name 'MyDB_Primary' -FileName 'D:\SQLData\MyDB.mdf' -Size 102400 -IsPrimaryFile -AsSpec
$fileGroupSpec = New-SqlDscFileGroup -Name 'PRIMARY' -Files @($primaryFile) -IsDefault $true -AsSpec
Creates a DatabaseFileGroupSpec object with files and properties set directly via parameters.
Returns a DatabaseFileGroupSpec object instead of a SMO FileGroup object. This specification object can be passed to New-SqlDscDatabase to define file groups before the database is created.
Type: SwitchParameter
Parameter Sets: AsSpec
Aliases:
Required: True
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the Database object to which this FileGroup will belong. This parameter is optional. If not specified, a standalone FileGroup is created that can be added to a Database later.
Type: Database
Parameter Sets: WithDatabaseFromSpec, WithDatabase
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies a DatabaseFileGroupSpec object that defines the file group configuration including name, properties, and data files.
Type: DatabaseFileGroupSpec
Parameter Sets: WithDatabaseFromSpec
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies an array of DatabaseFileSpec objects to include in the file group. Only valid when using -AsSpec.
Type: DatabaseFileSpec[]
Parameter Sets: AsSpec
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies that the FileGroup object should be created without prompting for confirmation. By default, the command prompts for confirmation when the Database parameter is provided.
Type: SwitchParameter
Parameter Sets: WithDatabaseFromSpec, WithDatabase
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies whether this file group should be the default file group. Only valid when using -AsSpec.
Type: SwitchParameter
Parameter Sets: AsSpec
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the name of the FileGroup to create.
Type: String
Parameter Sets: Standalone, WithDatabase, AsSpec
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies whether the file group should be read-only. Only valid when using -AsSpec.
Type: SwitchParameter
Parameter Sets: AsSpec
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalsePrompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseShows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.