Link to home
Start Free TrialLog in
Avatar of creative555
creative555

asked on

help with the script needed to get folder owners for multiple shares instead of one share

Hi,

I have this script that exports folder owners to the csv file. It only does it for one share. I would like to use import file with multiple shares  listed in UNC format (\\servername\share) and to export results for each share  into each share's respective file name - share1.csv, share2.csv, etc. Something like this but it is from another script and I would not be able to combine them since the folder owner script is different. Please help. Thank you so much!


Get-Content shares.txt | ForEach `
{
    $share = ($_ -split "\\")[-1]

Open in new window


and add

| Export-CSV "F:\NTFSReports\$share.csv"

Open in new window

........................


Script is below
function Get-FolderOwner {
    param(
        [string] $Path = "\\NYCFileServer01\sharename",
        [int] $RecurseDepth = 1
    )

    $RecurseDepth--

    Get-ChildItem $Path -Directory | ForEach-Object {
        # Get-Acl throws terminating errors, so we need to wrap it in
        # a ForEach-Object block; included -ErrorAction Stop out of habit
        try {
            $Owner = $_ | Get-Acl -ErrorAction Stop | select -exp Owner
        }
        catch {
            $Owner = "Error: {0}" -f $_.Exception.Message
        }

        [PSCustomObject] @{
            Path = $_.FullName
            Owner = $Owner
        }

        if ($RecurseDepth -gt 0) {
            Get-FolderOwner -Path $_.FullName -RecurseDepth $RecurseDepth
        }
    }
}

Try
{
    Get-FolderOwner \\NYC-Fileserver01\SHarename -RecurseDepth 100 | Export-Csv E:\scripts\NTFS\FolderOwner-Sharename.csv

}
Catch [System.OutOfMemoryException]
{
   # Restart-Computer localhost
}
Catch
{
    $ErrorMessage = $_.Exception.Message
    $FailedItem = $_.Exception.ItemName
    # Send-MailMessage -From ExpensesBot@MyCompany.Com -To WinAdmin@MyCompany.Com -Subject "HR File Read Failed!" -SmtpServer EXCH01.AD.MyCompany.Com -Body "We failed to read file $FailedItem. The error message was $ErrorMessage"
    Break
}
Finally
{
    $Time=Get-Date
    "This script made a read attempt at $Time" | out-file e:\scripts\NTFS\NTFSscriptlog.log -append
}

Open in new window

Avatar of creative555
creative555

ASKER

Thank you so much for moving code into snippet.
Avatar of Jeremy Weisinger
Hi creative555,

Here's a script based on others that I've written. See if this is what you're looking for.

$shareList = 'shares.txt' #Enter the path to the share list file
$OutputDirectory = 'C:\output\' #Enter a path if you want to save the CSVs to something besides the working directory.

function Get-FolderOwner{ 
    Param (
        $rootdir, #Directory that is the base/root of the scan
        $outCSV  #Location to output CSV results
        )


 
    $table = New-Object system.Data.DataTable "OwnerInfo" 
    $col1 = New-Object system.Data.DataColumn Path,([string]) 
    $table.columns.add($col1) 
    $col2 = New-Object system.Data.DataColumn Owner,([string]) 
    $table.columns.add($col2) 

   
    #Get all directories in root directory
    $dirs = Get-ChildItem $rootdir -Recurse -Directory

    #Get root directory Owner info
    $rootacl = Get-Acl $rootdir

    $row = $table.NewRow() 
    $row.Path = $rootacl.path.Replace('Microsoft.PowerShell.Core\FileSystem::','') 
    $row.Owner = $rootacl.Owner
    $table.Rows.Add($row) 


    #Get Owner for all subdirectories
    $diracls = $dirs | Get-Acl

    #Loop through permissions
    Foreach($acl in $diracls) {

        $row = $table.NewRow() 
        $row.Path = $acl.path.Replace('Microsoft.PowerShell.Core\FileSystem::','') 
        $row.Owner = $acl.Owner
        $table.Rows.Add($row) 

    }


    #Write results to CSV file
    $table | Export-Csv $outCSV -NoTypeInformation
    #Clean up variables
    Remove-Variable table,dirs,diracls,rootacl,acl,dir

    }

# Get list of directories to scan
Get-Content $shareList | ForEach{
    $shareCSVName = ($_ -split "\\")[-2] +'_'+($_ -split "\\")[-1]+'.csv'
    If($OutputDirectory.Length -gt 0){
        If($OutputDirectory.EndsWith('\')){
            $shareCSVName = $OutputDirectory+$shareCSVName
            }else{
            $shareCSVName = $OutputDirectory+'\'+$shareCSVName
        }
    }    
    Get-FolderOwner -rootdir $_ -outCSV $shareCSVName
}

Open in new window


A few things to note:
1. You need to modify the variables at the top of the script to reflect your environment.
2. I have changed the output file name from "sharename.csv" to "servername_sharename.csv" in case there's any name collision. This can easily be changed back to just the share name.
Oh. excellent. Will test it tonight and let you know if that works!! :)
Hello,
Thank you so much. It worked partially. In particular the files with owners that had access denied didn't work. Below are the errors that I received. Thank you so much


Remove-Variable : Cannot find a variable with name 'dir'.
At C:\NYC\Scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1
:48 char:5
+     Remove-Variable table,dirs,diracls,rootacl,acl,dir
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (dir:String) [Remove-Variable], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableComm
   and
 
Get-ChildItem : Could not find a part of the path '\\USWESWNE3I60\Installs-TEST\test'.
At C:\NYC\Scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1
:20 char:13
+     $dirs = Get-ChildItem $rootdir -Recurse -Directory
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ReadError: (\\USWESWNE3I60\Installs-TEST\test:String) [Get-Chi
   ldItem], DirectoryNotFoundException
    + FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
 


    Directory: \\USWESWNE3I60\Installs-TEST



    + CategoryInfo          : NotSpecified: (:) [Get-Acl], DirectoryNotFoundException
    + FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Command
   s.GetAclCommand
 
Remove-Variable : Cannot find a variable with name 'diracls'.
At C:\NYC\Scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1
:48 char:5
+     Remove-Variable table,dirs,diracls,rootacl,acl,dir
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (diracls:String) [Remove-Variable], ItemNotFoundE
   xception
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableComm
   and
 
Remove-Variable : Cannot find a variable with name 'acl'.
At C:\NYC\Scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1
:48 char:5
+     Remove-Variable table,dirs,diracls,rootacl,acl,dir
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (acl:String) [Remove-Variable], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableComm
   and
 
Remove-Variable : Cannot find a variable with name 'dir'.
At C:\NYC\Scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1
:48 char:5
+     Remove-Variable table,dirs,diracls,rootacl,acl,dir
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (dir:String) [Remove-Variable], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableComm
   and
 
Get-Acl : Cannot validate argument on parameter 'Path'. The argument is null or empty. Supply
an argument that is not null or empty and then try the command again.
At C:\NYC\Scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1
:23 char:24
+     $rootacl = Get-Acl $rootdir
+                        ~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Acl], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.Ge
   tAclCommand
 
You cannot call a method on a null-valued expression.
At C:\NYC\Scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1
:26 char:5
+     $row.Path = $rootacl.path.Replace('Microsoft.PowerShell.Core\FileSystem::',' ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
Remove-Variable : Cannot find a variable with name 'rootacl'.
At C:\NYC\Scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1
:48 char:5
+     Remove-Variable table,dirs,diracls,rootacl,acl,dir
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (rootacl:String) [Remove-Variable], ItemNotFoundE
   xception
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableComm
   and
 
Remove-Variable : Cannot find a variable with name 'acl'.
At C:\NYC\Scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1
:48 char:5
+     Remove-Variable table,dirs,diracls,rootacl,acl,dir
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (acl:String) [Remove-Variable], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableComm
   and
 
Remove-Variable : Cannot find a variable with name 'dir'.
At C:\NYC\Scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1
:48 char:5
+     Remove-Variable table,dirs,diracls,rootacl,acl,dir
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (dir:String) [Remove-Variable], ItemNotFoundExcep
   tion
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableComm
   and
Looks like the main issue is the directory isn't valid. Here's the relevant error:
Get-ChildItem : Could not find a part of the path '\\USWESWNE3I60\Installs-TEST\test'

Make sure all your shares are valid. Or if you don't know if the shares will be valid or not, we can add a test to the script to check the path before trying to get owner information.
hm. strange. I can access the shares i specified. I have them listed in the shares.txt like this:

\\USWESWNE3I60751\Installs
\\USWESWNE3I60751\Installs-TEST
hm strange. It adds additional Test directory at the end of share name

This is what I have
\\USWESWNE3I60751\Installs-TEST

It adds \\USWESWNE3I60751\Installs-TEST\Test ???


But it also says this:
PS C:\nyc\scripts\NTFS-PermissionsGetAndGrantScripts> .\GET-NTFSpermissionsvOwnerMultipleShares.ps1
Remove-Variable : Cannot find a variable with name 'dir'.
At C:\nyc\scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1:48 char:5
+     Remove-Variable table,dirs,diracls,rootacl,acl,dir
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (dir:String) [Remove-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableCommand

Get-ChildItem : Could not find a part of the path '\\USWESWNE3I60751\InstallsTEST\test'.
At C:\dhl\scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1:20 char:13
+     $dirs = Get-ChildItem $rootdir -Recurse -Directory
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ReadError: (\\USWESWNE3I60751\InstallsTEST\test:String) [Get-ChildItem], DirectoryNotFou
   ndException
    + FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand



    Directory: \\USWESWNE3I60751\InstallsTEST


Path                                    Owner                                   Access
----                                    -----                                   ------
1                                       AMER-AD\svc-admt                        TESTDOMAIN\user1 Allow  FullControl...
ActiveDirectory                         BUILTIN\Administrators                  TESTDOMAIN\user1 Allow  FullControl...
ADPermissionsReporterFree               BUILTIN\Administrators                  TESTDOMAIN\user1 Allow  FullControl...
dumpacl                                 BUILTIN\Administrators                  TESTDOMAIN\user1 Allow  FullControl...
l : \\USWESWNE3I60751\InstallsTEST\test
nyc\scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1:32 char:24
$diracls = $dirs | Get-Acl
                   ~~~~~~~
CategoryInfo          : NotSpecified: (:) [Get-Acl], DirectoryNotFoundException
FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.GetAclCommand

-Variable : Cannot find a variable with name 'diracls'.
nyc\scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1:48 char:5
Remove-Variable table,dirs,diracls,rootacl,acl,dir
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo          : ObjectNotFound: (diracls:String) [Remove-Variable], ItemNotFoundException
FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableCommand

-Variable : Cannot find a variable with name 'acl'.
nyc\scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1:48 char:5
Remove-Variable table,dirs,diracls,rootacl,acl,dir
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo          : ObjectNotFound: (acl:String) [Remove-Variable], ItemNotFoundException
FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableCommand

-Variable : Cannot find a variable with name 'dir'.
dhl\scripts\NTFS-PermissionsGetAndGrantScripts\GET-NTFSpermissionsvOwnerMultipleShares.ps1:48 char:5
Remove-Variable table,dirs,diracls,rootacl,acl,dir
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo          : ObjectNotFound: (dir:String) [Remove-Variable], ItemNotFoundException
FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableCommand
Here is the script that I am running:


$shareList = 'shares.txt' #Enter the path to the share list file
$OutputDirectory = 'C:\NYC\Scripts\NTFS-PermissionsGetAndGrantScripts' #Enter a path if you want to save the CSVs to something besides the working directory.

function Get-FolderOwner{
    Param (
        $rootdir, #Directory that is the base/root of the scan
        $outCSV  #Location to output CSV results
        )


 
    $table = New-Object system.Data.DataTable "OwnerInfo"
    $col1 = New-Object system.Data.DataColumn Path,([string])
    $table.columns.add($col1)
    $col2 = New-Object system.Data.DataColumn Owner,([string])
    $table.columns.add($col2)

   
    #Get all directories in root directory
    $dirs = Get-ChildItem $rootdir -Recurse -Directory

    #Get root directory Owner info
    $rootacl = Get-Acl $rootdir

    $row = $table.NewRow()
    $row.Path = $rootacl.path.Replace('Microsoft.PowerShell.Core\FileSystem::','')
    $row.Owner = $rootacl.Owner
    $table.Rows.Add($row)


    #Get Owner for all subdirectories
    $diracls = $dirs | Get-Acl

    #Loop through permissions
    Foreach($acl in $diracls) {

        $row = $table.NewRow()
        $row.Path = $acl.path.Replace('Microsoft.PowerShell.Core\FileSystem::','')
        $row.Owner = $acl.Owner
        $table.Rows.Add($row)

    }


    #Write results to CSV file
    $table | Export-Csv $outCSV -NoTypeInformation
    #Clean up variables
    Remove-Variable table,dirs,diracls,rootacl,acl,dir

    }

# Get list of directories to scan
Get-Content $shareList | ForEach{
    $shareCSVName = ($_ -split "\\")[-2] +'_'+($_ -split "\\")[-1]+'.csv'
    If($OutputDirectory.Length -gt 0){
        If($OutputDirectory.EndsWith('\')){
            $shareCSVName = $OutputDirectory+$shareCSVName
            }else{
            $shareCSVName = $OutputDirectory+'\'+$shareCSVName
        }
    }    
    Get-FolderOwner -rootdir $_ -outCSV $shareCSVName
}
Hmm... I just tested it and am not getting any errors. It's not adding anything for me. Are you sure that's the script you're running?
Hello,
Yes. I am sure


$shareList = 'shares.txt' #Enter the path to the share list file
$OutputDirectory = 'C:\NYC\Scripts\NTFS-PermissionsGetAndGrantScripts' #Enter a path if you want to save the CSVs to something besides the working directory.

function Get-FolderOwner{
    Param (
        $rootdir, #Directory that is the base/root of the scan
        $outCSV  #Location to output CSV results
        )


 
    $table = New-Object system.Data.DataTable "OwnerInfo"
    $col1 = New-Object system.Data.DataColumn Path,([string])
    $table.columns.add($col1)
    $col2 = New-Object system.Data.DataColumn Owner,([string])
    $table.columns.add($col2)

   
    #Get all directories in root directory
    $dirs = Get-ChildItem $rootdir -Recurse -Directory

    #Get root directory Owner info
    $rootacl = Get-Acl $rootdir

    $row = $table.NewRow()
    $row.Path = $rootacl.path.Replace('Microsoft.PowerShell.Core\FileSystem::','')
    $row.Owner = $rootacl.Owner
    $table.Rows.Add($row)


    #Get Owner for all subdirectories
    $diracls = $dirs | Get-Acl

    #Loop through permissions
    Foreach($acl in $diracls) {

        $row = $table.NewRow()
        $row.Path = $acl.path.Replace('Microsoft.PowerShell.Core\FileSystem::','')
        $row.Owner = $acl.Owner
        $table.Rows.Add($row)

    }


    #Write results to CSV file
    $table | Export-Csv $outCSV -NoTypeInformation
    #Clean up variables
    Remove-Variable table,dirs,diracls,rootacl,acl,dir

    }

# Get list of directories to scan
Get-Content $shareList | ForEach{
    $shareCSVName = ($_ -split "\\")[-2] +'_'+($_ -split "\\")[-1]+'.csv'
    If($OutputDirectory.Length -gt 0){
        If($OutputDirectory.EndsWith('\')){
            $shareCSVName = $OutputDirectory+$shareCSVName
            }else{
            $shareCSVName = $OutputDirectory+'\'+$shareCSVName
        }
    }    
    Get-FolderOwner -rootdir $_ -outCSV $shareCSVName
}
It is adding "test" to the share.....\\USWESWNE3I60751\InstallsTEST\test
In my input file shares, I have \\USWESWNE3I60751\InstallsTEST\ NOT \\USWESWNE3I60751\InstallsTEST\test





I get error + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVar
   iableCommand

Get-Acl : \\USWESWNE3I60751\InstallsTEST\test
At C:\NYC\Scripts\NTFS-PermissionsGetAndGrantScripts\2GET-NTFSpermissionsvOwnerMultiple
Shares.ps1:32 char:24
+     $diracls = $dirs | Get-Acl
+                        ~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-Acl], DirectoryNotFoundException
    + FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShel
Also,
I didn't put anything for the following : $rootdir variable......Do I need to put anything there?? I thought it suppose to read the shares from shares.txt. I have different shares on different servers that I want to query, For example, \\server01\share1 \\server2\share2


function Get-FolderOwner{
    Param (
        $rootdir, #Directory that is the base/root of the scan
The $rootdir variable is in the function and the directory gets passed to it when it's called. So nothing needs to be defined there.

Do the directory and Output look correct when you run the following script?
$shareList = 'shares.txt' 
$OutputDirectory = 'C:\NYC\Scripts\NTFS-PermissionsGetAndGrantScripts' 
Get-Content $shareList | ForEach{
    $shareCSVName = ($_ -split "\\")[-2] +'_'+($_ -split "\\")[-1]+'.csv'
    If($OutputDirectory.Length -gt 0){
        If($OutputDirectory.EndsWith('\')){
            $shareCSVName = $OutputDirectory+$shareCSVName
            }else{
            $shareCSVName = $OutputDirectory+'\'+$shareCSVName
        }
    }    
    $_ 
    $shareCSVName
}

Open in new window

hm. I tried on different server and still getting this error. The script works partially. I do get outputs but not will all permissions:

Remove-Variable : Cannot find a variable with name 'dir'.
At E:\scripts\ntfs\2GET-NTFSpermissionsvOwnerMultipleShares.ps1:63 char:5
+     Remove-Variable table,dirs,diracls,rootacl,acl,dir
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (dir:String) [Remove-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableCommand

Remove-Variable : Cannot find a variable with name 'dir'.
At E:\scripts\ntfs\2GET-NTFSpermissionsvOwnerMultipleShares.ps1:63 char:5
+     Remove-Variable table,dirs,diracls,rootacl,acl,dir
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (dir:String) [Remove-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableCommand

Remove-Variable : Cannot find a variable with name 'acl'.
At E:\scripts\ntfs\2GET-NTFSpermissionsvOwnerMultipleShares.ps1:63 char:5
+     Remove-Variable table,dirs,diracls,rootacl,acl,dir
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (acl:String) [Remove-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableCommand

Remove-Variable : Cannot find a variable with name 'dir'.
At E:\scripts\ntfs\2GET-NTFSpermissionsvOwnerMultipleShares.ps1:63 char:5
+     Remove-Variable table,dirs,diracls,rootacl,acl,dir
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (dir:String) [Remove-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableCommand
ASKER CERTIFIED SOLUTION
Avatar of Jeremy Weisinger
Jeremy Weisinger

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This works now!!! Thank you so much! I was able to get great reports and save a lot of time with this script.