locked
Create object on remote server RRS feed

  • Question

  • Hello,

    I have a problem with a new-item command that i issued to create a folder on a remote server.

    Running the below command on local server works without a problem. Error rose when trying the same with a remote (pingable) server. As a side note: I'm able to access the remote server (SRV2) file system drive with Get-Item/ChildItem cmdlets. Here's a snasphot of the problematic line in the function:

    $bic = "random input ID"
    $Slave = 'SRV2'
    $Lspath2 = 'D:\somefolder'
    $dir = New-Item -ItemType directory -Path ("\\$Slave\$LSpath2\trax_" + $bic)

    I know that invoke-command can be used to that extend, but as you can see i want to be able to grab the created folder into a variable which will be used further in the function.

    Any hints, direction, or rethinking of what i'm trying to accomplish will be much appreciated.

    Many thanks!!!



    Monday, October 10, 2016 1:07 PM

Answers

  • Hi Teciluas,

    this fails because your path is wrong for an UNC path:

    # What your path will be
    "\\SRV2\D:\somefolder\trax_123456789"
    
    # What it should be
    "\\SRV2\D$\somefolder\trax_123456789"

    Basically, when accessing a remote server using SMB, you need to access a share on that server. You use ":" for local or mapped drives only. Most Windows Computers joined to a domain have administrative shares enabled, which amongst other things creates a hidden share for each local drive it has (the "$" behind the letter protects it from being displayed while browsing the server for shares).

    Cheers,
    Fred


    There's no place like 127.0.0.1

    • Marked as answer by Teciluas Monday, October 10, 2016 1:41 PM
    Monday, October 10, 2016 1:27 PM

All replies

  • Hi Teciluas,

    this fails because your path is wrong for an UNC path:

    # What your path will be
    "\\SRV2\D:\somefolder\trax_123456789"
    
    # What it should be
    "\\SRV2\D$\somefolder\trax_123456789"

    Basically, when accessing a remote server using SMB, you need to access a share on that server. You use ":" for local or mapped drives only. Most Windows Computers joined to a domain have administrative shares enabled, which amongst other things creates a hidden share for each local drive it has (the "$" behind the letter protects it from being displayed while browsing the server for shares).

    Cheers,
    Fred


    There's no place like 127.0.0.1

    • Marked as answer by Teciluas Monday, October 10, 2016 1:41 PM
    Monday, October 10, 2016 1:27 PM
  • Hello Fred,

    Thanks for the explanation! I came down to simple file system basics! Many thanks for taking the time to answer me.

    Cheers,

    Anicet

    Monday, October 10, 2016 1:43 PM