Solved

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

Posted on 2014-01-21
3
1,031 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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  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 quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
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 antispam), the admini…

696 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