Sethu's blog

dev@sqlservr.microsoft

Workaround: 'sqlps' and "Test-Path" PowerShell cmdlet on a UNC path

Workaround: 'sqlps' and "Test-Path" PowerShell cmdlet on a UNC path

  • Comments 1

Related Forum thread: http://social.msdn.microsoft.com/Forums/en-US/sqlsmoanddmo/thread/719ede23-9f1a-43f5-8c4e-8188fea0b19f/

Related Connect feedback: https://connect.microsoft.com/SQLServer/feedback/details/768743/sql-server-2012-import-module-sqlps-breaks-the-test-path-powershell-cmdlet

Issue:
When Test-Path cmdlet is run in SQL Powershell from the context of SQL Powershell provider path, Test-Path returns False. We see the same behavior with Registry Window Powershell provider as well

Workaround:
Specify literal path while using Test-Path cmdlet
Example:
test-path -literalpath "FileSystem::\\machine\uncpath"

References:
http://mcpmag.com/articles/2011/05/16/handling-errors-scripts-test-path.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ee126188(v=vs.85).aspx

Comments
  • Thanks a bunch -- couldn't figure out why Test-Path wasn't working in my SQL agent job.

Page 1 of 1 (1 items)
Leave a Comment
  • Please add 8 and 8 and type the answer here:
  • Post