Solved

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

Posted on 2014-01-21
3
978 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 68

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Synchronize a new Active Directory domain with an existing Office 365 tenant
This article will help you understand what HashTables are and how to use them in PowerShell.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now