Hi all,
I have been writing minor PS scripts for a couple of weeks now and have slowly increasing my knowledge. I have written the following script and what it is supposed to do is as follows:
List's the child items of the folder that is input in a command. It then outputs it in a Gridview to allow for the specific subfolder to be chosen, and at that point, I am looking to have it list the permissions of that selected folder in a CSV file.
My issue is that after selecting the folder in the Gridview pane, I am getting the following error:
Get-Acl : Cannot find path 'Projects' because it does not exist.
At I:\Administration\Scripts\Get Folder PermissionsV1.ps1:9 char:32
+ Get-Acl | Format-List | export-csv c:\Permissions ...
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Get-Acl], ItemNotFoundException
+ FullyQualifiedErrorId : GetAcl_PathNotFound_Exception,Microsoft.PowerShell.Commands.GetAclCommand
The code is listed here as well. I've looked up this error, but not quite sure of the direction to head.
$server = read-host "Enter the name of the server you want information about."
$folder = read-host "Enter the folder you want information about."
Write-Host "Please be patient as the file will take some time to populate."
Get-ChildItem "\\$server\$folder" -Filter * |
where {$_.PsIsContainer} |
Select -ExpandProperty Name |
Sort |
Out-GridView -PassThru |
Get-Acl | Format-List | export-csv c:\Permissions.csv -NoTypeInformation
Invoke-item c:\Permissions.csv