set-location and enter-pssession

Welcome Forums General PowerShell Q&A set-location and enter-pssession

This topic contains 6 replies, has 3 voices, and was last updated by

 
Participant
1 year ago.

  • Author
    Posts
  • #83308

    Inactive
    Points: 0
    Rank: Member

    I am unable to use the set-location command after I have connected to remote computer using enter-pssession. Is this possible?

    Thank for any help!

    Robert

  • #83309

    Keymaster
    Points: 1,638
    Helping HandTeam Member
    Rank: Community Hero

    Provided the location you specify exists and you have permission, and the Remoting endpoint doesn't prevent it, then yes.

    • #83351

      Participant
      Points: 1
      Rank: Member

      What happens if you:
      PS> Enter-PSSession $Hostname
      PS> Test-Path $ThePathYouWantToSet-LocationTo

  • #83402

    Inactive
    Points: 0
    Rank: Member

    Thank you.... Don

    The location does exist.

    This is a domain computer. I can use the set-location command when I am physically on the machine:

    PS C:\WINDOWS\system32> hostname
    OWT2077

    PS C:\WINDOWS\system32> Set-Location -Path \\owsms\Infotech

    PS Microsoft.PowerShell.Core\FileSystem::\\owsms\Infotech>

    When connect to OWT2077 using enable-pssession and try using the set-location command I get this:

    [owt2077]: PS C:\Users\e139022\Documents> Set-Location "\\owsms\infotech"

    Set-Location : Access is denied
    + CategoryInfo : PermissionDenied: (\\owsms\infotech:String) [Set-Location], UnauthorizedAcc
    essException
    + FullyQualifiedErrorId : ItemExistsUnauthorizedAccessError,Microsoft.PowerShell.Commands.SetLocation
    Command

    I don't understand where the PermissionDenied is coming from?

    Thank you again for your input!

    Robert

  • #83414

    Keymaster
    Points: 1,638
    Helping HandTeam Member
    Rank: Community Hero

    Ah. You're attempting to connect to a UNC. That won't work in the default Remoting world because your delegated credential cannot be delegated across a second hop. This is “the second hop problem;” see same in “Secrets of PowerShell Remoting” on our ebooks menu. You would be perhaps better cresting a new PSDrive to the UNC, as you can provide explicit credentials to do so.

  • #83423

    Inactive
    Points: 0
    Rank: Member

    Thank you Don!

    I have to say – I didn't expect to get a response from someone with your level of skill and recognition. I am pretty new to PowerShell but I have completely absorbed myself in it. I have taken your "Play by Play: PowerShell from Idea to Action" on Pluralsight. I also have listened to you on Channel 9. I have taken the courses on MVA taught by Jason Helmick and Jeffery Snover. Jeffery Snover is always touting how great the PowerShell community is. After this experience – I am can see why. You guys are all great teachers and I enjoy learning from all of you. So Thank You for sacrifices and time you give.

    Robert Rosas

  • #83435

    Participant
    Points: 1
    Rank: Member

    Don ... that guy 😉

The topic ‘set-location and enter-pssession’ is closed to new replies.