mirror of
https://github.com/jonbranan/globalscape.git
synced 2024-10-20 13:57:57 -05:00
98 lines
3.8 KiB
PowerShell
98 lines
3.8 KiB
PowerShell
##
|
|
## Copyright (C) 2018 GlobalSCAPE, Inc.
|
|
##
|
|
## The copyright to the computer program(s) herein is the property of
|
|
## GlobalSCAPE, Inc. The program(s) may be used and/or copied only with
|
|
## the written permission of GlobalSCAPE, Inc. or in accordance with the
|
|
## terms and conditions stipulated in the agreement/contract under which
|
|
## the program(s) have been supplied.
|
|
|
|
[CmdletBinding()]
|
|
Param(
|
|
[Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a host name or IP address")]
|
|
[String] $EFTAdminHostname = "localhost",
|
|
|
|
[Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")]
|
|
[int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100,
|
|
|
|
[Parameter(Position = 4, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")]
|
|
[String] $EFTSiteName = "",
|
|
|
|
[Parameter(Position = 5, Mandatory = $False, HelpMessage = "Enter a Authentication Type to connect to EFT Server. 0: EFT Login, 1: Windows Login, 2: Network Logon")]
|
|
[int] [ValidateSet(0, 1, 2)] $EFTAdminAuthType = 1,
|
|
|
|
[Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter login")]
|
|
[String] $EFTAdminUsername,
|
|
|
|
[Parameter(Position = 7, Mandatory = $False, HelpMessage = "Enter password")]
|
|
[String] $Password
|
|
)
|
|
## To Export to CSV use:
|
|
|
|
$script:EftServer = $null
|
|
$script:EftSites = $null
|
|
$script:EftSite = $null
|
|
$MXE_FOLDER_NOT_FOUND = "MX Error: 82 (00000052)"
|
|
$MXE_INVALID_FOLDER_NAME = "MX Error: 97 (00000061)"
|
|
$script:EftServer = new-object -ComObject "SFTPCOMInterface.CIServer"
|
|
|
|
try {
|
|
$script:EftServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password)
|
|
}
|
|
catch [System.Runtime.InteropServices.COMException] {
|
|
Write-Host "Fail to connect to EFT '$($hostname)'. Exception : $($_.Exception.Message)"
|
|
throw
|
|
}
|
|
|
|
$script:EftSites = $script:EftServer.Sites()
|
|
$sitesCount = $script:EftSites.Count()
|
|
|
|
$results = @()
|
|
for ($j = 0; $j -le $sitesCount - 1; $j++ ) {
|
|
$script:EftSite = $script:EftSites.Item($j)
|
|
$SiteName = $script:EftSite.Name
|
|
if ($EFTSiteName -ne "") {
|
|
if ( $EFTSiteName -ne $siteName) {
|
|
continue
|
|
}
|
|
}
|
|
Write-Progress -Activity "Processing Sites" -status "Site '$SiteName' $j/$sitesCount" -percentComplete ($j / $sitesCount * 100)
|
|
$i = 0
|
|
# Retrieve all the paths that have permissions in the config and decorate the orphans with a *
|
|
$folders = $script:EftSite.GetPermPathsList("-do")
|
|
$folderList = $folders.Split([string[]]"`r`n", "RemoveEmptyEntries")
|
|
|
|
Foreach ($folder in $folderList) {
|
|
Write-Progress -Activity "Processing Folders" -status "Folder $folder ($i/$($folderList.length))" -percentComplete ($i / $folderList.length * 100)
|
|
$i++
|
|
# check if folder paths ends with * (orphans) and ignore
|
|
if ($folder[-1] -ne "*") {
|
|
continue
|
|
}
|
|
$folder = $folder.Substring(0,$folder.Length-1)
|
|
try {
|
|
$physicalPath = $script:EftSite.GetPhysicalPath($folder)
|
|
}
|
|
catch [System.Runtime.InteropServices.COMException] {
|
|
switch ($_) {
|
|
$MXE_FOLDER_NOT_FOUND { $physicalPath = "**MXE_FOLDER_NOT_FOUND** : $_ " }
|
|
$MXE_INVALID_FOLDER_NAME { $physicalPath = "**MXE_INVALID_FOLDER_NAME** : $_ "}
|
|
Default { $physicalPath = "**Exception** : $_"}
|
|
}
|
|
$errorCount++
|
|
}
|
|
$results += new-object PSObject -Property @{
|
|
SiteName = $script:EftSite.Name;
|
|
Path = $folder;
|
|
PhysicalPath = $physicalPath;
|
|
}
|
|
}
|
|
|
|
}
|
|
$results | Sort-Object SiteName, Path, Client
|
|
|
|
$script:EftServer.close()
|
|
|
|
$script:EftSite = $null
|
|
$script:EftSites = $null
|
|
$script:EftServer = $null |