concept Export - DbaScript in category dbatools

appears as: Export-DbaScript
Learn dbatools in a Month of Lunches

This is an excerpt from Manning's book Learn dbatools in a Month of Lunches.

14.2.1  Using Export-DbaScript

Export-DbaScript allows you export T-SQL from commands that output SMO objects, such as Get-DbaAgentJob or Get-DbaDbStoredProcedure. This is similar to right-clicking in SSMS and Script [object] as.

Listing 14.9. Using Export-DbaScript with Get-DbaAgentJob
````
PS C:\> Get-DbaAgentJob -SqlInstance sql01 | Select-Object -First 1 | Export-DbaScript