Skip to content

Commit d26c6bc

Browse files
committed
Added a new SQL Server Agent section in sql server powershell article
1 parent efdfea1 commit d26c6bc

2 files changed

Lines changed: 23 additions & 7 deletions

File tree

docs/powershell/download-sql-server-ps-module.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ Visit [Manage SQL Server on Linux with PowerShell Core](../linux/sql-server-linu
150150

151151
## Other modules
152152

153-
- [Az.Sql](https://www.powershellgallery.com/packages/Az.Sql/)
154-
- [SqlServerDsc](https://www.powershellgallery.com/packages/SqlServerDsc/)
155-
- [ReportingServicesTools](https://www.powershellgallery.com/packages/ReportingServicesTools/)
156-
- [MicrosoftPowerBIMgmt](https://www.powershellgallery.com/packages/MicrosoftPowerBIMgmt/)
153+
- [Az.Sql](https://www.powershellgallery.com/packages/Az.Sql/) - SQL service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.
154+
155+
- [SqlServerDsc](https://www.powershellgallery.com/packages/SqlServerDsc/) - Module with DSC resources for deployment and configuration of Microsoft SQL Server.
156+
157+
## Next steps
158+
159+
[SQL Server PowerShell](sql-server-powershell.md)

docs/powershell/sql-server-powershell.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ To ship SQL PowerShell updates, we had to change the identity of the SQL PowerSh
3333

3434
If you have any PowerShell scripts that run `Import-Module -Name SQLPS`, and you want to take advantage of the new provider functionality and new cmdlets, you must change them to `Import-Module -Name SqlServer`. The new module is installed to `%ProgramFiles%\WindowsPowerShell\Modules\SqlServer` folder. As such, you don't have to update the $env:PSModulePath variable. If you have scripts that use a third-party or community version of a module named **SqlServer**, use the Prefix parameter to avoid name collisions.
3535

36-
There's no change to the module used by SQL Server Agent. As such, the job steps of the type PowerShell use the SQLPS module. For more information, see [How to run PowerShell with SQL Server Agent](run-windows-powershell-steps-in-sql-server-agent.md).
37-
3836
## SQL Server PowerShell Components
3937

4038
The **SqlServer** module loads two Windows PowerShell snap-ins:
@@ -57,7 +55,22 @@ Use the **Convert-UrnToPath** cmdlet to convert a Unique Resource Name for a Dat
5755

5856
Query expressions are strings that use syntax similar to XPath to specify a set of criteria that enumerates one or more objects in an object model hierarchy. A Unique Resource Name (URN) is a specific type of query expression string that uniquely identifies a single object. For more information, see [Query Expressions and Uniform Resource Names](query-expressions-and-uniform-resource-names.md).
5957

58+
## SQL Server Agent
59+
60+
There's no change to the module used by SQL Server Agent. As such, SQL Server Agent jobs which have job steps of the type PowerShell use the SQLPS module. For more information, see [How to run PowerShell with SQL Server Agent](run-windows-powershell-steps-in-sql-server-agent.md). However, starting with SQL Server 2019, you can disable this. To do so, on the first line of a job step of the type PowerShell you can add `#NOSQLPS` which stops the SQL Agent from auto-loading the SQLPS module. When you do this, your SQL Agent Job runs the version of PowerShell installed on the machine, and then you can use any other PowerShell module you like.
61+
62+
If you want to use the **SqlServer** module in your SQL Agent Job step, you can place this code on the first two lines of your script.
63+
64+
```powershell
65+
#NOSQLPS
66+
Import-Module -Name SqlServer
67+
```
68+
6069
## Cmdlet reference
6170

6271
- [SqlServer cmdlets](https://docs.microsoft.com/powershell/module/sqlserver)
63-
- [SQLPS cmdlets](https://docs.microsoft.com/powershell/module/sqlps)
72+
- [SQLPS cmdlets](https://docs.microsoft.com/powershell/module/sqlps)
73+
74+
## Next steps
75+
76+
[Download SQL Server PowerShell Module](download-sql-server-ps-module.md)

0 commit comments

Comments
 (0)