execute command dir on powershell sqlserver

Posted on 2014-08-12
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 38

    Accepted Solution

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
    This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
    Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now