?
Solved

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

Posted on 2014-01-21
3
Medium Priority
?
1,100 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 71

Accepted Solution

by:
Qlemo earned 2000 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline

864 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