Invoke D365SqlScript - FH-Inway/d365fo.tools GitHub Wiki
Execute a SQL Script or a SQL Command
Invoke-D365SqlScript [-FilePath] <String> [-DatabaseServer <String>] [-DatabaseName <String>]
[-SqlUser <String>] [-SqlPwd <String>] [-TrustedConnection <Boolean>] [-EnableException] [-NoPooling]
[<CommonParameters>]
Invoke-D365SqlScript [-Command] <String> [-DatabaseServer <String>] [-DatabaseName <String>]
[-SqlUser <String>] [-SqlPwd <String>] [-TrustedConnection <Boolean>] [-EnableException] [-NoPooling]
[<CommonParameters>]
Execute a SQL Script or a SQL Command against the D365FO SQL Server database
Invoke-D365SqlScript -FilePath "C:\temp\d365fo.tools\DeleteUser.sql"
This will execute the "C:\temp\d365fo.tools\DeleteUser.sql" against the registered SQL Server on the machine.
Invoke-D365SqlScript -Command "DELETE FROM SALESTABLE WHERE RECID = 123456789"
This will execute "DELETE FROM SALESTABLE WHERE RECID = 123456789" against the registered SQL Server on the machine.
Invoke-D365SqlScript -Command "DELETE FROM SALESTABLE WHERE RECID = 123456789" -NoPooling
This will execute "DELETE FROM SALESTABLE WHERE RECID = 123456789" against the registered SQL Server on the machine. It will not use connection pooling.
Path to the file containing the SQL Script that you want executed
Type: String
Parameter Sets: FilePath
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
SQL command that you want executed
Type: String
Parameter Sets: Command
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The name of the database server
If on-premises or classic SQL Server, use either short name og Fully Qualified Domain Name (FQDN).
If Azure use the full address to the database server, e.g. server.database.windows.net
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: $Script:DatabaseServer
Accept pipeline input: False
Accept wildcard characters: False
The name of the database
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: $Script:DatabaseName
Accept pipeline input: False
Accept wildcard characters: False
The login name for the SQL Server instance
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: $Script:DatabaseUserName
Accept pipeline input: False
Accept wildcard characters: False
The password for the SQL Server user
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: $Script:DatabaseUserPassword
Accept pipeline input: False
Accept wildcard characters: False
Switch to instruct the cmdlet whether the connection should be using Windows Authentication or not
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This parameters disables user-friendly warnings and enables the throwing of exceptions This is less user friendly, but allows catching exceptions in calling scripts
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Should the connection use connection pooling or not
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Author: Mötz Jensen (@splaxi)
Author: Caleb Blanchard (@daxcaleb)