Access network share inside script block

Welcome Forums General PowerShell Q&A Access network share inside script block

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
1 year, 6 months ago.

  • Author
    Posts
  • #70948

    Participant
    Points: 0
    Rank: Member

    $SB={
    $cabfileGeneralShare="\\server1\cabfiles\"
    $CabfileLocal="c:\temp\cab"
    $file="wsusscn2.cab";
    robocopy $cabfileGeneralShare $CabfileLocal $file /R:1 /W:0 /FP /TEE /V
    $env:COMPUTERNAME
    }

    $cred=Get-Credential;# we use smart card credential (double hop issue), so I cant pass username and password as parameter and use newpsdrive inside script block
    Invoke-Command -ScriptBlock $SB -ComputerName "remote1" -Credential $cred

    ERROR 5 (0x00000005) Getting File System Type of Source ,\\server1\cabfiles\ access denied

  • #70960

    Participant
    Points: 0
    Rank: Member

    Error code refers access denied (0x00000005), Check NTFS permission on the share.

The topic ‘Access network share inside script block’ is closed to new replies.