Enable access to a network folder

Welcome Forums General PowerShell Q&A Enable access to a network folder

Viewing 0 reply threads
  • Author
    Posts
    • #5546
      Member
      Topics: 1562
      Replies: 0
      Points: 0
      Rank: Member

      by Yareth at 2013-02-13 13:42:57

      Hi everyone,

      I'd like to find out if I'm approaching my case appropriately. I'd like to grant access to a network folder to a user that is on the domain.
      As in code below I use Get-Credential to get their user name and password and based on that I would like for the folder to open.

      Get-Credential

      $credential = Get-Credential
      $userName = $credential.UserName
      $pass = $credential.Password

      if ( ($userName -eq 'USER' ) -and ((([Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($pass)) -eq 'PA$$WORD')) ))
      {

      invoke-item \\SERVER\data\staff\fax}

      Or should I do this in some other more cleaner way? Thanks

      by JeffH at 2013-02-13 16:09:26

      Are you trying to open a folder with a credential? You could create a temporary PSDrive which has built in support for a PSCredential.

Viewing 0 reply threads
  • The topic ‘Enable access to a network folder’ is closed to new replies.