Learn how to a build a cloud-first strategyRegister Now


execute command dir on powershell sqlserver

Posted on 2014-08-12
Medium Priority
Last Modified: 2014-08-12

Is it possible to execute a command dir on share drive through powershell sqlserver ?
I try the following command, the share is accessible  :
PS SQLSERVER:\> $location = "\\sharedb\Databases\dbserver"
PS SQLSERVER:\> $DBStats = dir -force $location | where-object {$_.Name -ne "tempdb"; $_.Refresh()}
PS SQLSERVER:\> dir : Cannot find path '\\sharedb\Databases\dbserver' because it does not exist.


Question by:bibi92
1 Comment
LVL 41

Accepted Solution

footech earned 2000 total points
ID: 40256026
Is this a remote session?  If so you're probably running into the kerberos double-hop problem.
You would have to use CredSSP for this to work.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Loops Section Overview

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question