Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

execute command dir on powershell sqlserver

Posted on 2014-08-12
1
Medium Priority
?
276 Views
Last Modified: 2014-08-12
Hello,

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.

Thanks

Regards
0
Comment
Question by:bibi92
1 Comment
 
LVL 41

Accepted Solution

by:
footech earned 2000 total points
ID: 40256026
Is this a remote session?  If so you're probably running into the kerberos double-hop problem.
http://blogs.technet.com/b/heyscriptingguy/archive/2012/11/14/enable-powershell-quot-second-hop-quot-functionality-with-credssp.aspx
You would have to use CredSSP for this to work.
0

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