Enable access to a network folder

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 5 years, 11 months ago.

  • Author
    Posts
  • #5546

    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.

You must be logged in to reply to this topic.