Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Context #71

Open
lorenzstorm1 opened this issue Oct 7, 2020 · 9 comments
Open

User Context #71

lorenzstorm1 opened this issue Oct 7, 2020 · 9 comments
Assignees
Labels
Question Someone has a question about feature or usability Solution Delivered A solution has been provided

Comments

@lorenzstorm1
Copy link

The Commands are always executed with the current user context permissions. Is it possible to specify another User for Accessing the Folder/Share/File?

@mwtrigg
Copy link

mwtrigg commented Oct 7, 2020

Create a PSDrive with alternate credentials, and run commands against that drive.

@lorenzstorm1
Copy link
Author

lorenzstorm1 commented Oct 12, 2020

Works - had to make the PSDrive persist

@lorenzstorm1
Copy link
Author

Does not work with the NTFSSecurity Module:
New-PSDrive -Name "W2" -PSProvider "FileSystem" -Root $Pfad -Credential $Cred
$Share = "W2"
get-psdrive
Name Used (GB) Free (GB) Provider Root CurrentLocation


Alias Alias
C 54,65 45,01 FileSystem C:\
D 0,45 99,55 FileSystem D:
W2 FileSystem \path to share
Get-NTFSAccess -Path W2:
Get-NTFSAccess: Unable to find the specified file.

Other non NTFSSecurity Module cmdlets work e.g.: Get-ChildItem -Path W2:

@raandree raandree self-assigned this Apr 20, 2021
@raandree raandree added the Question Someone has a question about feature or usability label Apr 20, 2021
@raandree
Copy link
Owner

Right, the commands are invoked in the context of the currently logged on user. @mwtrigg's idea would work if NTFSSecurity used the PowerShell providers. But one purpose of the module was to solve the Windows PowerShell 260 character path limitation, hence it uses AlphaFS which does not even know about PowerShell.

@lorenzstorm1, I know this answer comes a bit late. If you still have this issue, please try to use Invoke-Command.

@raandree raandree added the Solution Delivered A solution has been provided label Apr 20, 2021
@lorenzstorm1
Copy link
Author

Hi,

just tested with Invoke-Command > also not working

Invoke-Command -Computername $Server -Credential $Cred -ScriptBlock {Get-NTFSAccess -Path C:} > works
Invoke-Command -Computername $Server -Credential $Cred -ScriptBlock {Get-NTFSAccess -Path \nas\share} > does not work

@Sup3rlativ3
Copy link

I have a couple of questions for you that might help us get to the bottom of it for you.

  • What are you running this against? Is is a windows or Linux box, is it some sort of prebuilt NAS like Synology?
  • What version of NTFSSecurity are you using?
  • What client are you using? e.g. Windows 10 20H2, Windows 7?

I know that both of those situations work as I created an RBAC module and used both methods. Also, just double checking that you used a double backslash and not just a single e.g. \nas not \nas?

@lorenzstorm1
Copy link
Author

What are you running this against? Is is a windows or Linux box, is it some sort of prebuilt NAS like Synology? EMC Isilon/Powerscale
What version of NTFSSecurity are you using? the newest
What client are you using? e.g. Windows 10 20H2, Windows 7? Server 2019

I want to run this Powershell Command through Jenkins Powershell Plugin which is always executed as SYSTEM User. So i somehow need to find a way to include a User with Permissions to the NAS in the Command. Hope that helps

@Sup3rlativ3
Copy link

What's doing the authentication on the fileshares on your EMC, is it the domain controller or is it a local account?

Local account:
If the user is local to the EMC, I could suggest putting the hostname of the EMC in place of the domain e.g. EMC01\User.name or you could try putting a period in instead like .\user.name

Domain account:
If the shares are being hosted by a windows box the something like the below would work. Please note that this is obviously just a same and putting passwords in a script is a bad thing and shouldn't be done in prod.

$Server = "SERVER01.DOMAIN.INTERNAL"
$Username = "DOMAIN\USER.NAME"
$PlainPassword = "P@ssw0rd"
$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $UserName, $SecurePassword
Invoke-Command -ComputerName $Server -Credential $Credentials -ScriptBlock {Import-Module NTFSAccess; Get-NTFSAccess -Path \\$Using:Server\Share}

One other thing, is NTFSAccess installed for everyone on the remote server? If it's not available, you won't be able to use the cmdlet. I know it seems obvious but I've seen people skip over that detail.

@jcardel
Copy link

jcardel commented Aug 3, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Someone has a question about feature or usability Solution Delivered A solution has been provided
Projects
None yet
Development

No branches or pull requests

5 participants