Solved

Powershell: Need help with function that returns NTFS permissions on folder

Posted on 2014-01-21
3
1,006 Views
Last Modified: 2014-01-21
Hi,

I have found a script that exports NTFS permissions on a folder for groups and users recursive, to a csv file. I just can't get it to run properly. I have attached the script to this question and it can be found as well here: Script

I tried to call the function from another file like this:
C:\Temp\Get-FolderRights.ps1 
Get-NTFSPermissions -ShareName "\\apps003\archive$" -DomainName "domain" | Convertto-CSV | Out-file "C:\Temp\NTFSRights.csv"

Open in new window

It gave me this error:
The term 'Get-NTFSPermissions' is not recognized as the name of a cmdlet, function, etc.etc.

I tried this as well:
C:\Temp\Get-FolderRights.ps1 Get-NTFSPermissions -ShareName "\\apps003\archive$" -DomainName "domain" | Convertto-CSV | Out-file "C:\Temp\NTFSRights.csv"

Open in new window

It did not return an error.
It created only an empty csv file.

Tried to add the parameters directly int the script, this didn't work as well.

I'm doing something wrong but I can't figure out what.
Can someone help me on this ?

Thanks in advance !
0
Comment
Question by:Loyall
3 Comments
 
LVL 16

Expert Comment

by:Dale Harris
ID: 39796787
This may be a simple question, but did you attempt to load the function manually?  Try a simple copy/paste to make sure it all works and gets put into PowerShell.
0
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39796792
You need to call the script with the dot operator. Without, the script builds its own scope, and all functions, vars etc. will not be part of your session (dismissed as soon as the script ran).
. C:\Temp\Get-FolderRights.ps1 
Get-NTFSPermissions -ShareName "\\apps003\archive$" -DomainName "domain" | Convertto-CSV | Out-file "C:\Temp\NTFSRights.csv"

Open in new window

Note that you have to call the script only once for your current session. It just defines the function here, so you can use it until you terminate the session (e.g. by typing exit)
0
 
LVL 2

Author Closing Comment

by:Loyall
ID: 39796841
Just one little dot and some space !
Thanks a lot Qlemo, you gave the right solution !
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question