dbatools is a free PowerShell module with over 180 SQL Server administration, best practice and migration commands included.


Test-SqlPath

Uses master.dbo.xp_fileexist to determine if a file or directory exists, from the perspective of the SQL Server service account.

Examples

To test whether the service account running the “sqlcluster” SQL Server instance can access L:\MSAS12.MSSQLSERVER\OLAP. Logs into sqlcluster using Windows credentials.

Test-SqlPath -SqlServer sqlcluster -Path L:\MSAS12.MSSQLSERVER\OLAP

To test whether the service account running the “sqlcluster” SQL Server instance can access L:\MSAS12.MSSQLSERVER\OLAP. Logs into sqlcluster using SQL authentication.

$credential = Get-Credential
Test-SqlPath -SqlServer sqlcluster -SqlCredential $credential -Path L:\MSAS12.MSSQLSERVER\OLAP

Get-Help

From PowerShell, execute Get-Help Test-SqlPath -Detailed for more information on this function.

Source Code

Want to see the source code? View Test-SqlPath.ps1 on GitHub
 

Related commands