diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/.vscode/launch.json b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/.vscode/launch.json deleted file mode 100644 index fb89c00..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/.vscode/launch.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - - { - "type": "PowerShell", - "request": "launch", - "name": "PowerShell Launch Current File", - "script": "${file}", - "args": [], - "cwd": "${file}" - }, - { - "type": "PowerShell", - "request": "launch", - "name": "PowerShell Launch Current File in Temporary Console", - "script": "${file}", - "args": [], - "cwd": "${file}", - "createTemporaryIntegratedConsole": true - }, - { - "type": "PowerShell", - "request": "launch", - "name": "PowerShell Launch Current File w/Args Prompt", - "script": "${file}", - "args": [ - "${command:SpecifyScriptArgs}" - ], - "cwd": "${file}" - }, - { - "type": "PowerShell", - "request": "attach", - "name": "PowerShell Attach to Host Process", - "processId": "${command:PickPSHostProcess}", - "runspaceId": 1 - }, - { - "type": "PowerShell", - "request": "launch", - "name": "PowerShell Interactive Session", - "cwd": "${workspaceRoot}" - } - ] -} \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Build and Deploy EFT Automation.docx b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Build and Deploy EFT Automation.docx deleted file mode 100644 index d446b0f..0000000 Binary files a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Build and Deploy EFT Automation.docx and /dev/null differ diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT Change EFT Site Storage.docx b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT Change EFT Site Storage.docx deleted file mode 100644 index c2e7a59..0000000 Binary files a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT Change EFT Site Storage.docx and /dev/null differ diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.AdvanceStats.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.AdvanceStats.ps1 deleted file mode 100644 index 4d497c0..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.AdvanceStats.ps1 +++ /dev/null @@ -1,290 +0,0 @@ -## -## 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 = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False, HelpMessage = "Validate Folder Monitor Paths")] - [switch] $ValidatePath -) -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - -$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) - - $EventType = $script:EftServer.AvailableEvents - foreach ($eventtype in $EventType) { - Write-Progress -Activity "Processing Event Rules" -status "$($eventType.type)" -percentComplete -1 - Try { - $eRules = $script:eftsite.EventRules($eventType.type) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "COM Exception : $error[0]" -ForegroundColor Magenta - } - If ($erules) { - If ($eRules.Count() -gt 0) { - For ($iRule = 0; $iRule -lt $eRules.Count(); $iRule++) { - Write-Progress -Activity "Processing Event Rules" -status "Event Rule $iRule/$($eRules.Count())" -percentComplete ($iRule / $eRules.Count() * 100) - $objEvent = $eRules.Item($iRule) - - $objParams = $objEvent.GetParams() - $FM_Path = "" - $FM_CheckHealthInterval = "" - $FM_CheckHealth = "" - $FM_IncludeSubfolders = "" - $FM_UseAlternateCredentials = "" - $FM_UserName = "" - $FM_Password = "" - $FM_UseFileSystemNotifications = "" - $FM_UsePeriodicDirectoryPoll = "" - $FM_PollIntervalSeconds = "" - $FM_ArchiveSubFolderName = "" - $FM_UseInteractiveLogon = "" - $FM_ArchiveLeftovers = "" - $FM_AddTimestampToArchivedFileNames = "" - $FM_PollIntervalType = "" - $FM_PollInterval = "" - - $HA_SchedulingParams = "" - $HA_SchedulingBackupParams = "" - - $SCH_DailyEveryWeekDay = "" - $SCH_DailyDayPeriod = "" - $SCH_WeeklyWeekPeriod = "" - $SCH_WeeklySunday = "" - $SCH_WeeklyMonday = "" - $SCH_WeeklyTuesday = "" - $SCH_WeeklyWednesday = "" - $SCH_WeeklyThursday = "" - $SCH_WeeklyFriday = "" - $SCH_WeeklySaturday = "" - $SCH_MonthlyFixedDay = "" - $SCH_MonthlyDayPeriod = "" - $SCH_MonthlyMonthPeriod = "" - $SCH_MonthlyRelativeWeekday = "" - $SCH_MonthlyWeekday = "" - $SCH_YearlyFixedDay = "" - $SCH_YearlyMonth = "" - $SCH_YearlyDayPeriod = "" - $SCH_YearlyRelativeWeekday = "" - $SCH_YearlyWeekday = "" - $SCH_RepeatPattern = "" - $SCH_RepeatRate = "" - $SCH_RepeatEnabled = "" - $SCH_DateTimeEnd = "" - $SCH_TimeEndEnabled = "" - $SCH_DateEndEnabled = "" - $SCH_RundayCalendar = "" - $SCH_HolidayCalendar = "" - $SCH_NextRun = "" - $SCH_Recurrence = "" - $SCH_DateTimeStart = "" - $Validpath = "" - if ($eventType.Name -eq "Folder Monitor") { - - $FM_Path = $objParams.Path - if ($ValidatePath) { - try { - if (Test-Path $FM_Path) { - $Validpath = "OK" - } - else { - $Validpath = "FOLDER_NOT_FOUND" - } - } - catch { - $Validpath = "ERROR: $_" - } - } - try {$FM_CheckHealthInterval = $objParams.CheckHealthInterval} catch {} - try {$FM_CheckHealth = $objParams.CheckHealth} catch {} - try {$FM_IncludeSubfolders = $objParams.IncludeSubfolders} catch {} - try {$FM_UseAlternateCredentials = $objParams.UseAlternateCredentials} catch {} - try {$FM_UserName = $objParams.UserName} catch {} - try {$FM_Password = $objParams.Password} catch {} - try {$FM_UseFileSystemNotifications = $objParams.UseFileSystemNotifications} catch {} - try {$FM_UsePeriodicDirectoryPoll = $objParams.UsePeriodicDirectoryPoll} catch {} - try {$FM_PollIntervalSeconds = $objParams.PollIntervalSeconds } catch {} - try {$FM_ArchiveSubFolderName = $objParams.ArchiveSubFolderName } catch {} - try {$FM_UseInteractiveLogon = $objParams.UseInteractiveLogon } catch {} - try {$FM_ArchiveLeftovers = $objParams.ArchiveLeftovers} catch {} - try {$FM_AddTimestampToArchivedFileNames = $objParams.AddTimestampToArchivedFileNames} catch {} - try {$FM_PollIntervalType = $objParams.PollIntervalType } catch {} - try {$FM_PollInterval = $objParams.PollInterval } catch {} - } - if ($eventType.Name -eq "Scheduler (Timer) Event") { - try {$SCH_DailyEveryWeekDay = $objParams.DailyEveryWeekDay} catch {} - try {$SCH_DailyDayPeriod = $objParams.DailyDayPeriod} catch {} - try {$SCH_WeeklyWeekPeriod = $objParams.WeeklyWeekPeriod} catch {} - try {$SCH_WeeklySunday = $objParams.WeeklySunday} catch {} - try {$SCH_WeeklyMonday = $objParams.WeeklyMonday} catch {} - try {$SCH_WeeklyTuesday = $objParams.WeeklyTuesday} catch {} - try {$SCH_WeeklyWednesday = $objParams.WeeklyWednesday} catch {} - try {$SCH_WeeklyThursday = $objParams.WeeklyThursday} catch {} - try {$SCH_WeeklyFriday = $objParams.WeeklyFriday } catch {} - try {$SCH_WeeklySaturday = $objParams.WeeklySaturday } catch {} - try {$SCH_MonthlyFixedDay = $objParams.MonthlyFixedDay } catch {} - try {$SCH_MonthlyDayPeriod = $objParams.MonthlyDayPeriod} catch {} - try {$SCH_MonthlyMonthPeriod = $objParams.MonthlyMonthPeriod} catch {} - try {$SCH_MonthlyRelativeWeekday = $objParams.MonthlyRelativeWeekday } catch {} - try {$SCH_MonthlyWeekday = $objParams.MonthlyWeekday } catch {} - try {$SCH_YearlyFixedDay = $objParams.YearlyFixedDay } catch {} - try {$SCH_YearlyMonth = $objParams.YearlyMonth } catch {} - try {$SCH_YearlyDayPeriod = $objParams.YearlyDayPeriod } catch {} - try {$SCH_YearlyRelativeWeekday = $objParams.YearlyRelativeWeekday } catch {} - try {$SCH_YearlyWeekday = $objParams.YearlyWeekday } catch {} - try {$SCH_RepeatPattern = $objParams.RepeatPattern } catch {} - try {$SCH_RepeatRate = $objParams.RepeatRate } catch {} - try {$SCH_RepeatEnabled = $objParams.RepeatEnabled } catch {} - try {$SCH_DateTimeEnd = $objParams.DateTimeEnd } catch {} - try {$SCH_TimeEndEnabled = $objParams.TimeEndEnabled } catch {} - try {$SCH_DateEndEnabled = $objParams.DateEndEnabled } catch {} - try {$SCH_RundayCalendar = $objParams.RundayCalendar } catch {} - try {$SCH_HolidayCalendar = $objParams.HolidayCalendar } catch {} - try {$SCH_NextRun = $objParams.NextRun } catch {} - try {$SCH_Recurrence = $objParams.Recurrence } catch {} - try {$SCH_DateTimeStart = $objParams.DateTimeStart } catch {} - } - if($script:EftServer.HAEnabled){ - $EFTHAParams = $objEvent.GetHASchedulingParams() - $EFTHABackupParams = $objEvent.GetHABackupSchedulingParams() - for ($i=0;$i -lt $EFTHAParams.Count();$i++){ - $HA_SchedulingParams += "$($EFTHAParams.Item($i))," - } - for ($i=0;$i -lt $EFTHABackupParams.Count();$i++){ - $HA_SchedulingBackupParams += "$($EFTHABackupParams.Item($i))," - } - } - - $results += new-object psobject -Property @{ - SiteName = $siteName; - EventRuleName = $objParams.name; - Trigger = $eventType.Name; - Enabled = $objParams.Enabled; - Validpath = $Validpath - - FM_Path = $FM_Path; - FM_CheckHealthInterval = $FM_CheckHealthInterval; - FM_CheckHealth = $FM_CheckHealth; - FM_IncludeSubfolders = $FM_IncludeSubfolders; - FM_UseAlternateCredentials = $FM_UseAlternateCredentials; - FM_UserName = $FM_UserName; - FM_Password = $FM_Password; - FM_UseFileSystemNotifications = $FM_UseFileSystemNotifications; - FM_UsePeriodicDirectoryPoll = $FM_UsePeriodicDirectoryPoll; - FM_PollIntervalSeconds = $FM_PollIntervalSeconds; - FM_ArchiveSubFolderName = $FM_ArchiveSubFolderName; - FM_UseInteractiveLogon = $FM_UseInteractiveLogon; - FM_ArchiveLeftovers = $FM_ArchiveLeftovers; - FM_AddTimestampToArchivedFileNames = $FM_AddTimestampToArchivedFileNames; - FM_PollIntervalType = $FM_PollIntervalType; - FM_PollInterval = $FM_PollInterval; - - SCH_DailyEveryWeekDay = $SCH_DailyEveryWeekDay - SCH_DailyDayPeriod = $SCH_DailyDayPeriod - SCH_WeeklyWeekPeriod = $SCH_WeeklyWeekPeriod - SCH_WeeklySunday = $SCH_WeeklySunday - SCH_WeeklyMonday = $SCH_WeeklyMonday - SCH_WeeklyTuesday = $SCH_WeeklyTuesday - SCH_WeeklyWednesday = $SCH_WeeklyWednesday - SCH_WeeklyThursday = $SCH_WeeklyThursday - SCH_WeeklyFriday = $SCH_WeeklyFriday - SCH_WeeklySaturday = $SCH_WeeklySaturday - SCH_MonthlyFixedDay = $SCH_MonthlyFixedDay - SCH_MonthlyDayPeriod = $SCH_MonthlyDayPeriod - SCH_MonthlyMonthPeriod = $SCH_MonthlyMonthPeriod - SCH_MonthlyRelativeWeekday = $SCH_MonthlyRelativeWeekday - SCH_MonthlyWeekday = $SCH_MonthlyWeekday - SCH_YearlyFixedDay = $SCH_YearlyFixedDay - SCH_YearlyMonth = $SCH_YearlyMonth - SCH_YearlyDayPeriod = $SCH_YearlyDayPeriod - SCH_YearlyRelativeWeekday = $SCH_YearlyRelativeWeekday - SCH_YearlyWeekday = $SCH_YearlyWeekday - SCH_RepeatPattern = $SCH_RepeatPattern - SCH_RepeatRate = $SCH_RepeatRate - SCH_RepeatEnabled = $SCH_RepeatEnabled - SCH_DateTimeEnd = $SCH_DateTimeEnd - SCH_TimeEndEnabled = $SCH_TimeEndEnabled - SCH_DateEndEnabled = $SCH_DateEndEnabled - SCH_RundayCalendar = $SCH_RundayCalendar - SCH_HolidayCalendar = $SCH_HolidayCalendar - SCH_NextRun = $SCH_NextRun - SCH_Recurrence = $SCH_Recurrence - SCH_DateTimeStart = $SCH_DateTimeStart - - HA_SchedulingParams = $HA_SchedulingParams; - HA_SchedulingBackupParams = $HA_SchedulingBackupParams; - - CheckSum = ""; - } - } - } - } - } -} -try { - for ($i = 0 ; $i -le $results.count - 1; $i++) { - $u = $results[$i] - #Concatenate all columns except the mentioned in the ExcludedProperty - $Hash = -join ( $u | Select-Object * -ExcludeProperty SiteName, SCH_NextRun, Validpath, CheckSum) - $Hash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($Hash))) | Select-Object -ExpandProperty Hash - $results[$i].CheckSum = $Hash - } -} -catch { - $results[$i].CheckSum = "NA" -} - -$script:EftServer.close() - -$results | Sort-Object SiteName, Trigger, EventRuleName - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Build.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Build.ps1 deleted file mode 100644 index c9e490e..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Build.ps1 +++ /dev/null @@ -1,535 +0,0 @@ -## -## 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. -### -# cd C:\Users\rguzman\Desktop\src\src -# . .\deploy.ps1 -EFTHostname localhost -EFTSiteName Rogers -EFTAdmin admin -password Super2017!! -# TEST TEST TEST111 -### - -[CmdletBinding()] -Param( - [Parameter(Position = 0, Mandatory = $False, HelpMessage = "Enter the output folder where files will be created")] - [String] $BuildFolder = "", - - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False )] - [switch]$Quiet = $false -) -Function RemoveInvalidChars($path) { - $path -replace ("[{0}]" -f (([System.IO.Path]::GetInvalidFileNameChars()| ForEach-Object {[regex]::Escape($_)}) -join '|')), '_' - #return $path -} - -Write-host "******* EFT Build SCRIPT 1.0 *************************************************" -ForegroundColor Yellow -if ($Quiet -eq $false) { - Write-host " > This script will perform read-only operations your EFT configuration " -ForegroundColor Yellow - Write-host " > It is recommend you test this script in a non-production environment before " -ForegroundColor Yellow - Write-host " using in production to validate its functionality" -ForegroundColor Yellow - Write-host "******************************************************************************" -ForegroundColor Yellow -} -$CurrentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name -if ($EFTAdminAuthType -eq 1) { - $EFTAdminUsername = $CurrentUserName -} -$EftService = Get-Service "EFT *" -$adminPrivileges = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' -if ($BuildFolder -eq "") { - $transactionId = [guid]::NewGuid() -Replace "-", "" - $transactionId = $transactionId.Substring(0, 8) - $OutputFolder = "build-$transactionId" -} -else { - $OutputFolder = $BuildFolder -} -#Output parameters -Write-Host "Current datetime : $(Get-Date -f $df)" -Write-Host "Current User : $CurrentUserName" -Write-Host "Admin Privileges : $adminPrivileges" -Write-host "EFT Server Service : " -NoNewline -$OriginalEFTServiceState = $EftService.Status -if ($EftService.Status -eq "Running") {Write-host "$($OriginalEFTServiceState)" -ForegroundColor Green} else {Write-host "$($OriginalEFTServiceState)" -ForegroundColor Red} -Write-host "BuildName : $OutputFolder" -Write-host "EFT Admin Hostname : $EFTAdminHostname" -Write-host "EFT Admin Port : $EFTAdminPort" -Write-host "EFT Site Name : $EFTSiteName" -Write-host "EFT Admin Auth Type : $EFTAdminAuthType" -Write-host "EFT Admin Username : $EFTAdminUsername" -#$here = (Split-Path -Parent $MyInvocation.MyCommand.Path) - -if ($Quiet -eq $false) { - $continue = Read-Host -Prompt "Have you read and understand the notes (y/n)?" - if ($continue.ToUpper() -ne "Y") { - exit - } -} -# Constants -$MAX_PAD = 100 -$PAD_CHR = "." -$EFTServer = $null -$EFTSites = $null -$EFTSite = $null - -$MXE_AW_INVALID_TASK_NAME = "MX Error: 71 (00000047)" -$MXE_EVENT_AW_TASK_DOES_NOT_EXIST = "MX Error: 106 (0000006A)" -$MXE_CANNOT_EXPORT_EVENT_RULE = "MX Error: 120 (00000078)" - -# Validations -if ($OutputFolder -notmatch '.+?\\$') { - $OutputFolder += '\' -} - -If ( (Test-Path $OutputFolder) -eq $false) { - Write-Verbose "Creating $OutputFolder" - new-item $OutputFolder -ItemType directory | Out-Null -} - -$OutputFolder = Convert-Path $OutputFolder - -$EFTServer = new-object -ComObject "SFTPCOMInterface.CIServer" - -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() - -for ($j = 0; $j -le $sitesCount - 1; $j++ ) { - - $script:EftSite = $script:EftSites.Item($j) - $SiteGuid = $null - $siteName = $script:EftSite.Name - try { - $SiteGuid = $script:EftSite.GUID - } - catch [System.Runtime.InteropServices.COMException] { - Write-Verbose "Can't get GUID for Site $siteName" - } - - if ($EFTSiteName -ne "") { - if ( $EFTSiteName -ne $siteName) { - continue - } - } - - Write-host " " - Write-host " $siteName [$SiteGuid]".PadRight(65, "*").Padleft(100, "*") - - $commandBasePath = "$OutputFolder$($siteName)\commands\" - If ( (Test-Path $commandBasePath) -eq $false) { - Write-Verbose "Creating $commandBasePath" - new-item $commandBasePath -ItemType directory | Out-Null - } - Write-host "[Custom Commands]" - write-host " Path: $commandBasePath " - - $exportCount = 0 - $errorCount = 0 - $customcommandslist = $eftsite.GetCommands() - - If ($customcommandslist) { - foreach ($customCommand in $customcommandslist) { - try { - $sw.Restart() - $customCommandSettings = $eftsite.GetCommandSettings($customCommand) - $exportedfilename = RemoveInvalidChars $customCommandSettings.Name - $exportedfilename = $exportedfilename + ".xml" - - Write-host "Exporting: $customCommand".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - Export-Clixml -path "$commandBasePath\$exportedfilename" -inputObject $customCommandSettings -depth 4 -Encoding UTF8 - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - $exportCount++ - } - catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Magenta - Write-Host "COM Exception : $error[0]" -ForegroundColor Red - $errorCount++ - continue - } - } - } - - Write-host " Exported: " -NoNewline - Write-host "$exportCount " -NoNewline -ForegroundColor green - Write-host "Errors: "-NoNewline - Write-host "$errorCount " -ForegroundColor red - Write-host " " - - - $commandBasePath = "$OutputFolder$($siteName)\commands_userpermissions\" - If ( (Test-Path $commandBasePath) -eq $false) { - Write-Verbose "Creating $commandBasePath" - new-item $commandBasePath -ItemType directory | Out-Null - } - Write-host "[Custom Commands Users Permissions]" - write-host " Path: $commandBasePath " - - $exportCount = 0 - $errorCount = 0 - $customcommandslist = $eftsite.GetCommands() - - If ($customcommandslist) { - foreach ($customCommand in $customcommandslist) { - try { - $sw.Restart() - $customCommandSettings = $eftsite.GetCommandSettings($customCommand) - $exportedfilename = RemoveInvalidChars $customCommandSettings.Name - $exportedfilename = $exportedfilename + ".xml" - - $userPermissions = $customCommandSettings.GetUserPermissions() - Write-host "Exporting: $customCommand".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - Export-Clixml -path "$commandBasePath\$exportedfilename" -inputObject $userPermissions -depth 4 -Encoding UTF8 - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - $exportCount++ - } - catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Magenta - Write-Host "COM Exception : $error[0]" -ForegroundColor Red - $errorCount++ - continue - } - } - } - - Write-host " Exported: " -NoNewline - Write-host "$exportCount " -NoNewline -ForegroundColor green - Write-host "Errors: "-NoNewline - Write-host "$errorCount " -ForegroundColor red - Write-host " " - - $AMLbasePath = "$OutputFolder$($siteName)\workflows\" - If ( (Test-Path $AMLbasePath) -eq $false) { - Write-Verbose "Creating $AMLbasePath" - new-item $AMLbasePath -ItemType directory | Out-Null - } - $taskCount = $EFTSite.AdvancedWorkflowsCount - Write-host "[Advanced Workflows]" - Write-host " Path: $AMLbasePath" - - $exportCount = 0 - $errorCount = 0 - If ($taskcount -gt 0) { - For ($iTask = 0; $iTask -lt $taskCount; $iTask++) { - try { - $sw.Restart() - $objTask = $eftsite.GetAdvancedWorkflowParams($itask) - $task = $objTask.Name - $SafeTaskName = RemoveInvalidChars $task - $exportedfilename = "$SafeTaskName.xml" - - Write-host "Exporting: $task ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - Export-Clixml -path "$AMLbasePath\$exportedfilename" -inputObject $objTask -depth 4 -Encoding UTF8 - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - $exportCount++ - } - catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Magenta - switch ($_) { - $MXE_AW_INVALID_TASK_NAME { Write-host "MXE_AW_INVALID_TASK_NAME : $_ " -ForegroundColor Red } - $MXE_EVENT_AW_TASK_DOES_NOT_EXIST { Write-host "MXE_EVENT_AW_TASK_DOES_NOT_EXIST : $_ " -ForegroundColor Red } - Default {Write-Host "COM Exception : $error[0]" -ForegroundColor Red} - } - $errorCount++ - continue - } - # Write-Host "current Task: " $objTask.Name - } - } - Write-host " Exported: " -NoNewline - Write-host "$exportCount " -NoNewline -ForegroundColor green - Write-host "Errors: "-NoNewline - Write-host "$errorCount " -ForegroundColor red - Write-host " " - - $basePath = Join-Path "$OutputFolder" "$($siteName)\as2_profiles\" - If ( (Test-Path $basePath) -eq $false) { - Write-Verbose "Creating $basePath" - new-item $basePath -ItemType directory | Out-Null - } - - $totalUsers = -1 - $users = $script:EftSite.GetUsers() - $totalUsers = $users.length - - if ($totalUsers -gt -1 ) { - Write-host "[AS2 Profiles] " - Write-host " Path: $basePath" - } - $exportCount = 0 - $errorCount = 0 - - for ($i = 0; $i -lt $users.length; $i++ ) { - try { - $sw.Restart() - $username = $users[$i] - $detail = $script:EftSite.GetUserSettings($users[$i]) - - $AS2InboundProfile = $detail.AS2InboundSettings - $AS2OutboundProfile = $detail.AS2OutboundSettings - - if ($null -eq $AS2InboundProfile -and $null -eq $AS2OutboundProfile) { - continue - } - Write-host "Exporting: $username ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - # Create username folder - $userPath = Join-Path "$basePath" "$username" - If ( (Test-Path $userPath) -eq $false) { - new-item $userPath -ItemType directory | Out-Null - } - - if ($null -ne $AS2InboundProfile) { - Export-Clixml -path "$userPath\AS2Inbound.xml" -inputObject $AS2InboundProfile -depth 4 -Encoding UTF8 - - $successEmail = $AS2InboundProfile.GetSuccessEmail() - if ($null -ne $successEmail) { - Export-Clixml -path "$userPath\AS2Inbound_SuccessEmail.xml" -inputObject $successEmail -depth 4 -Encoding UTF8 - } - - $FailureEmail = $AS2InboundProfile.GetFailureEmail() - if ($null -ne $FailureEmail) { - Export-Clixml -path "$userPath\AS2Inbound_FailureEmail.xml" -inputObject $FailureEmail -depth 4 -Encoding UTF8 - } - - $SuccessCommand = $AS2InboundProfile.GetSuccessCommand() - if ($null -ne $SuccessCommand) { - Export-Clixml -path "$userPath\AS2Inbound_SuccessCommand.xml" -inputObject $SuccessCommand -depth 4 -Encoding UTF8 - } - $FailureCommand = $AS2InboundProfile.GetFailureCommand() - if ($null -ne $FailureCommand) { - Export-Clixml -path "$userPath\AS2Inbound_FailureCommand.xml" -inputObject $FailureCommand -depth 4 -Encoding UTF8 - } - } - - if ($null -ne $AS2OutboundProfile) { - Export-Clixml -path "$userPath\AS2Outbound.xml" -inputObject $AS2OutboundProfile -depth 4 -Encoding UTF8 - - $successEmail = $AS2OutboundProfile.GetSuccessEmail() - if ($null -ne $successEmail) { - Export-Clixml -path "$userPath\AS2Outbound_SuccessEmail.xml" -inputObject $successEmail -depth 4 -Encoding UTF8 - } - - $FailureEmail = $AS2OutboundProfile.GetFailureEmail() - if ($null -ne $FailureEmail) { - Export-Clixml -path "$userPath\AS2Outbound_FailureEmail.xml" -inputObject $FailureEmail -depth 4 -Encoding UTF8 - } - - $SuccessCommand = $AS2OutboundProfile.GetSuccessCommand() - if ($null -ne $SuccessCommand) { - Export-Clixml -path "$userPath\AS2Outbound_SuccessCommand.xml" -inputObject $SuccessCommand -depth 4 -Encoding UTF8 - } - - $FailureCommand = $AS2OutboundProfile.GetFailureCommand() - if ($null -ne $FailureCommand) { - Export-Clixml -path "$userPath\AS2Outbound_FailureCommand.xml" -inputObject $FailureCommand -depth 4 -Encoding UTF8 - } - } - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - $exportCount++ - } - catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Magenta - Write-Host "COM Exception : $error[0]" -ForegroundColor Red - $errorCount++ - continue - } - - } - $basePath = Join-Path "$OutputFolder" "$($siteName)\connection_profiles\" - If ( (Test-Path $basePath) -eq $false) { - Write-Verbose "Creating $basePath" - new-item $basePath -ItemType directory | Out-Null - } - - $totalProfiles = -1 - try { - $totalProfiles = $script:eftsite.GetConnectionProfilesCount() - } - catch { - $totalProfiles = -1 - } - if ($totalProfiles -ne -1) { - Write-host "[Connection Profiles] " - Write-host " Path: $basePath" - } - $exportCount = 0 - $errorCount = 0 - - For ($iprofile = 0; $iprofile -lt $totalProfiles; $iprofile++) { - try { - $sw.Restart() - $objTask = $script:eftsite.GetConnectionProfileParams($iprofile) - $task = $objTask.Name - $SafeTaskName = RemoveInvalidChars $task - $exportedfilename = "$SafeTaskName.xml" - Write-host "Exporting: $task ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - Export-Clixml -path "$basePath\$exportedfilename" -inputObject $objTask -depth 4 -Encoding UTF8 - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - $exportCount++ - } - catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Magenta - Write-Host "COM Exception : $error[0]" -ForegroundColor Red - $errorCount++ - continue - } - } - - if ($totalProfiles -ne -1) { - Write-host " Exported: " -NoNewline - Write-host "$exportCount " -NoNewline -ForegroundColor green - Write-host "Errors: "-NoNewline - Write-host "$errorCount " -ForegroundColor red - Write-host " " - } - - $eventRulesbasePath = Join-Path "$OutputFolder" "$($siteName)\event_rules\" - If ( (Test-Path $eventRulesbasePath) -eq $false) { - Write-Verbose "Creating $eventRulesbasePath" - new-item $eventRulesbasePath -ItemType directory | Out-Null - } - - $EventType = $script:EftServer.AvailableEvents - - Write-host "[Event Rules] " - Write-host " Path: $eventRulesbasePath" - - $exportCount = 0 - $errorCount = 0 - - - $EventFolders = $null - $EFTUsingFolders = $false - try { - $EventFolders = $EFTsite.EventRuleFolders() - $EFTUsingFolders = $true - # Creating event rules folders as file directories - for ($i = 0 ; $i -le $EventFolders.Count() - 1 ; $i++) { - $eventFolder = $EventFolders.Item($i) - $eventFolderPath = Join-Path $eventRulesbasePath $eventFolder.Name - If ( (Test-Path $eventFolderPath) -eq $false) { - new-item $eventFolderPath -ItemType directory | Out-Null - } - } - } - catch { - Write-verbose "Event Rule folders feature not found via COM" - } - - foreach ($eventtype in $EventType) { - try { - $eRules = $script:eftsite.EventRules($eventType.type) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "COM Exception : $error[0]" -ForegroundColor Magenta - $errorCount++ - continue - } - - If ($erules -and $eRules.Count() -gt 0) { - For ($iRule = 0; $iRule -lt $eRules.Count(); $iRule++) { - try { - $sw.Restart() - #$exported = $false - $objEvent = $eRules.Item($iRule) - $objParams = $objEvent.GetParams() - - $rulename = $objParams.name - $exportedfilename = RemoveInvalidChars $objParams.name - $exportedfilename = $exportedfilename + ".xml" - $eventRulesPath = $eventRulesbasePath - Write-host "Exporting: $rulename ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - # Write-Verbose "$eventRulesbasePath$exportedfilename" - - if ($EFTUsingFolders) { - for ($i = 0 ; $i -le $EventFolders.Count() - 1 ; $i++) { - $EventFolder = $EventFolders.Item($i) - if ($EventFolder.Find($rulename)) { - $eventRulesPath = Join-Path $eventRulesPath $EventFolder.Name - break - } - } - } - $eventRulesPath = Join-Path $eventRulesPath $exportedfilename - Write-Verbose "$eventRulesPath" - $objEvent.Export("$eventRulesPath") - - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - $exportCount++ - } - catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Magenta - switch ($_) { - $MXE_CANNOT_EXPORT_EVENT_RULE { Write-host "MXE_CANNOT_EXPORT_EVENT_RULE : $_ " -ForegroundColor Red } - Default {Write-Host "COM Exception : $error[0]" -ForegroundColor Red} - } - $errorCount++ - continue - } - } - } - - } - - - - - Write-host " Exported: " -NoNewline - Write-host "$exportCount " -NoNewline -ForegroundColor green - Write-host "Errors: "-NoNewline - Write-host "$errorCount " -ForegroundColor red - Write-host " " - - -} - - -$EFTSite = $null -$EFTSites = $null -$EFTServer.Close() -$EFTServer = $null - -# Dev machine -# git clone -# EFT.export -> File System XML -# Edit files (Change, Edit, etc) -# Update parameters -# git -m "Commit" -# git push/Sync - - -# Prod machine -# git clone -#EFT.Deploy -clean -force -ParametersCsv ProductionParams.csv \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.CLI.md b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.CLI.md deleted file mode 100644 index aaf6a84..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.CLI.md +++ /dev/null @@ -1,32 +0,0 @@ -Use Powershell (x86) console - -## Examples - -Loading the CLI script - -``` powershell -. .\EFT.CLI.ps1 -``` - - -Example on how to remove event rules with an exact name -``` powershell -Connect-EFT -Set-Site MySite -Get-EventRules | where {$_.Name -eq 'On File Downloaded Rule imported 1'} | ForEach-Object { Remove-eventrule -Name $_.Name } -``` - -Example on how to remove event rules that event rule name has 'imported' on the name - -``` powershell -Connect-EFT -Set-Site MySite -Get-EventRules | where {$_.Name -like '*imported*'} | ForEach-Object { Remove-eventrule -Name $_.Name } -``` - -Example shows how to remove advanced Worflows with the 'asd' in the workflow name -``` powershell -Connect-EFT -Set-Site MySite -Get-AdvancedWorkflows | where {$_.Name -like '*asd*'} | ForEach-Object { Remove-AdvancedWorkflow -Name $_.Name } -``` \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.CLI.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.CLI.ps1 deleted file mode 100644 index 745f0f1..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.CLI.ps1 +++ /dev/null @@ -1,674 +0,0 @@ -## -## 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() -$global:Server = $null -$global:sites = $null -$global:site = $null -$global:user = $null -$global:event = $null -$global:version = 2.0 -function Get-EFT-CLI-Version() { - Write-Host $global:version -} - -##################################################################### -## Server -##################################################################### -<# - .SYNOPSIS - Connects to an EFT Server - .EXAMPLE - Connect-EFT localhost 1100 admin admin - This commands will connect to an EFT server listening in localhost using port 1100 and using - admin/admin as username/password. -#> -function Connect-EFT( - [Parameter(Position = 0, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $Hostname = "localhost", - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] $Port = 1100, - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a Authentication Type to connect to EFT Server. 0: EFT Login, 1: Windows Login, 2: Network Logon")] - [int] $AuthType = 1, - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter login")] - [String] $Login, - [Parameter(Position = 4, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password -) { - Write-Verbose "hostname :$hostname" - Write-Verbose "port :$port" - Write-Verbose "Login :$login" - Write-Verbose "len(Password) :$password.length" - Write-Verbose "SiteName :$siteName" - $global:Server = new-object -ComObject "SFTPCOMInterface.CIServer" - try { - $global:Server.ConnectEx($hostname, $port, $AuthType, $login, $password) - $global:sites = $global:server.Sites() - Write-Host "You are now connected !!" -ForegroundColor Green - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "Exception : $error[0]" -ForegroundColor Red - Write-Host "You are NOT connected !!" -ForegroundColor Red - } -} - -function Disconnect-EFT() { - <# - .SYNOPSIS - Disconnect the connection to EFT Server - .EXAMPLE - Disconnect-EFT - This commands will disconnect from an EFT server. -#> - if ($null -ne $global:site) { - [System.Runtime.Interopservices.Marshal]::ReleaseComObject($global:site) - $global:site = $null - } - if ($null -ne $global:sites) { - [System.Runtime.Interopservices.Marshal]::ReleaseComObject($global:sites) - $global:sites = $null - } - if ($null -ne $global:Server) { - $global:Server.Close() - [System.Runtime.Interopservices.Marshal]::ReleaseComObject($global:Server) - $global:sites = $null - } -} - -function Get-EFT-ConnectionStatus() { - if ($null -eq $global:Server) { - Write-Host "Disconnected" -ForegroundColor Red - } - else { - Write-Host "Connected" -ForegroundColor Green - } -} -##################################################################### -## Sites -##################################################################### -function Get-Sites() { - if ($null -eq $global:Server) { - Write-Host "You need to connect to EFT Server first" -ForegroundColor Red - } - else { - $results = @() - for ($i = 0; $i -le $global:sites.Count() - 1; $i++ ) { - $site = $global:sites.Item($i) - $row = New-Object PSObject - $row | Add-Member -type NoteProperty -name SiteName -Value $site.Name - $row | Add-Member -type NoteProperty -name IsRunning -Value $site.IsStarted - $row | Add-Member -type NoteProperty -name "Active Sessions" -Value $site.GetConnectedCount() - $row | Add-Member -type NoteProperty -name UsersDefined -Value $site.UsersDefined - $row | Add-Member -type NoteProperty -name "WTC Sessions Active" -Value $site.WTCSessionsActive - $row | Add-Member -type NoteProperty -name "WTC Sessions Remaining" -Value $site.WTCSessionsActive - $row | Add-Member -type NoteProperty -name "Active Uploads" -Value $site.GetUploadCount() - $row | Add-Member -type NoteProperty -name "Active Downloads" -Value $site.GetDownloadCount() - $results += $row - } - return $results - } -} -function Set-Site( - [Parameter(Position = 0, Mandatory = $True, HelpMessage = "Enter a site name")] - [String]$siteName) { - Write-Verbose "SiteName :$siteName" - if ($null -eq $global:Server) { - Write-Host "You need to connect to EFT Server first" -ForegroundColor Red - } - else { - for ($i = 0; $i -le $global:sites.Count() - 1; $i++ ) { - $global:site = $global:sites.Item($i) - if ($global:site.Name -eq $siteName) { - Write-Host "Site '$siteName' selected" -ForegroundColor Green - return $siteName - } - } - Write-Host "Site '$siteName' not found" -ForegroundColor Red - } -} -##################################################################### -## Users -##################################################################### -function Get-Users() { - [CmdletBinding()] - param([String[]]$Usernames) - - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - $results = @() - if ($null -eq $Usernames) { - $usernames = Get-Usernames | Select-Object -Expand Username - } - - foreach ($username in $usernames) { - $user = Set-User $username - $row = New-Object PSObject - $row | Add-Member -type NoteProperty -name Username -Value $username - $row | Add-Member -type NoteProperty -name IsEnabled -Value $user.GetEnableAccount() - $row | Add-Member -type NoteProperty -name Email -Value $user.Email - $row | Add-Member -type NoteProperty -name FullName -Value $user.FullName - $row | Add-Member -type NoteProperty -name HasHomeFolder -Value $user.GetHomeDir() - $row | Add-Member -type NoteProperty -name HomeFolder -Value $user.GetHomeDirString() - $row | Add-Member -type NoteProperty -name HomeFolderIsRoot -Value $user.GetHomeDirIsRoot() - $row | Add-Member -type NoteProperty -name Description -Value $user.GetDescription() - $row | Add-Member -type NoteProperty -name Phone -Value $user.Phone - $row | Add-Member -type NoteProperty -name Pager -Value $user.Pager - $row | Add-Member -type NoteProperty -name Fax -Value $user.Fax - $row | Add-Member -type NoteProperty -name Custom1 -Value $user.Custom1 - $row | Add-Member -type NoteProperty -name Custom2 -Value $user.Custom2 - $row | Add-Member -type NoteProperty -name Custom3 -Value $user.Custom3 - $row | Add-Member -type NoteProperty -name Comments -Value $user.Comments - $row | Add-Member -type NoteProperty -name IsLocked -Value $user.IsLocked - $row | Add-Member -type NoteProperty -name IsConnected -Value $user.IsConnected - $row | Add-Member -type NoteProperty -name LastConnectionTime -Value $user.LastConnectionTime - $row | Add-Member -type NoteProperty -name AccountCreationTime -Value $user.AccountCreationTime - $row | Add-Member -type NoteProperty -name LastModificationTime -Value $user.LastModificationTime - $results += $row - } - return $results - } -} -function Get-Usernames() { - [CmdletBinding()] - param([String[]]$settingsTemplates) - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - $results = @() - if ($null -eq $settingsTemplates) { - $settingsTemplates = Get-SettingsTemplates | Select-Object -Expand SettingsTemplate # Expand is used to convert from object attribute to array of strings - write-verbose "$settingsTemplates" - } - - foreach ($settingsTemplate in $settingsTemplates) { - $users = $null - try { - write-verbose "Getting users from '$settingsTemplate'" - $users = $global:site.GetSettingsLevelUsers($settingsTemplate) - } - catch [Exception] { - - } - - for ($i = 0; $i -le $users.length - 1; $i++ ) { - $row = New-Object PSObject - $row | Add-Member -type NoteProperty -name Username -Value $users[$i] - $row | Add-Member -type NoteProperty -name SettingsTemplate -Value $settingsTemplate - $results += $row - } - } - return $results - } -} - -function Set-User() { - [CmdletBinding()] - param([String]$username) - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - try { - if ($global:site.DoesUsernameExist($username)) { - $global:user = $global:site.GetUserSettings($username) - #Write-Host "User '$username' selected" -ForegroundColor Green - return $global:user - } - else { - Write-Host "User '$username' doesn't exist" -ForegroundColor Red - return - } - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "Exception : $error[0]" -ForegroundColor Red - } - } -} -function Remove-Users() { - [CmdletBinding()] - param([String[]]$Usernames) - - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - foreach ( $username in $Usernames) { - EFT-RM-User $username - } - } -} -function Remove-User() { - [CmdletBinding()] - param([String]$username) - - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - try { - $global:site.RemoveUser($username) - Write-Host "Username '$username' removed" -ForegroundColor Green - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "User '$username' not found" -ForegroundColor Red - Write-Host "Exception : $error[0]" -ForegroundColor Red - } - } -} - -function Get-SettingsTemplates() { - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use EFT-CD-Site " -ForegroundColor Red - } - else { - $results = @() - $settingsTemplates = $global:site.GetSettingsLevels() - - for ($i = 0; $i -le $settingsTemplates.length - 1; $i++ ) { - $row = New-Object PSObject - $row | Add-Member -type NoteProperty -name SettingsTemplate -Value $settingsTemplates[$i] - $results += $row - } - return $results - } -} -##################################################################### -## Virtual Folder -##################################################################### -function Get-VirtualFolders() { - Write-Verbose "SiteName :$global:site.Name" - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - $results = @() - $paths = $global:site.GetVirtualFolderList("").Split() - for ($i = 0 ; $i -le $paths.Length - 1 ; $i++) { - $currentPath = $paths.GetValue($i) - if ($currentPath -ne "") { - $row = New-Object PSObject - $row | Add-Member -type NoteProperty -name Path -Value $currentPath - $row | Add-Member -type NoteProperty -name PhysicalPath -Value $global:site.GetPhysicalPath($currentPath) - $results += $row - } - } - return $results - } -} -function Add-VirtualFolder() { - [CmdletBinding()] - param([String]$path, [String]$physicalPath, [bool]$validateTarget) - - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - $global:site.CreateVirtualFolder($path, $physicalPath, $validateTarget); - Write-Host "Virtual folder '$path' added" -ForegroundColor Green - } -} -function Edit-VirtualFolder() { - [CmdletBinding()] - param([String]$path, [String]$newPhysicalPath) - - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - $global:site.RemapVirtualFolder($path, $newPhysicalPath); - Write-Host "Virtual folder '$path' updated" -ForegroundColor Green - } -} -function Remove-VirtualFolder() { - [CmdletBinding()] - param([String]$path) - - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - if ($global:site.IsFolderVirtual($path)) { - $global:site.RemoveFolder($path); - Write-Host "path '$path' removed" -ForegroundColor Green - } - else { - Write-Host "path '$path' is not virtual folder" -ForegroundColor Red - } - } -} - -##################################################################### -## Permisions -##################################################################### -function Add-Permissions() { - [CmdletBinding()] - param( - [String]$path, - [String]$clientId, - [bool] $ReplaceExisting, - [bool] $FileUpload , - [bool] $FileDownload, - [bool] $FileDelete , - [bool] $FileRename , - [bool] $FileAppend , - [bool] $DirCreate , - [bool] $DirDelete , - [bool] $DirShowHidden, - [bool] $DirShowReadOnly, - [bool] $DirShowInList, - [bool] $DirList - ) - - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - try { - $perm = $global:site.GetBlankPermission($path, $clientId) - $perm.FileUpload = $FileUpload; - $perm.FileDownload = $FileDownload; - $perm.FileDelete = $FileDelete; - $perm.FileRename = $FileRename; - $perm.FileAppend = $FileAppend; - $perm.DirCreate = $DirCreate; - $perm.DirDelete = $DirDelete; - $perm.DirShowHidden = $DirShowHidden; - $perm.DirShowReadOnly = $DirShowReadOnly; - $perm.DirShowInList = $DirShowInList; - $perm.DirList = $DirList; - $global:site.SetPermission($perm, $ReplaceExisting); - Write-Host "permission '$path' for client '$clientId' has been added" -ForegroundColor Green - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "Exception : $error[0]" -ForegroundColor Red - } - } -} -function Edit-Permissions() { - [CmdletBinding()] - param( - [String]$path, - [String]$clientId, - [bool] $ReplaceExisting, - [bool] $FileUpload , - [bool] $FileDownload, - [bool] $FileDelete , - [bool] $FileRename , - [bool] $FileAppend , - [bool] $DirCreate , - [bool] $DirDelete , - [bool] $DirShowHidden, - [bool] $DirShowReadOnly, - [bool] $DirShowInList, - [bool] $DirList - - ) - - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - try { - $permissions = $global:site.GetFolderPermissions($path) - for ($i = 0; $i -le $permissions.length - 1; $i++) { - $perm = $permissions.GetValue($i) - if ($perm.Client -eq $clientId) { - $perm.FileUpload = $FileUpload; - $perm.FileDownload = $FileDownload; - $perm.FileDelete = $FileDelete; - $perm.FileRename = $FileRename; - $perm.FileAppend = $FileAppend; - $perm.DirCreate = $DirCreate; - $perm.DirDelete = $DirDelete; - $perm.DirShowHidden = $DirShowHidden; - $perm.DirShowReadOnly = $DirShowReadOnly; - $perm.DirShowInList = $DirShowInList; - $perm.DirList = $DirList; - $global:site.SetPermission($perm, $ReplaceExisting); - Write-Host "permission '$path' for client '$clientId' has been updated" -ForegroundColor Green - break - } - else { - Write-Host "permission '$path' for client '$clientId' not found" -ForegroundColor Red - } - } - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "Exception : $error[0]" -ForegroundColor Red - } - } -} -function Get-Permissions() { - [CmdletBinding()] - param( - [String]$path) - - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - try { - return $global:site.GetFolderPermissions($path) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "Exception : $error[0]" -ForegroundColor Red - } - } -} -function Remove-Permission() { - [CmdletBinding()] - param( - [String]$path, - [String]$clientId) - - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - try { - $global:site.RemovePermission($path, $clientId ) - Write-Host "permission '$path' for client '$clientId' has been removed" -ForegroundColor Green - return $true - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "Exception : $error[0]" -ForegroundColor Red - return $false - } - } -} - -##################################################################### -## EventRules -##################################################################### -function Get-EventRules() { - Write-Verbose "SiteName :$global:site.Name" - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - $results = @() - $eventTypes = $global:server.AvailableEvents - - for ($i = 0 ; $i -le $eventTypes.Length - 1 ; $i++) { - $currentEventType = $eventTypes[$i].type - $currentEventTypeName = $eventTypes[$i].Name - - $eventRules = $global:site.EventRules($currentEventType) - - for ($j = 0 ; $j -le $eventRules.Count() - 1 ; $j++ ) { - $eventRule = $eventRules.Item($j) - - $row = New-Object PSObject - $row | Add-Member -type NoteProperty -name Name -Value $eventRule.GetParams().Name - $row | Add-Member -type NoteProperty -name IsEnabled -Value $eventRule.GetParams().Enabled - $row | Add-Member -type NoteProperty -name Description -Value $eventRule.GetParams().Description - $row | Add-Member -type NoteProperty -name TypeName -Value $currentEventTypeName - $row | Add-Member -type NoteProperty -name Type -Value $currentEventType - - $results += $row - } - } - return $results - - } -} -function Set-EventRule() { - [CmdletBinding()] - param([String]$eventRuleName) - - Write-Verbose "SiteName :$global:site.Name" - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - $eventTypes = $global:server.AvailableEvents - $global:event = $null - for ($i = 0 ; $i -le $eventTypes.Length - 1 ; $i++) { - $currentEventType = $eventTypes[$i].type - - $eventRules = $global:site.EventRules($currentEventType) - for ($j = 0 ; $j -le $eventRules.Count() - 1 ; $j++ ) { - $eventRule = $eventRules.Item($j) - if ( $eventRule.GetParams().Name -eq $eventRuleName) { - $global:event = $eventRule - } - } - } - return $global:event - } -} -function Remove-EventRule() { - [CmdletBinding()] - param([String]$Name) - - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - $eventTypes = $global:server.AvailableEvents - - for ($i = 0 ; $i -le $eventTypes.Length - 1 ; $i++) { - $currentEventType = $eventTypes[$i].type - - $eventRules = $global:site.EventRules($currentEventType) - - for ($j = 0 ; $j -le $eventRules.Count() - 1 ; $j++ ) { - $eventRule = $eventRules.Item($j) - - if ($Name -eq $eventRule.GetParams().Name) { - $eventRules.Delete($j) - Write-Host "EventRule '$Name' removed" -ForegroundColor Green - return - } - } - } - Write-Host "EventRule '$Name' not found" -ForegroundColor red - return - } -} -function Remove-EventRules() { - [CmdletBinding()] - param([String[]]$Names) - - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - foreach ($Name in $Names) { - Remove-EventRule $Name - } - } -} - - -##################################################################### -## Advanced Workflows -##################################################################### -function Get-AdvancedWorkflows() { - Write-Verbose "SiteName :$global:site.Name" - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - $results = @() - $taskCount = $global:site.AdvancedWorkflowsCount - For ($iTask = 0; $iTask -lt $taskCount; $iTask++) { - $objTask = $global:site.GetAdvancedWorkflowParams($iTask) - $row = New-Object PSObject - $row | Add-Member -type NoteProperty -name Name -Value $objTask.Name - $row | Add-Member -type NoteProperty -name Description -Value $objTask.Description - $row | Add-Member -type NoteProperty -name TimeoutSeconds -Value $objTask.TimeoutSeconds - $row | Add-Member -type NoteProperty -name LogMode -Value $objTask.$LogMode - $row | Add-Member -type NoteProperty -name LogDir -Value $objTask.$LogDir - $row | Add-Member -type NoteProperty -name RetainSuccessfulLogsEnabled -Value $objTask.$RetainSuccessfulLogsEnabled - $row | Add-Member -type NoteProperty -name RetainFailedLogsEnabled -Value $objTask.$RetainFailedLogsEnabled - $results += $row - } - } - return $results -} -function Set-AdvancedWorkflow() { - [CmdletBinding()] - param([String]$AdvancedWorkflowName) - - Write-Verbose "SiteName :$global:site.Name" - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - $global:advancedWorkflow = $null - $taskCount = $global:site.AdvancedWorkflowsCount - For ($iTask = 0; $iTask -lt $taskCount; $iTask++) { - $objTask = $global:site.GetAdvancedWorkflowParams($iTask) - if ( $objTask.Name -eq $AdvancedWorkflowName) { - $global:advancedWorkflow = $objTask - } - } - return $global:advancedWorkflow - } -} -function Remove-AdvancedWorkflow() { - [CmdletBinding()] - param([String]$Name) - - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - $taskCount = $global:site.AdvancedWorkflowsCount - For ($iTask = 0; $iTask -lt $taskCount; $iTask++) { - $objTask = $global:site.GetAdvancedWorkflowParams($iTask) - - if ($Name -eq $objTask.Name) { - $global:site.RemoveAdvancedWorkflow($iTask) - Write-Host "Advanced Workflow '$Name' removed" -ForegroundColor Green - return - } - } - Write-Host "Advanced Workflow '$Name' not found" -ForegroundColor red - return - } -} -function Remove-AdvancedWorkflows() { - [CmdletBinding()] - param([String[]]$Names) - - if ($null -eq $global:site) { - Write-Host "You need to select a EFT Site first use Set-Site " -ForegroundColor Red - } - else { - foreach ($Name in $Names) { - Remove-AdvancedWorkflow $Name - } - } -} \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.ConnectionProfiles.Export.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.ConnectionProfiles.Export.ps1 deleted file mode 100644 index 8c6b196..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.ConnectionProfiles.Export.ps1 +++ /dev/null @@ -1,164 +0,0 @@ -## -## 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 = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password -) -## To Export to CSV use: -## .\EFT.Profiles-Export.ps1 |Export-csv profiles.csv -NoTypeInformation - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - -$script:EftServer = new-object -ComObject "SFTPCOMInterface.CIServer" -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' -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) - - $SiteGuid = $null - try { - $SiteGuid = $script:EftSite.GUID - } - catch [System.Runtime.InteropServices.COMException] { - - } - $totalProfiles = -1 - try { - $totalProfiles = $script:eftsite.GetConnectionProfilesCount() - } - catch { - $totalProfiles = -1 - } - - For ($iprofile = 0; $iprofile -lt $totalProfiles; $iprofile++) { - $objTask = $null - Write-Progress -Activity "Processing Connection Profile" -status "Profile ($iprofile/$($totalProfiles))" -percentComplete ($iprofile / $totalProfiles * 100) - - try { - $sw.Restart() - $objTask = $script:eftsite.GetConnectionProfileParams($iprofile) - } - catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Magenta - Write-Host "COM Exception : $error[0]" -ForegroundColor Red - $errorCount++ - continue - } - - $ConnectionProfileGUID="" - try { $ConnectionProfileGUID = $objTask.GUID } catch{} - - if ($null -ne $objTask ){ - $results += new-object psobject -Property @{ - SiteName = $script:EftSite.Name; - SiteGuid = $SiteGuid; - ConnectionProfileGUID = $ConnectionProfileGUID; - Name = $objTask.Name; - Type = $objTask.type; - Description = $objTask.Description; - Protocol = $objTask.Protocol; - Host = $objTask.Host; - Port = $objTask.Port; - AutoLogin = $objTask.AutoLogin; - User = $objTask.User; - Password = $objTask.Password; - PrivateKeyPath = $objTask.PrivateKeyPath; - PrivateKeyPassword = $objTask.PrivateKeyPassword; - PublicKeyPath = $objTask.PublicKeyPath; - TrustedPublicKeyPath = $objTask.TrustedPublicKeyPath; - MaxConcurrentThreads = $objTask.MaxConcurrentThreads; - ConnectionTimeoutSeconds= $objTask.ConnectionTimeoutSeconds; - ConnectionRetryAttempts = $objTask.ConnectionRetryAttempts; - RetryDelaySeconds = $objTask.RetryDelaySeconds; - ValidateIntegrity = $objTask.ValidateIntegrity; - FTPDataConnectionMode = $objTask.FTPDataConnectionMode; - FTPDataConnectionPortMin= $objTask.FTPDataConnectionPortMin; - FTPDataConnectionPortMax= $objTask.FTPDataConnectionPortMax; - FTPSClearCommandChannel = $objTask.FTPSClearCommandChannel; - FTPSClearDataChannel = $objTask.FTPSClearDataChannel; - TransferEncoding = $objTask.TransferEncoding; - TextFileTypes = $objTask.TextFileTypes; - PreserveRemoteFileTime = $objTask.PreserveRemoteFileTime; - PreserveLocalFileTime = $objTask.PreserveLocalFileTime; - UseProxy = $objTask.UseProxy; - ProxyType = $objTask.ProxyType; - ProxyHostName = $objTask.ProxyHostName; - ProxyPort = $objTask.ProxyPort; - ProxyUserName = $objTask.ProxyUserName; - ProxyPassword = $objTask.ProxyPassword; - ProxyAuthenticationType = $objTask.ProxyAuthenticationType; - ProxyAdvSeparator = $objTask.ProxyAdvSeparator; - ProxyAdvCustomCmds = $objTask.ProxyAdvCustomCmds; - UseSOCKS = $objTask.UseSOCKS; - SOCKSType = $objTask.SOCKSType; - SOCKSHostName = $objTask.SOCKSHostName; - SOCKSPort = $objTask.SOCKSPort; - SOCKSUseAuthentication = $objTask.SOCKSUseAuthentication; - SOCKSUserName = $objTask.SOCKSUserName; - SOCKSPassword = $objTask.SOCKSPassword; - CheckSum = ""; - } - } - } - -} -try { - for ($i = 0 ; $i -le $results.count - 1; $i++) { - $u = $results[$i] - #Concatenate all columns except the mentioned in the ExcludedProperty - $userHash = -join ( $u | Select-Object * -ExcludeProperty SiteName,SiteGuid, ConnectionProfileGUID, Name, CheckSum) - $userHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($userHash))) | Select-Object -ExpandProperty Hash - $results[$i].CheckSum = $userHash - } -} -catch { - $results[$i].CheckSum = "NA" -} -$results | Sort-Object Name -$script:EftServer.close() - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.ConnectionProfiles.Import.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.ConnectionProfiles.Import.ps1 deleted file mode 100644 index 6740d43..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.ConnectionProfiles.Import.ps1 +++ /dev/null @@ -1,186 +0,0 @@ -## -## 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(SupportsShouldProcess)] -Param( - [Parameter(Position = 0, Mandatory = $false, HelpMessage = "Enter the connection profiles CSV file ")] - [string] $ConnectioProfileCsvFile = "profiles.csv", - - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False )] - [switch]$Quiet = $false -) - -if ($ConnectioProfileCsvFile -eq "") { - #Uncomment the following to enter paramters for each site - # $EFTPermissions = @( - # @{ SiteName = "MySite"; Path = "\"; Client= "" IsInherited = "" ; InheritedFrom =""; Permissions = "" } - # @{ SiteName = "MySite"; Path = "\"; Client= "" IsInherited = "" ; InheritedFrom =""; Permissions = "" } - #) -} -else { - $ConnectioProfiles = Import-Csv $ConnectioProfileCsvFile - # "SiteName","Path", "Client","Permissions",IsInherited","InheritedFrom" -} -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' - -$MAX_PAD = 100 -$PAD_CHR = "." - -$EFTServer = new-object -ComObject "SFTPCOMInterface.CIServer" - -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $script:EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() - -$SiteList = @{} -for ($j = 0; $j -le $sitesCount - 1; $j++ ) { - $script:EftSite = $script:EftSites.Item($j) - $SiteList.Add($script:EftSite.Name, $script:EftSite.ID) -} - -Write-host "Importing Folder Permissions:" -$Imported = 0 -$errorCount = 0 -foreach ($ConnectioProfile in $ConnectioProfiles) { - $index = -1 - try { - $script:EftSite = $script:EftSites.SiteByID($SiteList[$ConnectioProfile.SiteName]) - - Write-host "Importing: [$($ConnectioProfile.SiteName)] $($ConnectioProfile.Name)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - - for ($i = 0; $i -lt $script:EFTSite.GetConnectionProfilesCount(); $i++) { - if ($ConnectioProfile.Name -eq $EFTSite.GetConnectionProfileParams($i).Name) { - $index = $i; - } - } - # Importing connection profile - if ($index -gt -1) { - # Updating connection profile - $connectionProfileParams = $EFTSite.GetConnectionProfileParams($index) - } - else { - # Adding Workflow - $connectionProfileParams = new-object -ComObject "SFTPCOMInterface.CIConnectionProfileParams" - $connectionProfileParams.Name = $ConnectioProfile.Name; - } - - - try { - if ($ConnectioProfile.ConnectionProfileGUID -ne "") { - $connectionProfileParams.GUID = $ConnectioProfile.ConnectionProfileGUID; - } - } - catch {} - - $connectionProfileParams.Type = [int]$ConnectioProfile.type; - $connectionProfileParams.Description = $ConnectioProfile.Description; - $connectionProfileParams.Protocol = [int]$ConnectioProfile.Protocol; - $connectionProfileParams.Host = $ConnectioProfile.Host; - $connectionProfileParams.Port = [int]$ConnectioProfile.Port; - $connectionProfileParams.AutoLogin = [bool]$ConnectioProfile.AutoLogin; - $connectionProfileParams.User = $ConnectioProfile.User; - $connectionProfileParams.Password = $ConnectioProfile.Password; - $connectionProfileParams.PrivateKeyPath = $ConnectioProfile.PrivateKeyPath; - $connectionProfileParams.PrivateKeyPassword = $ConnectioProfile.PrivateKeyPassword; - $connectionProfileParams.PublicKeyPath = $ConnectioProfile.PublicKeyPath; - $connectionProfileParams.TrustedPublicKeyPath = $ConnectioProfile.TrustedPublicKeyPath; - $connectionProfileParams.MaxConcurrentThreads = [int]$ConnectioProfile.MaxConcurrentThreads; - $connectionProfileParams.ConnectionTimeoutSeconds = [int]$ConnectioProfile.ConnectionTimeoutSeconds; - $connectionProfileParams.ConnectionRetryAttempts = [int]$ConnectioProfile.ConnectionRetryAttempts; - $connectionProfileParams.RetryDelaySeconds = [int]$ConnectioProfile.RetryDelaySeconds; - $connectionProfileParams.ValidateIntegrity = [bool]$ConnectioProfile.ValidateIntegrity; - $connectionProfileParams.FTPDataConnectionMode = [int]$ConnectioProfile.FTPDataConnectionMode; - $connectionProfileParams.FTPDataConnectionPortMin = [int]$ConnectioProfile.FTPDataConnectionPortMin; - $connectionProfileParams.FTPDataConnectionPortMax = [int]$ConnectioProfile.FTPDataConnectionPortMax; - $connectionProfileParams.FTPSClearCommandChannel = [bool]$ConnectioProfile.FTPSClearCommandChannel; - $connectionProfileParams.FTPSClearDataChannel = [bool]$ConnectioProfile.FTPSClearDataChannel; - $connectionProfileParams.TransferEncoding = [int]$ConnectioProfile.TransferEncoding; - $connectionProfileParams.TextFileTypes = $ConnectioProfile.TextFileTypes; - $connectionProfileParams.PreserveRemoteFileTime = [bool]$ConnectioProfile.PreserveRemoteFileTime; - $connectionProfileParams.PreserveLocalFileTime = [bool]$ConnectioProfile.PreserveLocalFileTime; - $connectionProfileParams.UseProxy = [bool]$ConnectioProfile.UseProxy; - $connectionProfileParams.ProxyType = [int]$ConnectioProfile.ProxyType; - $connectionProfileParams.ProxyHostName = $ConnectioProfile.ProxyHostName; - $connectionProfileParams.ProxyPort = [int]$ConnectioProfile.ProxyPort; - $connectionProfileParams.ProxyUserName = $ConnectioProfile.ProxyUserName; - $connectionProfileParams.ProxyPassword = $ConnectioProfile.ProxyPassword; - $connectionProfileParams.ProxyAuthenticationType = [int]$ConnectioProfile.ProxyAuthenticationType; - $connectionProfileParams.ProxyAdvSeparator = $ConnectioProfile.ProxyAdvSeparator; - $connectionProfileParams.ProxyAdvCustomCmds = $ConnectioProfile.ProxyAdvCustomCmds; - $connectionProfileParams.UseSOCKS = [bool]$ConnectioProfile.UseSOCKS; - $connectionProfileParams.SOCKSType = [int]$ConnectioProfile.SOCKSType; - $connectionProfileParams.SOCKSHostName = $ConnectioProfile.SOCKSHostName; - $connectionProfileParams.SOCKSPort = [int]$ConnectioProfile.SOCKSPort; - $connectionProfileParams.SOCKSUseAuthentication = [bool]$ConnectioProfile.SOCKSUseAuthentication; - $connectionProfileParams.SOCKSUserName = $ConnectioProfile.SOCKSUserName; - $connectionProfileParams.SOCKSPassword = $ConnectioProfile.SOCKSPassword; - If ($index -lt 0) { - $connectionProfileIndex = $eftsite.AddConnectionProfile($connectionProfileParams) - } - - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - $Imported++ - - } - catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_FOLDER_NOT_FOUND { Write-host "MXE_FOLDER_NOT_FOUND : $_ " -ForegroundColor Red } - $MXE_INVALID_FOLDER_NAME { Write-host "MXE_INVALID_FOLDER_NAME : $_ " -ForegroundColor Red } - $MXE_FOLDER_NOT_EMPTY { Write-host "MXE_FOLDER_NOT_EMPTY : $_ " -ForegroundColor Red } - Default { Write-host "Exception : $_" -ForegroundColor Red} - } - $errorCount++ - continue - } -} -$script:EftServer.close() - -Write-host " Imported: " -NoNewline -Write-host "$Imported " -NoNewline -ForegroundColor green -Write-host "Errors: "-NoNewline -Write-host "$errorCount " -ForegroundColor red -Write-host " " - - - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Deploy.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Deploy.ps1 deleted file mode 100644 index bf297f5..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Deploy.ps1 +++ /dev/null @@ -1,888 +0,0 @@ -## -## 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. - -### -# cd C:\Users\rguzman\Desktop\src\src -# . .\deploy.ps1 -EFTHostname localhost -EFTSiteName Rogers -EFTAdmin admin -password Super2017!! -# TEST TEST TEST - -### -param ( - [Parameter(Position = 0, Mandatory = $True, HelpMessage = "Enter the input folder where files will be read for deploy")] - [String] $BuildFolder = "" , - - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, 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 = 4, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [switch] $Mirror = $false, - - [Parameter(Position = 7, Mandatory = $False )] - [switch]$Quiet = $false - -) -Function RemoveInvalidChars($path) { - $path -replace ("[{0}]" -f (([System.IO.Path]::GetInvalidFileNameChars() | ForEach-Object { [regex]::Escape($_) }) -join '|')), '_' - #return $path -} -function ParseValues ($source, $target) { - $sourceProps = Get-Member -InputObject $source -MemberType Properties - $targetProps = Get-Member -InputObject $target -MemberType Properties - foreach ($targetprop in $targetProps) { - foreach ($sourceProp in $sourceProps) { - Write-Debug "Source: $($sourceProp.Name) .. Target: $($targetProp.Name)" - # Manual Properties , these must be set Manually - if ($targetProp.Name -eq "ProxyType") { - break; - } - if ($sourceProp.Name -eq $targetProp.Name) { - #$Name = $targetProp.Name - #$definition =$targetProp.Definition - #$i = $definition.indexOf(" ") - #$targettype = $Definition.substring(0,$i) - if ($sourceProp.definition -like "*get*" -and $targetProp.definition -like "*set*" ) { - $target."$($targetProp.Name)" = $source."$($sourceProp.Name)" - break - } - } - - } - - } -} -function RenameEventRule($originalName, $newName) { - - $eventTypes = $EFTServer.AvailableEvents - for ($i = 0 ; $i -le $eventTypes.Length - 1 ; $i++) { - $currentEventType = $eventTypes[$i].type - #$currentEventTypeName = $eventTypes[$i].Name - $eventRules = $EFTSite.EventRules($currentEventType) - for ($j = 0 ; $j -le $eventRules.Count() - 1 ; $j++ ) { - $eventRule = $eventRules.Item($j) - $eventParams = $eventRule.GetParams() - if ($originalName -eq $eventParams.Name) { - $eventParams.Name = $newName - $eventRule.SetParams($eventParams) - - return $true - } - } - if ($isRenamed) { - return $true - } - } - return $false -} - -Write-host "******* EFT Deploy SCRIPT 1.0 *************************************************" -ForegroundColor Yellow -if ($Quiet -eq $false) { - Write-host " WARNING NOTES:" -ForegroundColor Yellow - Write-host " > This script will modify your EFT configuration and these changes can't be undone" -ForegroundColor Yellow - Write-host " > You must perform backups of your EFT config before using this script" -ForegroundColor Yellow - Write-host " > It is recommend you test this script in a non-production environment before " -ForegroundColor Yellow - Write-host " using in production to validate its functionality" -ForegroundColor Yellow - Write-host "******************************************************************************" -ForegroundColor Yellow -} -$CurrentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name -if ($EFTAdminAuthType -eq 1) { - $EFTAdminUsername = $CurrentUserName -} -$EftService = Get-Service "EFT *" -$adminPrivileges = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' - - -#Output parameters -Write-Host "Current datetime : $(Get-Date -f $df)" -Write-Host "Current User : $CurrentUserName" -Write-Host "Admin Privileges : $adminPrivileges" -Write-host "EFT Server Service : " -NoNewline -$OriginalEFTServiceState = $EftService.Status -if ($EftService.Status -eq "Running") { Write-host "$($OriginalEFTServiceState)" -ForegroundColor Green } else { Write-host "$($OriginalEFTServiceState)" -ForegroundColor Red } -Write-host "Build Folder : $BuildFolder" -Write-host "Mirror Artifacts : $Mirror" -Write-host "EFT Admin Hostname : $EFTAdminHostname" -Write-host "EFT Admin Port : $EFTAdminPort" -Write-host "EFT Admin Auth Type : $EFTAdminAuthType" -Write-host "EFT Admin Username : $EFTAdminUsername" - -if ($Quiet -eq $false) { - $continue = Read-Host -Prompt "Have you read and understand the warning notes (y/n)?" - if ($continue.ToUpper() -ne "Y") { - exit - } -} -# Constants -$MAX_PAD = 100 -$PAD_CHR = "." -$EFTServer = $null -$EFTSites = $null -$EFTSite = $null -$CUSTOM_COMMAND_NOT_FOUND = "Could not find specified command in this site" -$MXE_CANNOT_IMPORT_EVENT_RULE = "MX Error: 119 (00000077)" -$MXE_INVALID_CONNECTION_PROFILE_DATA = "MX Error: 109 (0000006D)" - -# Validations -if ($BuildFolder -notmatch '.+?\\$') { - $BuildFolder += '\' -} - -If ( (Test-Path $BuildFolder) -eq $false) { - Write-host "Build folder '$BuildFolder' doesn't exist" -ForegroundColor red - exit -} - -$BuildFolder = Convert-Path $BuildFolder - -$EFTServer = new-object -ComObject "SFTPCOMInterface.CIServer" - -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -#$sitesCount = $script:EftSites.Count() -$sitesCount = $script:EftSites.Count() -$eventTypes = $EFTServer.AvailableEvents - -Get-ChildItem $BuildFolder -Directory | -Foreach-Object { - - $EFTSiteName = $_.BaseName - - Write-host "Detecting EFT site: $EFTSiteName ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - - $siteFound = $false - #Finding sitename - $sw.Restart() - for ($i = 0; $i -le $sitesCount - 1; $i++ ) { - $EFTSite = $EFTSites.Item($i) - if ($EFTSite.Name -eq $EFTSiteName) { - $siteFound = $true - break - } - } - - if ($siteFound) { - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - else { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-Host "Site Not found" -ForegroundColor Red - return - } - Write-host "" - Write-host "[Advanced Workflows]" - if (Test-Path "$BuildFolder\$EFTSiteName\workflows\") { - Get-ChildItem "$BuildFolder\$EFTSiteName\workflows\" -Filter *.xml | - Foreach-Object { - - Write-Host "Importing: $($_.BaseName)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $objParams = Import-Clixml $_.FullName - $workflowIndex = -1 - try { - $workflowIndex = $EFTSite.GetAdvancedWorkflowIndex($objParams.Name) - # Importing workflow - - if ($workflowIndex -gt -1) { - # Updating Workflow - $workflowParams = $EFTSite.GetAdvancedWorkflowParams($workflowIndex) - } - else { - # Adding Workflow - $workflowParams = new-object -ComObject "SFTPCOMInterface.CIAdvancedWorkflowParams" - } - - $sourceHash = -join ( $objParams | Select-Object * -ExcludeProperty DateCreated ) - $targetHash = -join ( $workflowParams | Select-Object * -ExcludeProperty DateCreated) - - try { - $sourceHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($sourceHash))) | Select-Object -ExpandProperty Hash - $targetHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($targetHash))) | Select-Object -ExpandProperty Hash - } - catch { - $sourceHash = 1 - $targetHash = 2 - } - - if ($sourceHash -ne $targetHash) { - ParseValues $objParams $workflowParams - #$workflowParams = $objParams - If ($workflowIndex -ge 0) { - $eftsite.SetAdvancedWorkflowParams($workflowIndex, $workflowParams) - } - else { - $eftsite.AddAdvancedWorkflow($workflowParams) - } - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - else { - Write-host " SAME ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - } - } - catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - } - } - } - - Write-host "" - Write-host "[Custom Commands]" - if (Test-Path "$BuildFolder\$EFTSiteName\commands\") { - Get-ChildItem "$BuildFolder\$EFTSiteName\commands\" -Filter *.xml | - Foreach-Object { - - Write-Host "Importing: $($_.BaseName)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $objParams = Import-Clixml $_.FullName - $index = -1 - try { - $found = $false - - # Updating command - try { - $commandSettings = $EFTSite.GetCommandSettings($objParams.Name) - $found = $true - } - catch { - $found = $false - } - - if (!$found) { - # Adding Workflow - $commandSettings = new-object -ComObject "SFTPCOMInterface.CICommandSettings" - } - - $sourceHash = -join ( $objParams | Select-Object *) - $targetHash = -join ( $commandSettings | Select-Object *) - try { - $sourceHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($sourceHash))) | Select-Object -ExpandProperty Hash - $targetHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($targetHash))) | Select-Object -ExpandProperty Hash - } - catch { - $sourceHash = 1 - $targetHash = 2 - } - if ($sourceHash -ne $targetHash) { - #$commandSettings = $objParams - If (!$found) { - $commandSettings = $eftsite.CreateCommand($objParams.Name) - } - ParseValues $objParams $commandSettings - - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - else { - Write-host " SAME ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - } - } - catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - } - } - } - Write-host "" - Write-host "[Custom Commands User Permissions]" - if (Test-Path "$BuildFolder\$EFTSiteName\commands_userpermissions\") { - Get-ChildItem "$BuildFolder\$EFTSiteName\commands_userpermissions\" -Filter *.xml | - Foreach-Object { - - Write-Host "Importing: $($_.BaseName)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $objParams = Import-Clixml $_.FullName - - try { - # Updating command - $commandSettings = $EFTSite.GetCommandSettings($_.BaseName) - $userPermissions = $commandSettings.GetUserPermissions() - - - $sourceHash = -join ( $objParams ) - $targetHash = -join ( $userPermissions ) - try { - $sourceHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($sourceHash))) | Select-Object -ExpandProperty Hash - $targetHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($targetHash))) | Select-Object -ExpandProperty Hash - } - catch { - $sourceHash = 1 - $targetHash = 2 - } - if ($sourceHash -ne $targetHash) { - - foreach ($userperm in $userPerfmissions) { - $commandSettings.RemoveUserPermission($userperm); - } - - foreach ($userperm in $objParams) { - $commandSettings.AddUserPermission($userperm); - } - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - else { - Write-host " SAME ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - } - } - catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - } - } - } - - Write-host "" - Write-host "[AS2 Profiles]" - if (Test-Path "$BuildFolder\$EFTSiteName\as2_profiles\") { - $baseAS2Path = join-path "$BuildFolder" "$EFTSiteName\as2_profiles\" - Get-ChildItem "$BuildFolder\$EFTSiteName\as2_profiles\" -Directory -Recurse | Where-Object { $_.PSIsContainer } | - Foreach-Object { - #$Username = $_.BaseName - $username = $_.FullName.Replace($baseAS2Path, "") - $userfound = $false - Write-Host "Importing: $($username) [AS2Inbound]".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - try { - $detail = $script:EftSite.GetUserSettings($Username) - $userfound = $true - } - catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - } - - if ($userfound) { - $AS2Inbound_Path = Join-Path $_.FullName "AS2Inbound.xml" - if (Test-Path $AS2Inbound_Path -PathType Leaf) { - - $sw.Restart() - $sourceAS2InboundProfile = Import-Clixml $AS2Inbound_Path - $targetAS2InboundProfile = $detail.AS2InboundSettings - - $sourceHash = -join ( $sourceAS2InboundProfile | Select-Object * ) ; - $targetHash = -join ( $targetAS2InboundProfile | Select-Object * ) - - try { - $sourceHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($sourceHash))) | Select-Object -ExpandProperty Hash - $targetHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($targetHash))) | Select-Object -ExpandProperty Hash - } - catch { - $sourceHash = 1; $targetHash = 2 - } - if ($sourceHash -ne $targetHash) { - #$connectionProfileParams = $objParams - ParseValues $sourceAS2InboundProfile $targetAS2InboundProfile - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - else { - Write-host " SAME ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - } - } - - $AS2Inbound_FailureCommand_Path = Join-Path $_.FullName "AS2Inbound_FailureCommand.xml" - if (Test-Path $AS2Inbound_FailureCommand_Path -PathType Leaf) { - Write-Host "Importing: $($_.BaseName) [AS2Inbound_FailureCommand]".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $sourceAS2Inbound_FailureCommand = Import-Clixml $AS2Inbound_FailureCommand_Path - $targetAS2Inbound_FailureCommand = $detail.AS2InboundSettings.GetFailureCommand() - - $sourceHash = -join ( $sourceAS2Inbound_FailureCommand | Select-Object * ) ; - $targetHash = -join ( $targetAS2Inbound_FailureCommand | Select-Object * ) - - try { - $sourceHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($sourceHash))) | Select-Object -ExpandProperty Hash - $targetHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($targetHash))) | Select-Object -ExpandProperty Hash - } - catch { - $sourceHash = 1; $targetHash = 2 - } - if ($sourceHash -ne $targetHash) { - #$connectionProfileParams = $objParams - ParseValues $sourceAS2Inbound_FailureCommand $targetAS2Inbound_FailureCommand - $detail.AS2InboundSettings.SetFailureCommand($targetAS2Inbound_FailureCommand) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - else { - Write-host " SAME ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - } - } - - # $AS2Inbound_FailureEmail_Path = Join-Path $_.FullName "AS2Inbound_FailureEmail.xml" - $AS2Inbound_FailureEmail_Path = Join-Path $_.FullName "AS2Inbound_FailureEmail.xml" - if (Test-Path $AS2Inbound_FailureEmail_Path -PathType Leaf) { - Write-Host "Importing: $($_.BaseName) [AS2Inbound_FailureEmail]".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $sourceAS2Inbound_FailureEmail = Import-Clixml $AS2Inbound_FailureEmail_Path - $targetAS2Inbound_FailureEmail = $detail.AS2InboundSettings.GetFailureEmail() - - $sourceHash = -join ( $sourceAS2Inbound_FailureEmail | Select-Object * ) ; - $targetHash = -join ( $targetAS2Inbound_FailureEmail | Select-Object * ) - - try { - $sourceHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($sourceHash))) | Select-Object -ExpandProperty Hash - $targetHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($targetHash))) | Select-Object -ExpandProperty Hash - } - catch { - $sourceHash = 1; $targetHash = 2 - } - if ($sourceHash -ne $targetHash) { - #$connectionProfileParams = $objParams - ParseValues $sourceAS2Inbound_FailureEmail $targetAS2Inbound_FailureEmail - $detail.AS2InboundSettings.SetFailureEmail($targetAS2Inbound_FailureEmail) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - else { - Write-host " SAME ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - } - } - - # $AS2Inbound_SuccessCommand_Path = Join-Path $_.FullName "AS2Inbound_SuccessCommand.xml" - $AS2Inbound_SuccessCommand_Path = Join-Path $_.FullName "AS2Inbound_SuccessCommand.xml" - if (Test-Path $AS2Inbound_SuccessCommand_Path -PathType Leaf) { - Write-Host "Importing: $($_.BaseName) [AS2Inbound_SuccessCommand]".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $sourceAS2Inbound_SuccessCommand = Import-Clixml $AS2Inbound_SuccessCommand_Path - $targetAS2Inbound_SuccessCommand = $detail.AS2InboundSettings.GetSuccessCommand() - - $sourceHash = -join ( $sourceAS2Inbound_SuccessCommand | Select-Object * ) ; - $targetHash = -join ( $targetAS2Inbound_SuccessCommand | Select-Object * ) - - try { - $sourceHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($sourceHash))) | Select-Object -ExpandProperty Hash - $targetHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($targetHash))) | Select-Object -ExpandProperty Hash - } - catch { - $sourceHash = 1; $targetHash = 2 - } - if ($sourceHash -ne $targetHash) { - #$connectionProfileParams = $objParams - ParseValues $sourceAS2Inbound_SuccessCommand $targetAS2Inbound_SuccessCommand - $detail.AS2InboundSettings.SetSuccessCommand($targetAS2Inbound_SuccessCommand) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - else { - Write-host " SAME ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - } - } - - # $AS2Inbound_SuccessEmail_Path = Join-Path $_.FullName "AS2Inbound_SuccessEmail.xml" - $AS2Inbound_SuccessEmail_Path = Join-Path $_.FullName "AS2Inbound_SuccessEmail.xml" - if (Test-Path $AS2Inbound_SuccessCommand_Path -PathType Leaf) { - Write-Host "Importing: $($_.BaseName) [AS2Inbound_SuccessEmail]".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $sourceAS2Inbound_SuccessEmail = Import-Clixml $AS2Inbound_SuccessEmail_Path - $targetAS2Inbound_SuccessEmail = $detail.AS2InboundSettings.GetSuccessEmail() - - $sourceHash = -join ( $sourceAS2Inbound_SuccessEmail | Select-Object * ) ; - $targetHash = -join ( $targetAS2Inbound_SuccessEmail | Select-Object * ) - - try { - $sourceHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($sourceHash))) | Select-Object -ExpandProperty Hash - $targetHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($targetHash))) | Select-Object -ExpandProperty Hash - } - catch { - $sourceHash = 1; $targetHash = 2 - } - if ($sourceHash -ne $targetHash) { - #$connectionProfileParams = $objParams - ParseValues $sourceAS2Inbound_SuccessEmail $targetAS2Inbound_SuccessEmail - $detail.AS2InboundSettings.SetSuccessEmail($targetAS2Inbound_SuccessEmail) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - else { - Write-host " SAME ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - } - } - - $AS2Outbound_Path = Join-Path $_.FullName "AS2Outbound.xml" - if (Test-Path $AS2Outbound_Path -PathType Leaf) { - Write-Host "Importing: $($_.BaseName) [AS2Outbound]".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - - $sourceAS2OutboundProfile = Import-Clixml $AS2Outbound_Path - $targetAS2OutboundProfile = $detail.AS2OutboundSettings - - $sourceHash = -join ( $sourceAS2OutboundProfile | Select-Object * ) - $targetHash = -join ( $targetAS2OutboundProfile | Select-Object * ) - - try { - $sourceHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($sourceHash))) | Select-Object -ExpandProperty Hash - $targetHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($targetHash))) | Select-Object -ExpandProperty Hash - } - catch { - $sourceHash = 1; $targetHash = 2 - } - if ($sourceHash -ne $targetHash) { - #$connectionProfileParams = $objParams - ParseValues $sourceAS2OutboundProfile $targetAS2OutboundProfile - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - else { - Write-host " SAME ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - } - } - - # $AS2Outbound_FailureCommand_Path = Join-Path $_.FullName "AS2Outbound_FailureCommand.xml" - $AS2Outbound_FailureCommand_Path = Join-Path $_.FullName "AS2Outbound_FailureCommand.xml" - if (Test-Path $AS2Outbound_FailureCommand_Path -PathType Leaf) { - Write-Host "Importing: $($_.BaseName) [AS2Outbound_FailureCommand]".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - - $sourceAS2Outbound_FailureCommand = Import-Clixml $AS2Outbound_FailureCommand_Path - $targetAS2Outbound_FailureCommand = $detail.AS2OutboundSettings.GetFailureCommand() - - $sourceHash = -join ( $sourceAS2Outbound_FailureCommand | Select-Object * ) - $targetHash = -join ( $targetAS2Outbound_FailureCommand | Select-Object * ) - - try { - $sourceHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($sourceHash))) | Select-Object -ExpandProperty Hash - $targetHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($targetHash))) | Select-Object -ExpandProperty Hash - } - catch { - $sourceHash = 1; $targetHash = 2 - } - if ($sourceHash -ne $targetHash) { - #$connectionProfileParams = $objParams - ParseValues $sourceAS2Outbound_FailureCommand $targetAS2Outbound_FailureCommand - $detail.AS2OutboundSettings.SetFailureCommand($targetAS2Outbound_FailureCommand) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - else { - Write-host " SAME ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - } - } - - # $AS2Outbound_FailureEmail_Path = Join-Path $_.FullName "AS2Outbound_FailureEmail.xml" - $AS2Outbound_FailureEmail_Path = Join-Path $_.FullName "AS2Outbound_FailureEmail.xml" - if (Test-Path $AS2Outbound_FailureEmail_Path -PathType Leaf) { - Write-Host "Importing: $($_.BaseName) [AS2Outbound_FailureEmail]".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - - $sourceAS2Outbound_FailureEmail = Import-Clixml $AS2Outbound_FailureEmail_Path - $targetAS2Outbound_FailureEmail = $detail.AS2OutboundSettings.GetFailureEmail() - - $sourceHash = -join ( $sourceAS2Outbound_FailureEmail | Select-Object * ) - $targetHash = -join ( $targetAS2Outbound_FailureEmail | Select-Object * ) - - try { - $sourceHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($sourceHash))) | Select-Object -ExpandProperty Hash - $targetHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($targetHash))) | Select-Object -ExpandProperty Hash - } - catch { - $sourceHash = 1; $targetHash = 2 - } - if ($sourceHash -ne $targetHash) { - #$connectionProfileParams = $objParams - ParseValues $sourceAS2Outbound_FailureEmail $targetAS2Outbound_FailureEmail - $detail.AS2OutboundSettings.SetFailureEmail($targetAS2Outbound_FailureEmail) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - else { - Write-host " SAME ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - } - } - # $AS2Outbound_SuccessCommand_Path = Join-Path $_.FullName "AS2Outbound_SuccessCommand.xml" - $AS2Outbound_SuccessCommand_Path = Join-Path $_.FullName "AS2Outbound_SuccessCommand.xml" - if (Test-Path $AS2Outbound_SuccessCommand_Path -PathType Leaf) { - Write-Host "Importing: $($_.BaseName) [AS2Outbound_SuccessCommand]".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - - $sourceAS2Outbound_SuccessCommand = Import-Clixml $AS2Outbound_SuccessCommand_Path - $targetAS2Outbound_SuccessCommand = $detail.AS2OutboundSettings.GetSuccessCommand() - - $sourceHash = -join ( $sourceAS2Outbound_SuccessCommand | Select-Object * ) - $targetHash = -join ( $targetAS2Outbound_SuccessCommand | Select-Object * ) - - try { - $sourceHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($sourceHash))) | Select-Object -ExpandProperty Hash - $targetHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($targetHash))) | Select-Object -ExpandProperty Hash - } - catch { - $sourceHash = 1; $targetHash = 2 - } - if ($sourceHash -ne $targetHash) { - #$connectionProfileParams = $objParams - ParseValues $sourceAS2Outbound_SuccessCommand $targetAS2Outbound_SuccessCommand - $detail.AS2OutboundSettings.SetSuccessCommand($targetAS2Outbound_SuccessCommand) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - else { - Write-host " SAME ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - } - } - - # $AS2Outbound_SuccessEmail_Path = Join-Path $_.FullName "AS2Outbound_SuccessEmail.xml" - $AS2Outbound_SuccessEmail_Path = Join-Path $_.FullName "AS2Outbound_SuccessEmail.xml" - if (Test-Path $AS2Outbound_SuccessEmail_Path -PathType Leaf) { - Write-Host "Importing: $($_.BaseName) [AS2Outbound_SuccessEmail]".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - - $sourceAS2Outbound_SuccessEmail = Import-Clixml $AS2Outbound_SuccessEmail_Path - $targetAS2Outbound_SuccessEmail = $detail.AS2OutboundSettings.GetSuccessEmail() - - $sourceHash = -join ( $sourceAS2Outbound_SuccessEmail | Select-Object * ) - $targetHash = -join ( $targetAS2Outbound_SuccessEmail | Select-Object * ) - - try { - $sourceHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($sourceHash))) | Select-Object -ExpandProperty Hash - $targetHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($targetHash))) | Select-Object -ExpandProperty Hash - } - catch { - $sourceHash = 1; $targetHash = 2 - } - if ($sourceHash -ne $targetHash) { - #$connectionProfileParams = $objParams - ParseValues $sourceAS2Outbound_SuccessEmail $targetAS2Outbound_SuccessEmail - $detail.AS2OutboundSettings.SetSuccessEmail($targetAS2Outbound_SuccessEmail) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - else { - Write-host " SAME ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - } - } - } - } - } - - Write-host "" - Write-host "[Connection Profiles]" - if (Test-Path "$BuildFolder\$EFTSiteName\connection_profiles\") { - Get-ChildItem "$BuildFolder\$EFTSiteName\connection_profiles\" -Filter *.xml | - Foreach-Object { - - Write-Host "Importing: $($_.BaseName)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $objParams = Import-Clixml $_.FullName - $index = -1 - try { - # $workflowIndex = $EFTSite.GetAdvancedWorkflowIndex($objParams.Name) - - for ($i = 0; $i -lt $EFTSite.GetConnectionProfilesCount(); $i++) { - if ($objParams.Name -eq $EFTSite.GetConnectionProfileParams($i).Name) { - $index = $i; - } - } - # Importing connection profile - if ($index -gt -1) { - # Updating connection profile - $connectionProfileParams = $EFTSite.GetConnectionProfileParams($index) - } - else { - # Adding Workflow - $connectionProfileParams = new-object -ComObject "SFTPCOMInterface.CIConnectionProfileParams" - } - - $sourceHash = -join ( $objParams | Select-Object * -ExcludeProperty DateCreated ) - $targetHash = -join ( $connectionProfileParams | Select-Object * -ExcludeProperty DateCreated) - try { - $sourceHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($sourceHash))) | Select-Object -ExpandProperty Hash - $targetHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($targetHash))) | Select-Object -ExpandProperty Hash - } - catch { - $sourceHash = 1 - $targetHash = 2 - } - if ($sourceHash -ne $targetHash) { - #$connectionProfileParams = $objParams - ParseValues $objParams $connectionProfileParams - if ($objParams.UseProxy) { - $connectionProfileParams.ProxyType = $objParams.ProxyType - } - If ($index -lt 0) { - $connectionProfileIndex = $eftsite.AddConnectionProfile($connectionProfileParams) - } - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - else { - Write-host " SAME ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - } - } - catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - } - } - } - - if (Test-Path "$BuildFolder\$EFTSiteName\event_rules\") { - - $EventFolders = $null - $EFTUsingFolders = $false - try { - $EventFolders = $EFTsite.EventRuleFolders() - $EFTUsingFolders = $true - } - catch { - Write-verbose "Event Rule folders feature not found via COM" - } - - ## creating Folders on EFT - if ($EFTUsingFolders) { - Write-host "" - Write-host "[Event Rules Folders]" - if (Test-Path "$BuildFolder\$EFTSiteName\event_rules\") { - Get-ChildItem "$BuildFolder\$EFTSiteName\event_rules\" -Directory | - Foreach-Object { - $EventFolderName = $_.BaseName - - $sw.Restart() - $EventFolder = $EventFolders.Find($EventFolderName) - If ($null -eq $EventFolder) { - Write-host "Creating: $EventFolderName".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - - $EventFolders.Add($EventFolders.Count(), $EventFolderName) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - } - } - } - - - ## SubFolders if any - if ($EFTUsingFolders) { - - Write-host "" - Write-host "[Event Rules in Folder]" - - Get-ChildItem "$BuildFolder\$EFTSiteName\event_rules\" -Directory | - Foreach-Object { - $EventFolderName = $_.BaseName - Get-ChildItem "$BuildFolder\$EFTSiteName\event_rules\$EventFolderName" -Filter *.xml | - Foreach-Object { - try { - $EventFolder = $EventFolders.Find($EventFolderName) - $EventRuleName = $_.BaseName - - # Delete event Rule if is found on EFT - $sw.Restart() - $isDeleted = $false - for ($i = 0 ; $i -le $eventTypes.Length - 1 ; $i++) { - $currentEventType = $eventTypes[$i].type - #$currentEventTypeName = $eventTypes[$i].Name - $eventRules = $EFTSite.EventRules($currentEventType) - for ($j = 0 ; $j -le $eventRules.Count() - 1 ; $j++ ) { - $eventRule = $eventRules.Item($j) - #Write-Host "Base filename:$($_.BaseName)" - if ($EventRuleName -eq $eventRule.GetParams().Name) { - Write-host "Deleting: $($_.BaseName)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $eventRules.Delete($j) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - $isDeleted = $true - break - } - } - if ($isDeleted) { - break - } - } - - # Import Event Rule into EFT - # Importing Event Rules - Write-host "Importing: $EventFolderName/$EventRuleName".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - # Adding Event Rule - $EventFolder.Import($_.FullName) - $xml = [xml](Get-Content $_.FullName) - if ($xml.root.EventRulesList.Item.Name -ne $_.BaseName) { - RenameEventRule $_.BaseName $xml.root.EventRulesList.Item.Name - } - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-Host "Exception : $_" -ForegroundColor Red - } - } - - } - - } - exit - Write-host "" - Write-host "[Event Rules]" - ## Root folder - Get-ChildItem "$BuildFolder\$EFTSiteName\event_rules\" -Filter *.xml | - Foreach-Object { - - ## Used when Event Rules Folders doesn't exist - $isDeleted = $false - try { - # Delete event Rule if is found on EFT - $sw.Restart() - for ($i = 0 ; $i -le $eventTypes.Length - 1 ; $i++) { - $currentEventType = $eventTypes[$i].type - #$currentEventTypeName = $eventTypes[$i].Name - $eventRules = $EFTSite.EventRules($currentEventType) - for ($j = 0 ; $j -le $eventRules.Count() - 1 ; $j++ ) { - $eventRule = $eventRules.Item($j) - #Write-Host "Base filename:$($_.BaseName)" - if ($_.BaseName -eq $eventRule.GetParams().Name) { - Write-host "Deleting: $($_.BaseName)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $eventRules.Delete($j) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - $isDeleted = $true - break - } - } - if ($isDeleted) { - break - } - } - - # Import Event Rule into EFT - # Importing Event Rules - Write-host "Importing: $($_.BaseName)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - # Adding Event Rule - $EFTSite.ImportEventRules($_.FullName) - - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_CANNOT_IMPORT_EVENT_RULE { Write-host "MXE_CANNOT_IMPORT_EVENT_RULE : $_ " -ForegroundColor Red } - $MXE_INVALID_CONNECTION_PROFILE_DATA { Write-host "MXE_INVALID_CONNECTION_PROFILE_DATA : $_ " -ForegroundColor Red } - Default { Write-host "Exception : $_" -ForegroundColor Red } - } - Write-Host "Exception : $_" -ForegroundColor Red - } - - } - } -} - -$EFTSite = $null -$EFTSites = $null -$EFTServer.Close() -$EFTServer = $null - - - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-AWEParams.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-AWEParams.ps1 deleted file mode 100644 index 36e623c..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-AWEParams.ps1 +++ /dev/null @@ -1,300 +0,0 @@ -## -## 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. - -<# - .SYNOPSIS - Exports Execute AWE actions and its parameters used in event rules. - .DESCRIPTION - This script return Execute AWE actions and its parameters used in event rules for all or a specific EFT site - .EXAMPLE - .\EFT.EventRules.Export-AWEParams.ps1 | Export-Csv .\AWEParams_Report.csv -NoTypeInformation - - Export actions with Execute AWE action in event rules for all sites into a CSV file - This commands will connect to an EFT server listening in localhost using port 1100 and using - the current windows login credentials -#> -[CmdletBinding()] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password - -) - -function GetValue($value) { - if ($value -is [array]) { - return $value -join "|" - } - return $value -} -Function GetPropertyName ($EventProperty) { - switch ($EventProperty) { - 1003 { return "ServerLogOldPath" } - 1004 { return "ServerLogNewPath" } - 1006 { return "ServerLogFolder" } - 3006 { return "HttpQueryString" } - 3007 { return "HttpHeadersList" } - 5000 { return "VirtualPath" } - 5001 { return "PhysicalPath" } - 5003 { return "DestinationPhysicalPath" } - 5004 { return "FolderName" } - 5005 { return "FileName" } - 5006 { return "DestinationFolderName" } - 5007 { return "DestinationFileName" } - 5013 { return "ReportPath" } - 5015 { return "ReportFileName" } - 5016 { return "VirtualFolderName" } - 5017 { return "BaseFileName" } - 5018 { return "FileFolderExists" } - 5019 { return "CompressedPhysicalPath" } - 5020 { return "CompressedFileName" } - 5021 { return "CompressedBaseFileName" } - 7000 { return "WSVirtualPath" } - 7001 { return "WSPhysicalPath" } - 8000 { return "ContextVariable" } - } -} -Function GetOperationName ($Operation) { - switch ($Operation) { - 0 { return "Encrypt" } - 1 { return "EncryptAndSign" } - 2 { return "Sign" } - 3 { return "SDA" } - 4 { return "Decrypt" } - 5 { return "DecryptAndVerify" } - 6 { return "VerifyOnly" } - } -} -Function GetActionName ($EventActionType) { - switch ($EventActionType) { - 1 { return "CommandAction" } - 2 { return "MailAction" } - 4 { return "UploadAction" } - 8 { return "DownloadAction" } - 32 { return "PGPAction" } - 64 { return "StopAction" } - 128 { return "CleanupAction" } - 256 { return "ReportAction" } - 512 { return "AS2SendAction" } - 1024 { return "AWTaskAction" } - 2048 { return "BackupAction" } - 4096 { return "WindowsEventLog" } - 8192 { return "ContentIntegrityControl" } - 16384 { return "FolderAction" } - 32768 { return "FileAction" } - 65536 { return "CompressAction" } - 262144 { return "WebServiceAction" } - 524288 { return "CloudUploadAction" } - 1048576 { return "CloudDownloadAction" } - } -} - -function ExportAWEParamsInAction ($SiteName, $EventRule, $Trigger, $StatementPosition, $ActionPosition, $IsElse, $action, $IsFailAction, $FailActionPosition) { - $objParams = $EventRule.GetParams() - $results = @() - if ($action.type -ne $AWEACTION) { - return $results - } - $actionParams = $action.GetParams() # CIAWTaskActionParams - - switch ($action.type) { - $AWEACTION { - $VariablesCount = $actionParams.VariablesCount - if ($VariablesCount -eq 0) { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - TaskName = $actionParams.TaskName; - VariableName = ""; - VariableValue = ""; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - } - else { - for ($j = 0 ; $j -le $VariablesCount - 1 ; $j++) { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - TaskName = $actionParams.TaskName; - VariableName = $actionParams.GetVariableName($j); - VariableValue = $actionParams.GetVariableValue($j); - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - } - } - } - } - return $results -} - -function ProcessActionStatement ($SiteName, $EventRule, $Trigger, $StatementPosition, $ActionStatement , $ActionPosition, $IsElse) { - #$objParams = $EventRule.GetParams() - $action = $ActionStatement.Action() - - $results = @() - - $results += ExportAWEParamsInAction -SiteName $SiteName -EventRule $EventRule -Trigger $Trigger -StatementPosition $StatementPosition -ActionPosition $ActionPosition -action $action -IsElse $IsElse -IsFailAction 0 -FailActionPosition 0 - - #process additional Actions in the Fail Section - $failSection = $ActionStatement.FailSection() - # Fail Action Section - if ($null -ne $failSection) { - for ($indexfail = 0; $indexfail -le $failSection.Count() - 1 ; $indexfail++ ) { - $failaction = $failSection.item($indexfail) - - $script:Line++ - $results += ExportAWEParamsInAction -SiteName $SiteName -EventRule $EventRule -Trigger $Trigger -StatementPosition $StatementPosition -ActionPosition $ActionPosition -action $failaction -IsElse $IsElse -IsFailAction 1 -FailActionPosition $indexfail - - } - } - return $results - -} -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null -$script:Line = 0 - -$AWEACTION = 1024 - -$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) - - $EventType = $script:EftServer.AvailableEvents - foreach ($eventtype in $EventType) { - Write-Progress -Activity "Processing Event Rules" -status "$($eventType.Name)" -percentComplete -1 - Try { - $eRules = $script:eftsite.EventRules($eventType.type) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "COM Exception : $error[0]" -ForegroundColor Magenta - } - If ($erules) { - If ($eRules.Count() -gt 0) { - For ($iRule = 0; $iRule -lt $eRules.Count(); $iRule++) { - Write-Progress -Activity "Processing Event Rules" -status "Event Rule $iRule/$($eRules.Count())" -percentComplete ($iRule / $eRules.Count() * 100) - $objEvent = $eRules.Item($iRule) - $Trigger = $eventType.Name - - $totalStatements = $objEvent.StatementsCount() - $script:Line = 0 - for ($StatementPosition = 0; $StatementPosition -le $totalStatements - 1 ; $StatementPosition++) { - $statement = $objEvent.statement($StatementPosition) - - if ($statement.type -eq 0) { - # statement is ActionStatement - $actionStatement = $statement - $script:Line++ - $results += ProcessActionStatement -sitename $SiteName -EventRule $objEvent -Trigger $Trigger -ActionStatement $actionStatement -StatementPosition $StatementPosition -ActionPosition 0 -IsElse 0 - - } - else { - $script:Line++ - # statement is ConditionStatement - $ifActions = $statement.IfSection # CIActionStatements - $elseActions = $statement.ElseSection # CIActionStatements - #Actions in If section - if ($null -ne $ifActions ) { - for ($indexAction = 0; $indexAction -le $ifActions.Count() - 1 ; $indexAction++ ) { - #process Action statement - $actionStatement = $ifActions.item($indexAction) - $script:Line++ - if ($actionStatement.type -eq 0) { - # statement is ActionStatement - $results += ProcessActionStatement -sitename $SiteName -EventRule $objEvent -Trigger $Trigger -ActionStatement $actionStatement -StatementPosition $StatementPosition -ActionPosition $indexAction -IsElse 0 - } - } - } - - #Actions in Else section - if ($null -ne $elseActions ) { - $script:Line++ - for ($indexAction = 0; $indexAction -le $elseActions.Count() - 1 ; $indexAction++ ) { - #process Action statement - $actionStatement = $elseActions.item($indexAction) - $script:Line++ - if ($actionStatement.type -eq 0) { - # statement is ActionStatement - $results += ProcessActionStatement -sitename $SiteName -EventRule $objEvent -Trigger $Trigger -ActionStatement $actionStatement -StatementPosition $StatementPosition -ActionPosition $indexAction -IsElse 1 - } - } - } - } - } - } - } - } - } -} -try { - for ($i = 0 ; $i -le $results.count - 1; $i++) { - $u = $results[$i] - #Concatenate all columns except the mentioned in the ExcludedProperty - $Hash = -join ( $u | Select-Object * -ExcludeProperty SiteName, CheckSum) - $Hash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($Hash))) | Select-Object -ExpandProperty Hash - $results[$i].CheckSum = $Hash - } -} -catch { - $results[$i].CheckSum = "NA" -} -$script:EftServer.close() - -$results | Sort-Object SiteName, Trigger, EventRuleName - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-ConnectionProfilesInActions.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-ConnectionProfilesInActions.ps1 deleted file mode 100644 index 0a37611..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-ConnectionProfilesInActions.ps1 +++ /dev/null @@ -1,303 +0,0 @@ -## -## 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. - -<# - .SYNOPSIS - Exports actions and its connection profiles used in event rules. - .DESCRIPTION - This script return actions and its connection profiles used in event rules for all or a specific EFT site - .EXAMPLE - .\EFT.EventRules.Export-ConnectionProfilesInActions.ps1 | Export-Csv .\ProfilesInActions_Report.csv -NoTypeInformation - - Export actions with connection profiles in event rules for all sites into a CSV file - This commands will connect to an EFT server listening in localhost using port 1100 and using - the current windows login credentials - - .EXAMPLE - .\EFT.EventRules.Export-ConnectionProfilesInActions.ps1 -EFTAdminHostName 127.0.0.1 -EFTAdminPort 1100 -EFTAdminAuthType 0 -EFTAdminUsername myusername -Password Mypassword | Export-Csv .\PathsInActions_Report.csv -NoTypeInformation - - Export actions with connection profiles in event rules for all sites into a CSV file - This commands will connect to an EFT server listening in 127.0.0.1 using port 1100 and using EFT Admin credentials myusername/mypassword - -#> -[CmdletBinding()] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password - -) - -function GetValue($value) { - if ($value -is [array]) { - return $value -join "|" - } - return $value -} -Function GetPropertyName ($EventProperty) { - switch ($EventProperty) { - 1003 { return "ServerLogOldPath"} - 1004 { return "ServerLogNewPath"} - 1006 { return "ServerLogFolder"} - 3006 { return "HttpQueryString"} - 3007 { return "HttpHeadersList"} - 5000 { return "VirtualPath"} - 5001 { return "PhysicalPath"} - 5003 { return "DestinationPhysicalPath"} - 5004 { return "FolderName"} - 5005 { return "FileName"} - 5006 { return "DestinationFolderName"} - 5007 { return "DestinationFileName"} - 5013 { return "ReportPath"} - 5015 { return "ReportFileName"} - 5016 { return "VirtualFolderName"} - 5017 { return "BaseFileName"} - 5018 { return "FileFolderExists"} - 5019 { return "CompressedPhysicalPath"} - 5020 { return "CompressedFileName"} - 5021 { return "CompressedBaseFileName"} - 7000 { return "WSVirtualPath"} - 7001 { return "WSPhysicalPath"} - 8000 { return "ContextVariable"} - } -} -Function GetOperationName ($Operation) { - switch ($Operation) { - 0 { return "Encrypt"} - 1 { return "EncryptAndSign"} - 2 { return "Sign"} - 3 { return "SDA"} - 4 { return "Decrypt"} - 5 { return "DecryptAndVerify"} - 6 { return "VerifyOnly"} - } -} -Function GetActionName ($EventActionType) { - switch ($EventActionType) { - 1 { return "CommandAction"} - 2 { return "MailAction"} - 4 { return "UploadAction"} - 8 { return "DownloadAction"} - 32 { return "PGPAction"} - 64 { return "StopAction"} - 128 { return "CleanupAction"} - 256 { return "ReportAction"} - 512 { return "AS2SendAction"} - 1024 { return "AWTaskAction"} - 2048 { return "BackupAction"} - 4096 { return "WindowsEventLog"} - 8192 { return "ContentIntegrityControl"} - 16384 { return "FolderAction"} - 32768 { return "FileAction"} - 65536 { return "CompressAction"} - 262144 { return "WebServiceAction"} - 524288 { return "CloudUploadAction"} - 1048576 { return "CloudDownloadAction"} - } -} - -function ExportConnectionProfileInAction ($SiteName, $EventRule, $Trigger, $StatementPosition, $ActionPosition, $IsElse, $action, $IsFailAction, $FailActionPosition) { - $objParams = $EventRule.GetParams() - $results = @() - if ($action.type -ne $UPLOADACTION -and $action.type -ne $DOWNLOADACTION) - { - return $results - } - $actionParams = $action.GetParams() - - - switch ($action.type) { - $UPLOADACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "ConnectionProfileName" - ActionValue = $actionParams.ConnectionProfileName; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - } - $DOWNLOADACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "ConnectionProfileName" - ActionValue = $actionParams.ConnectionProfileName; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - } - } - return $results -} - -function ProcessActionStatement ($SiteName, $EventRule, $Trigger, $StatementPosition, $ActionStatement , $ActionPosition, $IsElse) { - #$objParams = $EventRule.GetParams() - $action = $ActionStatement.Action() - - $results = @() - - $results += ExportConnectionProfileInAction -SiteName $SiteName -EventRule $EventRule -Trigger $Trigger -StatementPosition $StatementPosition -ActionPosition $ActionPosition -action $action -IsElse $IsElse -IsFailAction 0 -FailActionPosition 0 - - #process additional Actions in the Fail Section - $failSection = $ActionStatement.FailSection() - # Fail Action Section - if ($null -ne $failSection) { - for ($indexfail = 0; $indexfail -le $failSection.Count() - 1 ; $indexfail++ ) { - $failaction = $failSection.item($indexfail) - - $script:Line++ - $results += ExportConnectionProfileInAction -SiteName $SiteName -EventRule $EventRule -Trigger $Trigger -StatementPosition $StatementPosition -ActionPosition $ActionPosition -action $failaction -IsElse $IsElse -IsFailAction 1 -FailActionPosition $indexfail - - } - } - return $results - -} -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null -$script:Line = 0 - -$UPLOADACTION = 4 -$DOWNLOADACTION = 8 - -$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) - - $EventType = $script:EftServer.AvailableEvents - foreach ($eventtype in $EventType) { - Write-Progress -Activity "Processing Event Rules" -status "$($eventType.Name)" -percentComplete -1 - Try { - $eRules = $script:eftsite.EventRules($eventType.type) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "COM Exception : $error[0]" -ForegroundColor Magenta - } - If ($erules) { - If ($eRules.Count() -gt 0) { - For ($iRule = 0; $iRule -lt $eRules.Count(); $iRule++) { - Write-Progress -Activity "Processing Event Rules" -status "Event Rule $iRule/$($eRules.Count())" -percentComplete ($iRule / $eRules.Count() * 100) - $objEvent = $eRules.Item($iRule) - $Trigger = $eventType.Name - - $totalStatements = $objEvent.StatementsCount() - $script:Line = 0 - for ($StatementPosition = 0; $StatementPosition -le $totalStatements - 1 ; $StatementPosition++) { - $statement = $objEvent.statement($StatementPosition) - - if ($statement.type -eq 0) { - # statement is ActionStatement - $actionStatement = $statement - $script:Line++ - $results += ProcessActionStatement -sitename $SiteName -EventRule $objEvent -Trigger $Trigger -ActionStatement $actionStatement -StatementPosition $StatementPosition -ActionPosition 0 -IsElse 0 - - } - else { - $script:Line++ - # statement is ConditionStatement - $ifActions = $statement.IfSection # CIActionStatements - $elseActions = $statement.ElseSection # CIActionStatements - #Actions in If section - if ($null -ne $ifActions ) { - for ($indexAction = 0; $indexAction -le $ifActions.Count() - 1 ; $indexAction++ ) { - #process Action statement - $actionStatement = $ifActions.item($indexAction) - $script:Line++ - if ($actionStatement.type -eq 0) { - # statement is ActionStatement - $results += ProcessActionStatement -sitename $SiteName -EventRule $objEvent -Trigger $Trigger -ActionStatement $actionStatement -StatementPosition $StatementPosition -ActionPosition $indexAction -IsElse 0 - } - } - } - - #Actions in Else section - if ($null -ne $elseActions ) { - $script:Line++ - for ($indexAction = 0; $indexAction -le $elseActions.Count() - 1 ; $indexAction++ ) { - #process Action statement - $actionStatement = $elseActions.item($indexAction) - $script:Line++ - if ($actionStatement.type -eq 0) { - # statement is ActionStatement - $results += ProcessActionStatement -sitename $SiteName -EventRule $objEvent -Trigger $Trigger -ActionStatement $actionStatement -StatementPosition $StatementPosition -ActionPosition $indexAction -IsElse 1 - } - } - } - } - } - } - } - } - } -} -try { - for ($i = 0 ; $i -le $results.count - 1; $i++) { - $u = $results[$i] - #Concatenate all columns except the mentioned in the ExcludedProperty - $Hash = -join ( $u | Select-Object * -ExcludeProperty SiteName, CheckSum) - $Hash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($Hash))) | Select-Object -ExpandProperty Hash - $results[$i].CheckSum = $Hash - } -} -catch { - $results[$i].CheckSum = "NA" -} -$script:EftServer.close() - -$results | Sort-Object SiteName, Trigger, EventRuleName - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-HostNamesInActions.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-HostNamesInActions.ps1 deleted file mode 100644 index 4f3c68d..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-HostNamesInActions.ps1 +++ /dev/null @@ -1,508 +0,0 @@ -## -## 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. - -<# - .SYNOPSIS - Exports Hostnames used in event rules actions. - .DESCRIPTION - This script return hostnames used in event rules actions for all or a specific EFT site - .EXAMPLE - .\EFT.EventRules.Export-HostNamesInActions.ps1 | Export-Csv .\HostnamesInActions_Report.csv -NoTypeInformation - - Export all Paths in actions in the event rules for all sites into a CSV file - This commands will connect to an EFT server listening in localhost using port 1100 and using - the current windows login credentials - - .EXAMPLE - .\EFT.EventRules.Export-HostNamesInActions.ps1 -EFTAdminHostName 127.0.0.1 -EFTAdminPort 1100 -EFTAdminAuthType 0 -EFTAdminUsername myusername -Password Mypassword | Export-Csv .\PathsInActions_Report.csv -NoTypeInformation - - Export all Paths in actions in the event rules for all sites into a CSV file - This commands will connect to an EFT server listening in 127.0.0.1 using port 1100 and using EFT Admin credentials myusername/mypassword - -#> -[CmdletBinding()] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password - -) -function GetValue($value) { - if ($value -is [array]) { - return $value -join "|" - } - return $value -} -Function GetPropertyName ($EventProperty) { - switch ($EventProperty) { - 1003 { return "ServerLogOldPath"} - 1004 { return "ServerLogNewPath"} - 1006 { return "ServerLogFolder"} - 3006 { return "HttpQueryString"} - 3007 { return "HttpHeadersList"} - 5000 { return "VirtualPath"} - 5001 { return "PhysicalPath"} - 5003 { return "DestinationPhysicalPath"} - 5004 { return "FolderName"} - 5005 { return "FileName"} - 5006 { return "DestinationFolderName"} - 5007 { return "DestinationFileName"} - 5013 { return "ReportPath"} - 5015 { return "ReportFileName"} - 5016 { return "VirtualFolderName"} - 5017 { return "BaseFileName"} - 5018 { return "FileFolderExists"} - 5019 { return "CompressedPhysicalPath"} - 5020 { return "CompressedFileName"} - 5021 { return "CompressedBaseFileName"} - 7000 { return "WSVirtualPath"} - 7001 { return "WSPhysicalPath"} - 8000 { return "ContextVariable"} - } -} -function GetProtocolName ($EventProperty) { - switch ($EventProperty) { - 1073741829 { return "ProtocolFASTAST"} - 0 { return "ProtocolFTP"} - 1 { return "ProtocolFTPS"} - 8 { return "ProtocolFTPSAuthTLS"} - 2 { return "ProtocolFTPSExpl"} - 4 { return "ProtocolHTTP "} - 5 { return "ProtocolHTTPS"} - -1 { return "ProtocolLocal"} - 3 { return "ProtocolSFTP"} - } - -} -Function GetActionName ($EventActionType) { - switch ($EventActionType) { - 1 { return "CommandAction"} - 2 { return "MailAction"} - 4 { return "UploadAction"} - 8 { return "DownloadAction"} - 32 { return "PGPAction"} - 64 { return "StopAction"} - 128 { return "CleanupAction"} - 256 { return "ReportAction"} - 512 { return "AS2SendAction"} - 1024 { return "AWTaskAction"} - 2048 { return "BackupAction"} - 4096 { return "WindowsEventLog"} - 8192 { return "ContentIntegrityControl"} - 16384 { return "FolderAction"} - 32768 { return "FileAction"} - 65536 { return "CompressAction"} - 262144 { return "WebServiceAction"} - 524288 { return "CloudUploadAction"} - 1048576 { return "CloudDownloadAction"} - } -} - -function ExportHostnameInAction ($SiteName, $EventRule, $Trigger, $StatementPosition, $ActionPosition, $IsElse, $action, $IsFailAction, $FailActionPosition) { - $objParams = $EventRule.GetParams() - $actionParams = $action.GetParams() - $results = @() - - switch ($action.type) { - - $UPLOADACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Host" - ActionValue = $actionParams.Host; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "User" - ActionValue = $actionParams.User; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - $results += new-object psobject -Property @{ - Line = $script:Line; - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Port" - ActionValue = $actionParams.Port; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Password" - ActionValue = $actionParams.Password; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - $results += new-object psobject -Property @{ - Line = $script:Line; - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Protocol" - ActionValue = GetProtocolName($actionParams.Protocol); - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - } - $DOWNLOADACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Host" - ActionValue = $actionParams.Host; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "User" - ActionValue = $actionParams.User; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Password" - ActionValue = $actionParams.Password; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "PrivateKeyPath" - ActionValue = $actionParams.PrivateKeyPath; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Port" - ActionValue = $actionParams.Port; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - } - $AS2SENDACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Host" - ActionValue = $actionParams.Host; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "User" - ActionValue = $actionParams.User; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Port" - ActionValue = $actionParams.Port; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - } - $CONTENTINTEGRITYCONTROL { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Host" - ActionValue = $actionParams.Host; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Port" - ActionValue = $actionParams.User; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - } - - $WEBSERVICEACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "URL" - ActionValue = $actionParams.URL; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - CheckSum = ""; - } - } - $CLOUDUPLOADACTION { - - } - $CLOUDDOWNLOADACTION { - - } - } - return $results -} - -function ProcessActionStatement ($SiteName, $EventRule, $Trigger, $StatementPosition, $ActionStatement , $ActionPosition, $IsElse) { - #$objParams = $EventRule.GetParams() - $action = $ActionStatement.Action() - - $results = @() - $results += ExportHostnameInAction -SiteName $SiteName -EventRule $EventRule -Trigger $Trigger -StatementPosition $StatementPosition -ActionPosition $ActionPosition -action $action -IsElse $IsElse -IsFailAction 0 -FailActionPosition 0 - - #process additional Actions in the Fail Section - $failSection = $ActionStatement.FailSection() - # Fail Action Section - if ($null -ne $failSection) { - for ($indexfail = 0; $indexfail -le $failSection.Count() - 1 ; $indexfail++ ) { - $failaction = $failSection.item($indexfail) - $script:Line++ - $results += ExportHostnameInAction -SiteName $SiteName -EventRule $EventRule -Trigger $Trigger -StatementPosition $StatementPosition -ActionPosition $ActionPosition -action $failaction -IsElse $IsElse -IsFailAction 1 -FailActionPosition $indexfail - } - } - return $results - -} -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null -$script:Line = 0 - -$UPLOADACTION = 4 -$DOWNLOADACTION = 8 -$AS2SENDACTION = 512 -$WEBSERVICEACTION = 262144 -$CLOUDUPLOADACTION = 524288 -$CLOUDDOWNLOADACTION = 1048576 - -$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) - - $EventType = $script:EftServer.AvailableEvents - foreach ($eventtype in $EventType) { - Write-Progress -Activity "Processing Event Rules" -status "$($eventType.Name)" -percentComplete -1 - Try { - $eRules = $script:eftsite.EventRules($eventType.type) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "COM Exception : $error[0]" -ForegroundColor Magenta - } - If ($erules) { - If ($eRules.Count() -gt 0) { - For ($iRule = 0; $iRule -lt $eRules.Count(); $iRule++) { - Write-Progress -Activity "Processing Event Rules" -status "Event Rule $iRule/$($eRules.Count())" -percentComplete ($iRule / $eRules.Count() * 100) - $objEvent = $eRules.Item($iRule) - $Trigger = $eventType.Name - - $totalStatements = $objEvent.StatementsCount() - $script:Line = 0 - for ($StatementPosition = 0; $StatementPosition -le $totalStatements - 1 ; $StatementPosition++) { - $statement = $objEvent.statement($StatementPosition) - if ($statement.type -eq 0) { - # statement is ActionStatement - $actionStatement = $statement - $script:Line++ - $results += ProcessActionStatement -sitename $SiteName -EventRule $objEvent -Trigger $Trigger -ActionStatement $actionStatement -StatementPosition $StatementPosition -ActionPosition 0 -IsElse 0 - - } - else { - $ConditionStatement = $statement.Condition - $script:Line++ - # statement is ConditionStatement - $ifActions = $statement.IfSection # CIActionStatements - $elseActions = $statement.ElseSection # CIActionStatements - #Actions in If section - if ($null -ne $ifActions ) { - - for ($indexAction = 0; $indexAction -le $ifActions.Count() - 1 ; $indexAction++ ) { - #process Action statement - $actionStatement = $ifActions.item($indexAction) - $script:Line++ - if ($actionStatement.type -eq 0) { - # statement is ActionStatement - $results += ProcessActionStatement -sitename $SiteName -EventRule $objEvent -Trigger $Trigger -ActionStatement $actionStatement -StatementPosition $StatementPosition -ActionPosition $indexAction -IsElse 0 - } - } - } - - #Actions in Else section - if ($null -ne $elseActions ) { - $script:Line++ - for ($indexAction = 0; $indexAction -le $elseActions.Count() - 1 ; $indexAction++ ) { - #process Action statement - $actionStatement = $elseActions.item($indexAction) - $script:Line++ - if ($actionStatement.type -eq 0) { - # statement is ActionStatement - $results += ProcessActionStatement -sitename $SiteName -EventRule $objEvent -Trigger $Trigger -ActionStatement $actionStatement -StatementPosition $StatementPosition -ActionPosition $indexAction -IsElse 1 - } - } - } - } - } - - - # $results += new-object psobject -Property @{ - # SiteName = $siteName; EventRuleName = $EventRuleName; Trigger = $eventType.Name; Enabled = $Enabled; Comments = $Comments; - # EmailNotifications_Actions = $EmailNotifications_Actions; EmailNotifications_FailedActions = $EmailNotifications_FailedActions; - # PGP_Key_Name = $PGP_Key_Name; PGP_Description = $PGP_Description; PGP_Size = $PGP_Size; - # PGP_Key_Expiration = $PGP_Key_Expiration; PGP_Fingerprint = $PGP_Fingerprint; PGP_CreatedOn = $PGP_CreatedOn; - # CheckSum = ""; - # } - - } - } - } - } -} -try { - for ($i = 0 ; $i -le $results.count - 1; $i++) { - $u = $results[$i] - #Concatenate all columns except the mentioned in the ExcludedProperty - $Hash = -join ( $u | Select-Object * -ExcludeProperty SiteName, CheckSum) - $Hash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($Hash))) | Select-Object -ExpandProperty Hash - $results[$i].CheckSum = $Hash - } -} -catch { - $results[$i].CheckSum = "NA" -} -$script:EftServer.close() - -$results | Sort-Object SiteName, Trigger, EventRuleName - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-PGPKeysUsed.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-PGPKeysUsed.ps1 deleted file mode 100644 index ffe46b6..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-PGPKeysUsed.ps1 +++ /dev/null @@ -1,322 +0,0 @@ -## -## 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. - -<# - .SYNOPSIS - Exports PGP keys used in evet rules with its associated metadata. - .DESCRIPTION - This script will retrieve all PGP Keys used from all the event rules for all or a specific EFT site - .EXAMPLE - .\EFT.EventRules.Export-PGPKeysUsed.ps1 | Export-Csv .\PGPKeysUsed_Report.csv -NoTypeInformation - - Export all PGP Keys used for all sites into a CSV file - This commands will connect to an EFT server listening in localhost using port 1100 and using - the current windows login credentials - - .EXAMPLE - .\EFT.EventRules.Export-PGPKeysUsed.ps1 -EFTAdminHostName 127.0.0.1 -EFTAdminPort 1100 -EFTAdminAuthType 0 -EFTAdminUsername myusername -Password Mypassword | Export-Csv .\PGPKeysUsed_Report.csv -NoTypeInformation - - Export all PGP Keys used for all sites into a CSV file - This commands will connect to an EFT server listening in 127.0.0.1 using port 1100 and using EFT Admin credentials myusername/mypassword - -#> -[CmdletBinding()] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password - -) -function GetEmailNotificationNextAction ( $Action) { - $EmailNotifications_Actions = "" - if ( $Action.type -eq $MailAction) { - $actionParams = $Action.GetParams() #CIMailActionParams - $EmailNotifications_Actions += $actionParams.TOAddresses + ';' + $actionParams.CCAddresses + ";" + $actionParams.BCCAddresses - } - - return $EmailNotifications_Actions -} -Function GetOperationName ($Operation){ - # Encrypt = 0, - # EncryptAndSign = 1, - # Sign = 2, - # SDA = 3, - # Decrypt = 4, - # DecryptAndVerify = 5, - # VerifyOnly = 6 - switch ($Operation){ - 0 { return "Encrypt"} - 1 { return "EncryptAndSign"} - 2 { return "Sign"} - 3 { return "SDA"} - 4 { return "Decrypt"} - 5 { return "DecryptAndVerify"} - 6 { return "VerifyOnly"} - } -} - -function ExportPGPAction ($SiteName, $objEvent, $Trigger, $action, $EmailNotifications_Actions, $EmailNotifications_FailedActions) { - $objParams = $objEvent.GetParams() - $actionParams = $action.GetParams() - $results = @() - - if ($actionParams.Operation -eq 1 -or $actionParams.Operation -eq 2 -or $actionParams.Operation -eq 5 -or $actionParams.Operation -eq 6 ){ - $PGP_SignKey_Fingerprint = $actionParams.SignKeyID - $PGP_SignKey_Name = "" - $PGP_SignKey_Description ="" - $PGP_SignKey_Size = "" - $PGP_SignKey_Expiration = "" - $PGP_SignKey_CreatedOn = "" - $PGP_SignKey_IsPrivate = "" - - $PGP_SignKey_Name = $PgpKeyRing | Where-Object {$_.ID -eq $PGP_SignKey_Fingerprint} | Select-Object Name -ExpandProperty Name - $PGP_SignKey_Description = $PgpKeyRing | Where-Object {$_.ID -eq $PGP_SignKey_Fingerprint} | Select-Object Description -ExpandProperty Description - $PGP_SignKey_Size = $PgpKeyRing | Where-Object {$_.ID -eq $PGP_SignKey_Fingerprint} |Select-Object Size -ExpandProperty Size - $PGP_SignKey_Expiration = $PgpKeyRing | Where-Object {$_.ID -eq $PGP_SignKey_Fingerprint} | Select-Object ExpirationDate -ExpandProperty ExpirationDate - $PGP_SignKey_CreatedOn = $PgpKeyRing | Where-Object {$_.ID -eq $PGP_SignKey_Fingerprint} | Select-Object CreationDate -ExpandProperty CreationDate - $PGP_SignKey_IsPrivate = $PgpKeyRing | Where-Object {$_.ID -eq $PGP_SignKey_Fingerprint} | Select-Object IsPrivate -ExpandProperty IsPrivate - } - foreach ($key in $actionParams.KeyIDs ) { - $PGP_Key_Fingerprint = $key - - $PGP_Key_Name = "" - $PGP_Key_Description ="" - $PGP_Key_Size = "" - $PGP_Key_Expiration ="" - $PGP_Key_CreatedOn = "" - $PGP_Key_IsPrivate = "" - - $PGP_Key_Name = $PgpKeyRing | Where-Object {$_.ID -eq $PGP_Key_Fingerprint} | Select-Object Name -ExpandProperty Name - $PGP_Key_Description = $PgpKeyRing | Where-Object {$_.ID -eq $PGP_Key_Fingerprint} | Select-Object Description -ExpandProperty Description - $PGP_Key_Size = $PgpKeyRing | Where-Object {$_.ID -eq $PGP_Key_Fingerprint} |Select-Object Size -ExpandProperty Size - $PGP_Key_Expiration = $PgpKeyRing | Where-Object {$_.ID -eq $PGP_Key_Fingerprint} | Select-Object ExpirationDate -ExpandProperty ExpirationDate - $PGP_Key_CreatedOn = $PgpKeyRing | Where-Object {$_.ID -eq $PGP_Key_Fingerprint} | Select-Object CreationDate -ExpandProperty CreationDate - $PGP_Key_IsPrivate = $PgpKeyRing | Where-Object {$_.ID -eq $PGP_Key_Fingerprint} | Select-Object IsPrivate -ExpandProperty IsPrivate ; - $OperationName = GetOperationName -Operation $actionParams.Operation - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; Comments = $objParams.Description; - EmailNotifications_Actions = $EmailNotifications_Actions; EmailNotifications_FailedActions = $EmailNotifications_FailedActions; - PGP_Operation = $OperationName; - PGP_Key_Fingerprint = $PGP_Key_Fingerprint;PGP_Key_Name = $PGP_Key_Name; PGP_Key_Description = $PGP_Key_Description; PGP_Key_Size = $PGP_Key_Size; - PGP_Key_Expiration = $PGP_Key_Expiration; PGP_Key_CreatedOn = $PGP_Key_CreatedOn; PGP_Key_IsPrivate = $PGP_Key_IsPrivate; - PGP_SignKey_Fingerprint = $PGP_SignKey_Fingerprint;PGP_SignKey_Name = $PGP_SignKey_Name; PGP_SignKey_Description = $PGP_SignKey_Description; PGP_SignKey_Size = $PGP_SignKey_Size; - PGP_SignKey_Expiration = $PGP_SignKey_Expiration; PGP_SignKey_CreatedOn = $PGP_SignKey_CreatedOn; PGP_SignKey_IsPrivate = $PGP_SignKey_IsPrivate; - CheckSum = ""; - } - } - return $results -} - -function ProcessActionStatement ($SiteName, $objEvent, $Trigger, $ActionStatement, $nextActionStatement ) { - $EmailNotifications_Actions = "" - $EmailNotifications_FailedActions = "" - $action = $ActionStatement.Action() - $nextaction = $null - if ($nextActionStatement.type -eq 0) { - $nextaction = $nextActionStatement.Action() - $EmailNotifications_Actions = GetEmailNotificationNextAction -Action $nextaction - } - $results = @() - if ( $action.type -eq $PGPAction) { - - # Check for Emails in the failed action section of the PGP Action - $failSection = $ActionStatement.FailSection() - if ($null -ne $failSection) { - for ($indexfail = 0; $indexfail -le $failSection.Count() - 1 ; $indexfail++ ) { - $failaction = $failSection.item($indexfail) - $EmailNotifications_FailedActions += GetEmailNotificationNextAction -Action $failaction - } - } - $results += ExportPGPAction -sitename $SiteName -objEvent $objEvent -Trigger $Trigger -action $action -EmailNotifications_Actions $EmailNotifications_Actions -EmailNotifications_FailedActions $EmailNotifications_FailedActions - - } - #process additional PGP Actions in the Fail Section - $failSection = $ActionStatement.FailSection() - # Fail Action Section - if ($null -ne $failSection) { - for ($indexfail = 0; $indexfail -le $failSection.Count() - 1 ; $indexfail++ ) { - $failaction = $failSection.item($indexfail) - if ( $failaction.type -eq $PGPAction) { - if ($indexfail -lt $failSection.Count() - 1) { - $nextfailaction = $failSection.item($indexfail + 1) - } - $EmailNotifications_Actions = GetEmailNotificationNextAction -Action $nextfailaction - $EmailNotifications_FailedActions = "" - $results += ExportPGPAction -sitename $SiteName -objEvent $objEvent -Trigger $Trigger -action $failaction -EmailNotifications_Actions $EmailNotifications_Actions -EmailNotifications_FailedActions $EmailNotifications_FailedActions - } - } - } - return $results - -} -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - -$MailAction = 2 -$PGPAction = 32 - -$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 -} -$PgpKeyRing = @() -$AvaliablePgpKeys = $script:EftServer.AvailablePGPKeys -$totalKeys = $AvaliablePgpKeys.Length -for ($k = 0; $k -le $totalKeys - 1; $k++) { - $keyinfo = $AvaliablePgpKeys.GetValue($k); - Write-Progress -Activity "Loading PGP Keyring" -status " $k/$totalKeys" -percentComplete ($k / $totalKeys * 100) - $PgpKeyRing += new-object psobject -Property @{ - ID = $keyinfo.ID; - Name = $keyinfo.Name; - Description = $keyinfo.Description; - Size = $keyinfo.Size; - CreationDate = $keyinfo.CreationDate; - NeverExpires = $keyinfo.NeverExpires; - ExpirationDate = $keyinfo.ExpirationDate; - IsPrivate = $keyinfo.Private; - } -} -$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) - - $EventType = $script:EftServer.AvailableEvents - foreach ($eventtype in $EventType) { - Write-Progress -Activity "Processing Event Rules" -status "$($eventType.Name)" -percentComplete -1 - Try { - $eRules = $script:eftsite.EventRules($eventType.type) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "COM Exception : $error[0]" -ForegroundColor Magenta - } - If ($erules) { - If ($eRules.Count() -gt 0) { - For ($iRule = 0; $iRule -lt $eRules.Count(); $iRule++) { - Write-Progress -Activity "Processing Event Rules" -status "Event Rule $iRule/$($eRules.Count())" -percentComplete ($iRule / $eRules.Count() * 100) - $objEvent = $eRules.Item($iRule) - $Trigger = $eventType.Name - - $totalStatements = $objEvent.StatementsCount() - for ($index = 0; $index -le $totalStatements - 1 ; $index++) { - $statement = $objEvent.statement($index) - - if ($statement.type -eq 0) { - # statement is ActionStatement - $actionStatement = $statement - - $nextstatement = $null - if ($index -lt $totalStatements - 1) { - $nextstatement = $objEvent.statement($index + 1) - } - $results += ProcessActionStatement -sitename $SiteName -Trigger $Trigger -objEvent $objEvent -ActionStatement $actionStatement -nextActionStatement $nextstatement - - } - else { - # statement is ConditionStatement - $ifActions = $statement.IfSection # CIActionStatements - $elseActions = $statement.ElseSection # CIActionStatements - #Actions in If section - if ($null -ne $ifActions ) { - for ($indexAction = 0; $indexAction -le $ifActions.Count() - 1 ; $indexAction++ ) { - #process Action statement - $actionStatement = $ifActions.item($indexAction) - if ($actionStatement.type -eq 0) { - # statement is ActionStatement - - $nextstatement = $null - if ($null -ne $ifActions -and $indexAction -lt $ifActions.Count() - 1) { - $nextstatement = $ifActions.Item($indexAction + 1) - } - $results += ProcessActionStatement -sitename $SiteName -Trigger $Trigger -objEvent $objEvent -ActionStatement $actionStatement -nextActionStatement $nextstatement - } - } - } - - #Actions in Else section - if ($null -ne $elseActions ) { - for ($indexAction = 0; $indexAction -le $elseActions.Count() - 1 ; $indexAction++ ) { - #process Action statement - $actionStatement = $elseActions.item($indexAction) - if ($actionStatement.type -eq 0) { - # statement is ActionStatement - - $nextstatement = $null - if ($indexAction -lt $ifActions.Count() - 1) { - $nextstatement = $ifActions.Item($index + 1) - } - $results += ProcessActionStatement -sitename $SiteName -Trigger $Trigger -objEvent $objEvent -ActionStatement $actionStatement -nextActionStatement $nextstatement - } - } - } - } - } - - - # $results += new-object psobject -Property @{ - # SiteName = $siteName; EventRuleName = $EventRuleName; Trigger = $eventType.Name; Enabled = $Enabled; Comments = $Comments; - # EmailNotifications_Actions = $EmailNotifications_Actions; EmailNotifications_FailedActions = $EmailNotifications_FailedActions; - # PGP_Key_Name = $PGP_Key_Name; PGP_Description = $PGP_Description; PGP_Size = $PGP_Size; - # PGP_Key_Expiration = $PGP_Key_Expiration; PGP_Fingerprint = $PGP_Fingerprint; PGP_CreatedOn = $PGP_CreatedOn; - # CheckSum = ""; - # } - - } - } - } - } -} -try { - for ($i = 0 ; $i -le $results.count - 1; $i++) { - $u = $results[$i] - #Concatenate all columns except the mentioned in the ExcludedProperty - $Hash = -join ( $u | Select-Object * -ExcludeProperty SiteName, CheckSum) - $Hash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($Hash))) | Select-Object -ExpandProperty Hash - $results[$i].CheckSum = $Hash - } -} -catch { - $results[$i].CheckSum = "NA" -} -$script:EftServer.close() - -$results | Sort-Object SiteName, Trigger, EventRuleName - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-Params.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-Params.ps1 deleted file mode 100644 index ba57727..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-Params.ps1 +++ /dev/null @@ -1,289 +0,0 @@ -## -## 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 = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False, HelpMessage = "Validate Folder Monitor Paths")] - [switch] $ValidatePath -) -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - -$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) - - $EventType = $script:EftServer.AvailableEvents - foreach ($eventtype in $EventType) { - Write-Progress -Activity "Processing Event Rules" -status "$($eventType.type)" -percentComplete -1 - Try { - $eRules = $script:eftsite.EventRules($eventType.type) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "COM Exception : $error[0]" -ForegroundColor Magenta - } - If ($erules) { - If ($eRules.Count() -gt 0) { - For ($iRule = 0; $iRule -lt $eRules.Count(); $iRule++) { - Write-Progress -Activity "Processing Event Rules" -status "Event Rule $iRule/$($eRules.Count())" -percentComplete ($iRule / $eRules.Count() * 100) - $objEvent = $eRules.Item($iRule) - - $objParams = $objEvent.GetParams() - $FM_Path = "" - $FM_CheckHealthInterval = "" - $FM_CheckHealth = "" - $FM_IncludeSubfolders = "" - $FM_UseAlternateCredentials = "" - $FM_UserName = "" - $FM_Password = "" - $FM_UseFileSystemNotifications = "" - $FM_UsePeriodicDirectoryPoll = "" - $FM_PollIntervalSeconds = "" - $FM_ArchiveSubFolderName = "" - $FM_UseInteractiveLogon = "" - $FM_ArchiveLeftovers = "" - $FM_AddTimestampToArchivedFileNames = "" - $FM_PollIntervalType = "" - $FM_PollInterval = "" - - $HA_SchedulingParams = "" - $HA_SchedulingBackupParams = "" - - $SCH_DailyEveryWeekDay = "" - $SCH_DailyDayPeriod = "" - $SCH_WeeklyWeekPeriod = "" - $SCH_WeeklySunday = "" - $SCH_WeeklyMonday = "" - $SCH_WeeklyTuesday = "" - $SCH_WeeklyWednesday = "" - $SCH_WeeklyThursday = "" - $SCH_WeeklyFriday = "" - $SCH_WeeklySaturday = "" - $SCH_MonthlyFixedDay = "" - $SCH_MonthlyDayPeriod = "" - $SCH_MonthlyMonthPeriod = "" - $SCH_MonthlyRelativeWeekday = "" - $SCH_MonthlyWeekday = "" - $SCH_YearlyFixedDay = "" - $SCH_YearlyMonth = "" - $SCH_YearlyDayPeriod = "" - $SCH_YearlyRelativeWeekday = "" - $SCH_YearlyWeekday = "" - $SCH_RepeatPattern = "" - $SCH_RepeatRate = "" - $SCH_RepeatEnabled = "" - $SCH_DateTimeEnd = "" - $SCH_TimeEndEnabled = "" - $SCH_DateEndEnabled = "" - $SCH_RundayCalendar = "" - $SCH_HolidayCalendar = "" - $SCH_NextRun = "" - $SCH_Recurrence = "" - $SCH_DateTimeStart = "" - $Validpath = "" - if ($eventType.Name -eq "Folder Monitor") { - - $FM_Path = $objParams.Path - if ($ValidatePath) { - try { - if (Test-Path $FM_Path) { - $Validpath = "OK" - } - else { - $Validpath = "FOLDER_NOT_FOUND" - } - } - catch { - $Validpath = "ERROR: $_" - } - } - try {$FM_CheckHealthInterval = $objParams.CheckHealthInterval} catch {} - try {$FM_CheckHealth = $objParams.CheckHealth} catch {} - try {$FM_IncludeSubfolders = $objParams.IncludeSubfolders} catch {} - try {$FM_UseAlternateCredentials = $objParams.UseAlternateCredentials} catch {} - try {$FM_UserName = $objParams.UserName} catch {} - try {$FM_Password = $objParams.Password} catch {} - try {$FM_UseFileSystemNotifications = $objParams.UseFileSystemNotifications} catch {} - try {$FM_UsePeriodicDirectoryPoll = $objParams.UsePeriodicDirectoryPoll} catch {} - try {$FM_PollIntervalSeconds = $objParams.PollIntervalSeconds } catch {} - try {$FM_ArchiveSubFolderName = $objParams.ArchiveSubFolderName } catch {} - try {$FM_UseInteractiveLogon = $objParams.UseInteractiveLogon } catch {} - try {$FM_ArchiveLeftovers = $objParams.ArchiveLeftovers} catch {} - try {$FM_AddTimestampToArchivedFileNames = $objParams.AddTimestampToArchivedFileNames} catch {} - try {$FM_PollIntervalType = $objParams.PollIntervalType } catch {} - try {$FM_PollInterval = $objParams.PollInterval } catch {} - } - if ($eventType.Name -eq "Scheduler (Timer) Event") { - try {$SCH_DailyEveryWeekDay = $objParams.DailyEveryWeekDay} catch {} - try {$SCH_DailyDayPeriod = $objParams.DailyDayPeriod} catch {} - try {$SCH_WeeklyWeekPeriod = $objParams.WeeklyWeekPeriod} catch {} - try {$SCH_WeeklySunday = $objParams.WeeklySunday} catch {} - try {$SCH_WeeklyMonday = $objParams.WeeklyMonday} catch {} - try {$SCH_WeeklyTuesday = $objParams.WeeklyTuesday} catch {} - try {$SCH_WeeklyWednesday = $objParams.WeeklyWednesday} catch {} - try {$SCH_WeeklyThursday = $objParams.WeeklyThursday} catch {} - try {$SCH_WeeklyFriday = $objParams.WeeklyFriday } catch {} - try {$SCH_WeeklySaturday = $objParams.WeeklySaturday } catch {} - try {$SCH_MonthlyFixedDay = $objParams.MonthlyFixedDay } catch {} - try {$SCH_MonthlyDayPeriod = $objParams.MonthlyDayPeriod} catch {} - try {$SCH_MonthlyMonthPeriod = $objParams.MonthlyMonthPeriod} catch {} - try {$SCH_MonthlyRelativeWeekday = $objParams.MonthlyRelativeWeekday } catch {} - try {$SCH_MonthlyWeekday = $objParams.MonthlyWeekday } catch {} - try {$SCH_YearlyFixedDay = $objParams.YearlyFixedDay } catch {} - try {$SCH_YearlyMonth = $objParams.YearlyMonth } catch {} - try {$SCH_YearlyDayPeriod = $objParams.YearlyDayPeriod } catch {} - try {$SCH_YearlyRelativeWeekday = $objParams.YearlyRelativeWeekday } catch {} - try {$SCH_YearlyWeekday = $objParams.YearlyWeekday } catch {} - try {$SCH_RepeatPattern = $objParams.RepeatPattern } catch {} - try {$SCH_RepeatRate = $objParams.RepeatRate } catch {} - try {$SCH_RepeatEnabled = $objParams.RepeatEnabled } catch {} - try {$SCH_DateTimeEnd = $objParams.DateTimeEnd } catch {} - try {$SCH_TimeEndEnabled = $objParams.TimeEndEnabled } catch {} - try {$SCH_DateEndEnabled = $objParams.DateEndEnabled } catch {} - try {$SCH_RundayCalendar = $objParams.RundayCalendar } catch {} - try {$SCH_HolidayCalendar = $objParams.HolidayCalendar } catch {} - try {$SCH_NextRun = $objParams.NextRun } catch {} - try {$SCH_Recurrence = $objParams.Recurrence } catch {} - try {$SCH_DateTimeStart = $objParams.DateTimeStart } catch {} - } - if($script:EftServer.HAEnabled){ - $EFTHAParams = $objEvent.GetHASchedulingParams() - $EFTHABackupParams = $objEvent.GetHABackupSchedulingParams() - for ($i=0;$i -lt $EFTHAParams.Count();$i++){ - $HA_SchedulingParams += "$($EFTHAParams.Item($i))," - } - for ($i=0;$i -lt $EFTHABackupParams.Count();$i++){ - $HA_SchedulingBackupParams += "$($EFTHABackupParams.Item($i))," - } - } - - $results += new-object psobject -Property @{ - SiteName = $siteName; - EventRuleName = $objParams.name; - Trigger = $eventType.Name; - Enabled = $objParams.Enabled; - Validpath = $Validpath - - FM_Path = $FM_Path; - FM_CheckHealthInterval = $FM_CheckHealthInterval; - FM_CheckHealth = $FM_CheckHealth; - FM_IncludeSubfolders = $FM_IncludeSubfolders; - FM_UseAlternateCredentials = $FM_UseAlternateCredentials; - FM_UserName = $FM_UserName; - FM_Password = $FM_Password; - FM_UseFileSystemNotifications = $FM_UseFileSystemNotifications; - FM_UsePeriodicDirectoryPoll = $FM_UsePeriodicDirectoryPoll; - FM_PollIntervalSeconds = $FM_PollIntervalSeconds; - FM_ArchiveSubFolderName = $FM_ArchiveSubFolderName; - FM_UseInteractiveLogon = $FM_UseInteractiveLogon; - FM_ArchiveLeftovers = $FM_ArchiveLeftovers; - FM_AddTimestampToArchivedFileNames = $FM_AddTimestampToArchivedFileNames; - FM_PollIntervalType = $FM_PollIntervalType; - FM_PollInterval = $FM_PollInterval; - - SCH_DailyEveryWeekDay = $SCH_DailyEveryWeekDay - SCH_DailyDayPeriod = $SCH_DailyDayPeriod - SCH_WeeklyWeekPeriod = $SCH_WeeklyWeekPeriod - SCH_WeeklySunday = $SCH_WeeklySunday - SCH_WeeklyMonday = $SCH_WeeklyMonday - SCH_WeeklyTuesday = $SCH_WeeklyTuesday - SCH_WeeklyWednesday = $SCH_WeeklyWednesday - SCH_WeeklyThursday = $SCH_WeeklyThursday - SCH_WeeklyFriday = $SCH_WeeklyFriday - SCH_WeeklySaturday = $SCH_WeeklySaturday - SCH_MonthlyFixedDay = $SCH_MonthlyFixedDay - SCH_MonthlyDayPeriod = $SCH_MonthlyDayPeriod - SCH_MonthlyMonthPeriod = $SCH_MonthlyMonthPeriod - SCH_MonthlyRelativeWeekday = $SCH_MonthlyRelativeWeekday - SCH_MonthlyWeekday = $SCH_MonthlyWeekday - SCH_YearlyFixedDay = $SCH_YearlyFixedDay - SCH_YearlyMonth = $SCH_YearlyMonth - SCH_YearlyDayPeriod = $SCH_YearlyDayPeriod - SCH_YearlyRelativeWeekday = $SCH_YearlyRelativeWeekday - SCH_YearlyWeekday = $SCH_YearlyWeekday - SCH_RepeatPattern = $SCH_RepeatPattern - SCH_RepeatRate = $SCH_RepeatRate - SCH_RepeatEnabled = $SCH_RepeatEnabled - SCH_DateTimeEnd = $SCH_DateTimeEnd - SCH_TimeEndEnabled = $SCH_TimeEndEnabled - SCH_DateEndEnabled = $SCH_DateEndEnabled - SCH_RundayCalendar = $SCH_RundayCalendar - SCH_HolidayCalendar = $SCH_HolidayCalendar - SCH_NextRun = $SCH_NextRun - SCH_Recurrence = $SCH_Recurrence - SCH_DateTimeStart = $SCH_DateTimeStart - - HA_SchedulingParams = $HA_SchedulingParams; - HA_SchedulingBackupParams = $HA_SchedulingBackupParams; - - CheckSum = ""; - } - } - } - } - } -} -try { - for ($i = 0 ; $i -le $results.count - 1; $i++) { - $u = $results[$i] - #Concatenate all columns except the mentioned in the ExcludedProperty - $Hash = -join ( $u | Select-Object * -ExcludeProperty SiteName, SCH_NextRun, Validpath, CheckSum) - $Hash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($Hash))) | Select-Object -ExpandProperty Hash - $results[$i].CheckSum = $Hash - } -} -catch { - $results[$i].CheckSum = "NA" -} -$script:EftServer.close() - -$results | Sort-Object SiteName, Trigger, EventRuleName - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-PathsInActions.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-PathsInActions.ps1 deleted file mode 100644 index 9df1ed2..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Export-PathsInActions.ps1 +++ /dev/null @@ -1,797 +0,0 @@ -## -## 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. - -<# - .SYNOPSIS - Exports Paths used in event rules actions. - .DESCRIPTION - This script return paths used in event rules actions for all or a specific EFT site - .EXAMPLE - .\EFT.EventRules.Export-PathsInActions.ps1 | Export-Csv .\PathsInActions_Report.csv -NoTypeInformation - - Export all Paths in actions in the event rules for all sites into a CSV file - This commands will connect to an EFT server listening in localhost using port 1100 and using - the current windows login credentials - - .EXAMPLE - .\EFT.EventRules.Export-PathsInActions.ps1 -EFTAdminHostName 127.0.0.1 -EFTAdminPort 1100 -EFTAdminAuthType 0 -EFTAdminUsername myusername -Password Mypassword | Export-Csv .\PathsInActions_Report.csv -NoTypeInformation - - Export all Paths in actions in the event rules for all sites into a CSV file - This commands will connect to an EFT server listening in 127.0.0.1 using port 1100 and using EFT Admin credentials myusername/mypassword - -#> -[CmdletBinding()] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False, HelpMessage = "Validate Paths")] - [switch] $ValidatePath - -) -function GetValue($value) { - if ($value -is [array]) { - return $value -join "|" - } - return $value -} -Function GetPropertyName ($EventProperty) { - switch ($EventProperty) { - 1003 { return "ServerLogOldPath"} - 1004 { return "ServerLogNewPath"} - 1006 { return "ServerLogFolder"} - 3006 { return "HttpQueryString"} - 3007 { return "HttpHeadersList"} - 5000 { return "VirtualPath"} - 5001 { return "PhysicalPath"} - 5003 { return "DestinationPhysicalPath"} - 5004 { return "FolderName"} - 5005 { return "FileName"} - 5006 { return "DestinationFolderName"} - 5007 { return "DestinationFileName"} - 5013 { return "ReportPath"} - 5015 { return "ReportFileName"} - 5016 { return "VirtualFolderName"} - 5017 { return "BaseFileName"} - 5018 { return "FileFolderExists"} - 5019 { return "CompressedPhysicalPath"} - 5020 { return "CompressedFileName"} - 5021 { return "CompressedBaseFileName"} - 7000 { return "WSVirtualPath"} - 7001 { return "WSPhysicalPath"} - 8000 { return "ContextVariable"} - } -} -Function GetOperationName ($Operation) { - switch ($Operation) { - 0 { return "Encrypt"} - 1 { return "EncryptAndSign"} - 2 { return "Sign"} - 3 { return "SDA"} - 4 { return "Decrypt"} - 5 { return "DecryptAndVerify"} - 6 { return "VerifyOnly"} - } -} -Function GetActionName ($EventActionType) { - switch ($EventActionType) { - 1 { return "CommandAction"} - 2 { return "MailAction"} - 4 { return "UploadAction"} - 8 { return "DownloadAction"} - 32 { return "PGPAction"} - 64 { return "StopAction"} - 128 { return "CleanupAction"} - 256 { return "ReportAction"} - 512 { return "AS2SendAction"} - 1024 { return "AWTaskAction"} - 2048 { return "BackupAction"} - 4096 { return "WindowsEventLog"} - 8192 { return "ContentIntegrityControl"} - 16384 { return "FolderAction"} - 32768 { return "FileAction"} - 65536 { return "CompressAction"} - 262144 { return "WebServiceAction"} - 524288 { return "CloudUploadAction"} - 1048576 { return "CloudDownloadAction"} - } -} -function ValidatePath ($path){ - $Validpath = "" - if ($ValidatePath -and $null -ne $path -and $path -ne '') { - try { - if (Test-Path $path) { - $Validpath = "OK" - } - else { - $Validpath = "PATH_NOT_FOUND" - } - } - catch { - $Validpath = "ERROR: $_" - } - } - return $Validpath -} - -function ExportPathInAction ($SiteName, $EventRule, $Trigger, $StatementPosition, $ActionPosition, $IsElse, $action, $IsFailAction, $FailActionPosition) { - $objParams = $EventRule.GetParams() - $actionParams = $action.GetParams() - $results = @() - - switch ($action.type) { - $PGPACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "FilePath" - ActionValue = $actionParams.FilePath; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.FilePath); - CheckSum = ""; - } - } - $COMMANDACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "WorkingFolder" - ActionValue = $actionParams.WorkingFolder; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.WorkingFolder); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Parameters" - ActionValue = $actionParams.Parameters; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.Parameters); - CheckSum = ""; - } - } - $UPLOADACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "LocalPath" - ActionValue = $actionParams.LocalPath; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.LocalPath); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "RemotePath" - ActionValue = $actionParams.RemotePath; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.RemotePath); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - Line = $script:Line; - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "PrivateKeyPath" - ActionValue = $actionParams.PrivateKeyPath; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.PrivateKeyPath); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "PublicKeyPath" - ActionValue = $actionParams.PublicKeyPath; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.PublicKeyPath); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "TrustedPublicKeyPath" - ActionValue = $actionParams.TrustedPublicKeyPath; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.TrustedPublicKeyPath); - CheckSum = ""; - } - } - $DOWNLOADACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "LocalPath" - ActionValue = $actionParams.LocalPath; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.LocalPath); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "RemotePath" - ActionValue = $actionParams.RemotePath; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.RemotePath); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "PrivateKeyPath" - ActionValue = $actionParams.PrivateKeyPath; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.PrivateKeyPath); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "PublicKeyPath" - ActionValue = $actionParams.PublicKeyPath; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.PublicKeyPath); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "TrustedPublicKeyPath" - ActionValue = $actionParams.TrustedPublicKeyPath; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.TrustedPublicKeyPath); - CheckSum = ""; - } - } - $CLEANUPACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Folder" - ActionValue = $actionParams.Folder; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.Folder); - CheckSum = ""; - } - } - $AS2SENDACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "LocalPath" - ActionValue = $actionParams.LocalPath; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.LocalPath); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "RemotePath" - ActionValue = $actionParams.RemotePath; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.RemotePath); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "PartnerCertificatePath" - ActionValue = $actionParams.PartnerCertificatePath; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.PartnerCertificatePath); - CheckSum = ""; - } - } - $BACKUPACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Folder" - ActionValue = $actionParams.Folder; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.Folder); - CheckSum = ""; - } - } - $CONTENTINTEGRITYCONTROL { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "File" - ActionValue = $actionParams.File; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.File); - CheckSum = ""; - } - } - $CONTENTINTEGRITYCONTROL { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "File" - ActionValue = $actionParams.File; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.File); - CheckSum = ""; - } - } - $FOLDERACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Path" - ActionValue = $actionParams.Path; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.Path); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "NewFolderName" - ActionValue = $actionParams.NewFolderName; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath( $actionParams.NewFolderName); - CheckSum = ""; - } - } - $FILEACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Path" - ActionValue = $actionParams.Path; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.Path); - CheckSum = ""; - } - } - $COMPRESSACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Source" - ActionValue = $actionParams.Source; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.Source); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "Destination" - ActionValue = $actionParams.Destination; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.Destination); - CheckSum = ""; - } - } - $WEBSERVICEACTION { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "BodyFile" - ActionValue = $actionParams.BodyFile; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.BodyFile); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "ResponseFile" - ActionValue = $actionParams.ResponseFile; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.ResponseFile); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "SslClientCertificate" - ActionValue = $actionParams.SslClientCertificate; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.SslClientCertificate); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "SslPrivateKey" - ActionValue = $actionParams.SslPrivateKey; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.SslPrivateKey); - CheckSum = ""; - } - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = $ActionPosition ; - IsElse = $IsElse; - ActionName = GetActionName($action.type); - ActionParameter = "SslServerCertificate" - ActionValue = $actionParams.SslServerCertificate; - IsFailAction = $IsFailAction; - FailActionPosition = $FailActionPosition; - Validpath = ValidatePath($actionParams.SslServerCertificate); - CheckSum = ""; - } - } - $CLOUDUPLOADACTION { - - } - $CLOUDDOWNLOADACTION { - - } - } - return $results -} -function ProcessConditionStatement ($SiteName, $EventRule, $Trigger, $StatementPosition, $SimpleCondition ) { - $results = @() - $objParams = $EventRule.GetParams() - if (GetPropertyName($SimpleCondition.property) -ne "") { - $results += new-object psobject -Property @{ - SiteName = $siteName; EventRuleName = $objParams.name; Trigger = $Trigger; Enabled = $objParams.Enabled; - Line = $script:Line; - StatementPosition = $StatementPosition; - ActionPosition = "" ; - IsElse = ""; - ActionName = "IFCondition" - ActionParameter = GetPropertyName($SimpleCondition.property); - ActionValue = GetValue($SimpleCondition.Value); - IsFailAction = ""; - FailActionPosition = ""; - Validpath = ""; - CheckSum = ""; - } - } - return $results -} -function ProcessActionStatement ($SiteName, $EventRule, $Trigger, $StatementPosition, $ActionStatement , $ActionPosition, $IsElse) { - #$objParams = $EventRule.GetParams() - $action = $ActionStatement.Action() - - $results = @() - $results += ExportPathInAction -SiteName $SiteName -EventRule $EventRule -Trigger $Trigger -StatementPosition $StatementPosition -ActionPosition $ActionPosition -action $action -IsElse $IsElse -IsFailAction 0 -FailActionPosition 0 - - #process additional Actions in the Fail Section - $failSection = $ActionStatement.FailSection() - # Fail Action Section - if ($null -ne $failSection) { - for ($indexfail = 0; $indexfail -le $failSection.Count() - 1 ; $indexfail++ ) { - $failaction = $failSection.item($indexfail) - $script:Line++ - $results += ExportPathInAction -SiteName $SiteName -EventRule $EventRule -Trigger $Trigger -StatementPosition $StatementPosition -ActionPosition $ActionPosition -action $failaction -IsElse $IsElse -IsFailAction 1 -FailActionPosition $indexfail - } - } - return $results - -} -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null -$script:Line = 0 - -$COMMANDACTION = 1 -$MAILACTION = 2 -$UPLOADACTION = 4 -$DOWNLOADACTION = 8 -$PGPACTION = 32 -$STOPACTION = 64 -$CLEANUPACTION = 128 -$REPORTACTION = 256 -$AS2SENDACTION = 512 -$AWTASKACTION = 1024 -$BACKUPACTION = 2048 -$WINDOWSEVENTLOG = 4096 -$CONTENTINTEGRITYCONTROL = 8192 -$FOLDERACTION = 16384 -$FILEACTION = 32768 -$COMPRESSACTION = 65536 -$WEBSERVICEACTION = 262144 -$CLOUDUPLOADACTION = 524288 -$CLOUDDOWNLOADACTION = 1048576 - -$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) - - $EventType = $script:EftServer.AvailableEvents - foreach ($eventtype in $EventType) { - Write-Progress -Activity "Processing Event Rules" -status "$($eventType.Name)" -percentComplete -1 - Try { - $eRules = $script:eftsite.EventRules($eventType.type) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "COM Exception : $error[0]" -ForegroundColor Magenta - } - If ($erules) { - If ($eRules.Count() -gt 0) { - For ($iRule = 0; $iRule -lt $eRules.Count(); $iRule++) { - Write-Progress -Activity "Processing Event Rules" -status "Event Rule $iRule/$($eRules.Count())" -percentComplete ($iRule / $eRules.Count() * 100) - $objEvent = $eRules.Item($iRule) - $Trigger = $eventType.Name - - $totalStatements = $objEvent.StatementsCount() - $script:Line = 0 - for ($StatementPosition = 0; $StatementPosition -le $totalStatements - 1 ; $StatementPosition++) { - $statement = $objEvent.statement($StatementPosition) - if ($statement.type -eq 0) { - # statement is ActionStatement - $actionStatement = $statement - $script:Line++ - $results += ProcessActionStatement -sitename $SiteName -EventRule $objEvent -Trigger $Trigger -ActionStatement $actionStatement -StatementPosition $StatementPosition -ActionPosition 0 -IsElse 0 - - } - else { - $ConditionStatement = $statement.Condition - $script:Line++ - if ($ConditionStatement.Operator -eq 0 -or $ConditionStatement.Operator -eq 1 ) { - #Compound condition - for ($conditionindex = 0; $conditionindex -le $ConditionStatement.Count() - 1; $conditionindex++) { - $simplecondition = $ConditionStatement.Item($conditionindex); - $results += ProcessConditionStatement -sitename $SiteName -EventRule $objEvent -Trigger $Trigger -StatementPosition $StatementPosition -SimpleCondition $SimpleCondition - } - } - else { - #simple condition - $simplecondition = $statement.Condition - $results += ProcessConditionStatement -sitename $SiteName -EventRule $objEvent -Trigger $Trigger -StatementPosition $StatementPosition -SimpleCondition $SimpleCondition - } - # statement is ConditionStatement - $ifActions = $statement.IfSection # CIActionStatements - $elseActions = $statement.ElseSection # CIActionStatements - #Actions in If section - if ($null -ne $ifActions ) { - - for ($indexAction = 0; $indexAction -le $ifActions.Count() - 1 ; $indexAction++ ) { - #process Action statement - $actionStatement = $ifActions.item($indexAction) - $script:Line++ - if ($actionStatement.type -eq 0) { - # statement is ActionStatement - $results += ProcessActionStatement -sitename $SiteName -EventRule $objEvent -Trigger $Trigger -ActionStatement $actionStatement -StatementPosition $StatementPosition -ActionPosition $indexAction -IsElse 0 - } - } - } - - #Actions in Else section - if ($null -ne $elseActions ) { - $script:Line++ - for ($indexAction = 0; $indexAction -le $elseActions.Count() - 1 ; $indexAction++ ) { - #process Action statement - $actionStatement = $elseActions.item($indexAction) - $script:Line++ - if ($actionStatement.type -eq 0) { - # statement is ActionStatement - $results += ProcessActionStatement -sitename $SiteName -EventRule $objEvent -Trigger $Trigger -ActionStatement $actionStatement -StatementPosition $StatementPosition -ActionPosition $indexAction -IsElse 1 - } - } - } - } - } - - - # $results += new-object psobject -Property @{ - # SiteName = $siteName; EventRuleName = $EventRuleName; Trigger = $eventType.Name; Enabled = $Enabled; Comments = $Comments; - # EmailNotifications_Actions = $EmailNotifications_Actions; EmailNotifications_FailedActions = $EmailNotifications_FailedActions; - # PGP_Key_Name = $PGP_Key_Name; PGP_Description = $PGP_Description; PGP_Size = $PGP_Size; - # PGP_Key_Expiration = $PGP_Key_Expiration; PGP_Fingerprint = $PGP_Fingerprint; PGP_CreatedOn = $PGP_CreatedOn; - # CheckSum = ""; - # } - - } - } - } - } -} -try { - for ($i = 0 ; $i -le $results.count - 1; $i++) { - $u = $results[$i] - #Concatenate all columns except the mentioned in the ExcludedProperty - $Hash = -join ( $u | Select-Object * -ExcludeProperty SiteName, CheckSum) - $Hash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($Hash))) | Select-Object -ExpandProperty Hash - $results[$i].CheckSum = $Hash - } -} -catch { - $results[$i].CheckSum = "NA" -} - -$script:EftServer.close() - -$results | Sort-Object SiteName, Trigger, EventRuleName - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Get-EnabledState.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Get-EnabledState.ps1 deleted file mode 100644 index c8e91e8..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Get-EnabledState.ps1 +++ /dev/null @@ -1,91 +0,0 @@ -## -## 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 = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password -) -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - -$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) - - $EventType = $script:EftServer.AvailableEvents - foreach ($eventtype in $EventType) { - Write-Progress -Activity "Processing Event Rules" -status "$($eventType.type)" -percentComplete -1 - Try { - $eRules = $script:eftsite.EventRules($eventType.type) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "COM Exception : $error[0]" -ForegroundColor Magenta - } - If ($erules) { - If ($eRules.Count() -gt 0) { - For ($iRule = 0; $iRule -lt $eRules.Count(); $iRule++) { - Write-Progress -Activity "Processing Event Rules" -status "Event Rule $iRule/$($eRules.Count())" -percentComplete ($iRule / $eRules.Count() * 100) - $objEvent = $eRules.Item($iRule) - - $objParams = $objEvent.GetParams() - $results += new-object psobject -Property @{ - SiteName = $siteName; - EventRuleName = $objParams.name; - Trigger = $eventType.Name; - Enabled = $objParams.Enabled; - } - } - } - } - } -} -$script:EftServer.close() - -$results | Sort-Object SiteName, Trigger, EventRuleName - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Remove.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Remove.ps1 deleted file mode 100644 index 1949d58..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Remove.ps1 +++ /dev/null @@ -1,159 +0,0 @@ -## -## 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(SupportsShouldProcess)] -Param( - [Parameter(Position = 0, Mandatory = $false, HelpMessage = "Enter the event rules Paramaters CSV file")] - [string] $InputCsvFile = "ev.csv", - - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False )] - [switch]$Quiet = $false -) -if ($InputCsvFile -eq "") { - #Uncomment the following to enter paramters for each site - $EventRulesList = @( - # @{ SiteName = "MySite"; Enabled = "False"; EventRuleName = "Event Rule 1"; Trigger = "File Downloaded" } - # @{ SiteName = "MySite"; Enabled = "True" ; EventRuleName = "Event Rule 2" Trigger = "File Uploaded" } - ) -} -else { - $EventRulesList = Import-Csv $InputCsvFile - # "SiteName","Enabled", "EventRuleName,Trigger" -} - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null -$MXE_EVENT_FM_FOLDER_NOT_ACCESSIBLE = "MX Error: 100 (00000064)" -$MXE_EVENTRULE_NOT_FOUND = "MX Error: 89 (00000059)" -$MXE_EVENTRULE_CHANGEDESC_MISSING = "MX Error: 90 (0000005A)" -$MXE_EVENT_AW_TASK_DOES_NOT_EXIST = "MX Error: 106 (0000006A)" -$MXE_EVENT_COMMAND_DOES_NOT_EXIST = "MX Error: 107 (0000006B)" -$MXE_EVENT_PGP_PASS_INVALID = "MX Error: 54 (00000036)" -$MXE_EVENT_INVALID = "MX Error: 43 (0000002B)" -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' - -$MAX_PAD = 100 -$PAD_CHR = "." - -$EFTServer = new-object -ComObject "SFTPCOMInterface.CIServer" - -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $script:EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() - -$SiteList = @{} -for ($j = 0; $j -le $sitesCount - 1; $j++ ) { - $script:EftSite = $script:EftSites.Item($j) - $SiteList.Add($script:EftSite.Name, $script:EftSite.ID) -} - -Write-host "Removing event rules" -$removedCount = 0 -$errorCount = 0 - -ForEach ($EventRuleItem in $EventRulesList) { - $count = $count + 1 - $processed = $false - $EventType = $script:EftServer.AvailableEvents - $script:EftSite = $script:EftSites.SiteByID($SiteList[$EventRuleItem.SiteName]) - - foreach ($eventtype in $EventType) { - Try { - $eRules = $script:eftsite.EventRules($eventType.type) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "COM Exception : $error[0]" -ForegroundColor Red - } - $EventCount = $eRules.Count() - If ($erules) { - If ($EventCount -gt 0) { - For ($iRule = 0; $iRule -le $EventCount - 1; $iRule++) { - $objEvent = $eRules.Item($iRule) - $objParams = $objEvent.GetParams() - $eventNameParam = $objParams.name - $chkName = $eventNameParam + ">" + $EventName - Write-Verbose $chkName - If ($eventNameParam -eq $EventRuleItem.EventRuleName) { - try { - Write-Host "Removed: [$($EventRuleItem.SiteName)] [$($EventRuleItem.EventRuleName)] $originalState->$($EventRuleItem.Enabled)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - if ($pscmdlet.ShouldProcess($EventRuleItem.EventRuleName, "deleted" )) { - $eRules.Delete($iRule) - } - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - $removedCount++ - break - } - catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_EVENTRULE_NOT_FOUND { Write-host "MXE_EVENTRULE_NOT_FOUND : $_ " -ForegroundColor Red } - $MXE_EVENT_FM_FOLDER_NOT_ACCESSIBLE { Write-host "MXE_EVENT_FM_FOLDER_NOT_ACCESSIBLE : $_ " -ForegroundColor Red } - $MXE_EVENTRULE_CHANGEDESC_MISSING { Write-host "MXE_EVENTRULE_CHANGEDESC_MISSING : $_ " -ForegroundColor Red } - $MXE_EVENT_AW_TASK_DOES_NOT_EXIST { Write-host "MXE_EVENT_AW_TASK_DOES_NOT_EXIST : $_ " -ForegroundColor Red } - $MXE_EVENT_COMMAND_DOES_NOT_EXIST { Write-host "MXE_EVENT_COMMAND_DOES_NOT_EXIST : $_ " -ForegroundColor Red } - $MXE_EVENT_PGP_PASS_INVALID { Write-host "MXE_EVENT_PGP_PASS_INVALID : $_ " -ForegroundColor Red } - $MXE_EVENT_INVALID { Write-host "MXE_EVENT_INVALID : $_ " -ForegroundColor Red } - Default { Write-host "Exception : $_" -ForegroundColor Red} - } - $errorCount++ - } - } - } - if ($processed) { - break - } - } - } - if ($processed) { - break - } - } - -} -$script:EftServer.close() - -Write-host " Removed: " -NoNewline -Write-host "$removedCount " -NoNewline -ForegroundColor green -Write-host "Errors: "-NoNewline -Write-host "$errorCount " -ForegroundColor red -Write-host " " - - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Update-EnabledState.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Update-EnabledState.ps1 deleted file mode 100644 index 400ecf4..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Update-EnabledState.ps1 +++ /dev/null @@ -1,171 +0,0 @@ -## -## 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(SupportsShouldProcess)] -Param( - [Parameter(Position = 0, Mandatory = $false, HelpMessage = "Enter the CSV file ")] - [string] $InputCsvFile = "EventRules_EnableState.csv", - - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False )] - [switch]$Quiet = $false -) -if ($InputCsvFile -eq "") { - #Uncomment the following to enter paramters for each site - $EventRulesList = @( - # @{ SiteName = "MySite"; Enabled = "False"; EventRuleName = "Event Rule 1"; Trigger = "File Downloaded" } - # @{ SiteName = "MySite"; Enabled = "True" ; EventRuleName = "Event Rule 2" Trigger = "File Uploaded" } - ) -} -else { - $EventRulesList = Import-Csv $InputCsvFile - # "SiteName","Enabled", "EventRuleName" -} - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null -$MXE_EVENT_FM_FOLDER_NOT_ACCESSIBLE = "MX Error: 100 (00000064)" -$MXE_EVENTRULE_NOT_FOUND = "MX Error: 89 (00000059)" -$MXE_EVENTRULE_CHANGEDESC_MISSING = "MX Error: 90 (0000005A)" -$MXE_EVENT_AW_TASK_DOES_NOT_EXIST = "MX Error: 106 (0000006A)" -$MXE_EVENT_COMMAND_DOES_NOT_EXIST = "MX Error: 107 (0000006B)" -$MXE_EVENT_PGP_PASS_INVALID = "MX Error: 54 (00000036)" -$MXE_EVENT_INVALID = "MX Error: 43 (0000002B)" -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' - -$MAX_PAD = 100 -$PAD_CHR = "." - -$EFTServer = new-object -ComObject "SFTPCOMInterface.CIServer" - -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $script:EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() - -$SiteList = @{ } -for ($j = 0; $j -le $sitesCount - 1; $j++ ) { - $script:EftSite = $script:EftSites.Item($j) - $SiteList.Add($script:EftSite.Name, $script:EftSite.ID) -} - -Write-host "Updating event rule enabled state" -$updateCount = 0 -$errorCount = 0 -$processed = 0 -if ($EventRulesList.Count -ne 0 ) { - ForEach ($EventRuleItem in $EventRulesList) { - $count = $count + 1 - $processed = $false - $EventType = $script:EftServer.AvailableEvents - Write-Verbose "Site: $($EventRuleItem.SiteName)" - $script:EftSite = $script:EftSites.SiteByID($SiteList[$EventRuleItem.SiteName]) - $sw.Restart() - - foreach ($eventtype in $EventType) { - Try { - $eRules = $script:eftsite.EventRules($eventType.type) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "COM Exception : $error[0]" -ForegroundColor Red - } - $EventCount = $eRules.Count() - If ($erules) { - If ($EventCount -gt 0) { - For ($iRule = 0; $iRule -le $EventCount - 1; $iRule++) { - $objEvent = $eRules.Item($iRule) - $objParams = $objEvent.GetParams() - $eventNameParam = $objParams.name - $chkName = $eventNameParam + ">" + $EventName - Write-Verbose $chkName - If ($eventNameParam -eq $EventRuleItem.EventRuleName) { - $originalState = "$($objParams.Enabled)" - try { - Write-Host "Update: [$($EventRuleItem.SiteName)] [$($EventRuleItem.EventRuleName)] $originalState->$($EventRuleItem.Enabled)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - - if( $originalState -eq $EventRuleItem.Enabled ) { - Write-host " SAME ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - } - else { - $objParams.Enabled = $EventRuleItem.Enabled - $updateCount++ - if ($pscmdlet.ShouldProcess($EventRuleItem.EventRuleName, "Enabled=$originalState" )) { - $objEvent.SetParams($objParams) - } - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - $processed = $true - break - } - catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_EVENTRULE_NOT_FOUND { Write-host "MXE_EVENTRULE_NOT_FOUND : $_ " -ForegroundColor Red } - $MXE_EVENT_FM_FOLDER_NOT_ACCESSIBLE { Write-host "MXE_EVENT_FM_FOLDER_NOT_ACCESSIBLE : $_ " -ForegroundColor Red } - $MXE_EVENTRULE_CHANGEDESC_MISSING { Write-host "MXE_EVENTRULE_CHANGEDESC_MISSING : $_ " -ForegroundColor Red } - $MXE_EVENT_AW_TASK_DOES_NOT_EXIST { Write-host "MXE_EVENT_AW_TASK_DOES_NOT_EXIST : $_ " -ForegroundColor Red } - $MXE_EVENT_COMMAND_DOES_NOT_EXIST { Write-host "MXE_EVENT_COMMAND_DOES_NOT_EXIST : $_ " -ForegroundColor Red } - $MXE_EVENT_PGP_PASS_INVALID { Write-host "MXE_EVENT_PGP_PASS_INVALID : $_ " -ForegroundColor Red } - $MXE_EVENT_INVALID { Write-host "MXE_EVENT_INVALID : $_ " -ForegroundColor Red } - Default { Write-host "Exception : $_" -ForegroundColor Red } - } - $errorCount++ - } - } - } - if ($processed) { - break - } - } - } - if ($processed) { - break - } - } - - } -} -$script:EftServer.close() -Write-host " Updated: " -NoNewline -Write-host "$updateCount " -NoNewline -ForegroundColor green -Write-host "Errors: "-NoNewline -Write-host "$errorCount " -ForegroundColor red -Write-host " " - - - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Update-Params.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Update-Params.ps1 deleted file mode 100644 index 40a334e..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.EventRules.Update-Params.ps1 +++ /dev/null @@ -1,251 +0,0 @@ -## -## 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(SupportsShouldProcess)] -Param( - [Parameter(Position = 0, Mandatory = $false, HelpMessage = "Enter the event rules Paramaters CSV file")] - [string] $InputCsvFile = "EventRules_Params.csv", - - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False )] - [switch]$Quiet = $false -) -if ($InputCsvFile -eq "") { - #Uncomment the following to enter paramters for each site - $EventRulesList = @( - # @{ SiteName = "MySite"; Enabled = "False"; EventRuleName = "Event Rule 1"; Trigger = "File Downloaded" } - # @{ SiteName = "MySite"; Enabled = "True" ; EventRuleName = "Event Rule 2" Trigger = "File Uploaded" } - ) -} -else { - $EventRulesList = Import-Csv $InputCsvFile - # "SiteName","Enabled", "EventRuleName,Trigger" -} - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null -$MXE_EVENT_FM_FOLDER_NOT_ACCESSIBLE = "MX Error: 100 (00000064)" -$MXE_EVENTRULE_NOT_FOUND = "MX Error: 89 (00000059)" -$MXE_EVENTRULE_CHANGEDESC_MISSING = "MX Error: 90 (0000005A)" -$MXE_EVENT_AW_TASK_DOES_NOT_EXIST = "MX Error: 106 (0000006A)" -$MXE_EVENT_COMMAND_DOES_NOT_EXIST = "MX Error: 107 (0000006B)" -$MXE_EVENT_PGP_PASS_INVALID = "MX Error: 54 (00000036)" -$MXE_EVENT_INVALID = "MX Error: 43 (0000002B)" -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' - -$MAX_PAD = 100 -$PAD_CHR = "." - -$EFTServer = new-object -ComObject "SFTPCOMInterface.CIServer" - -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $script:EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() - -$SiteList = @{} -for ($j = 0; $j -le $sitesCount - 1; $j++ ) { - $script:EftSite = $script:EftSites.Item($j) - $SiteList.Add($script:EftSite.Name, $script:EftSite.ID) -} - -Write-host "Updating event rule enabled state:" -$updateCount = 0 -$errorCount = 0 -$warnCount = 0 -ForEach ($EventRuleItem in $EventRulesList) { - $count = $count + 1 - $processed = $false - $EventType = $script:EftServer.AvailableEvents - $script:EftSite = $script:EftSites.SiteByID($SiteList[$EventRuleItem.SiteName]) - - foreach ($eventtype in $EventType) { - Try { - $eRules = $script:eftsite.EventRules($eventType.type) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "COM Exception : $error[0]" -ForegroundColor Red - } - $EventCount = $eRules.Count() - If ($erules) { - If ($EventCount -gt 0) { - For ($iRule = 0; $iRule -le $EventCount - 1; $iRule++) { - $objEvent = $eRules.Item($iRule) - $objParams = $objEvent.GetParams() - $eventNameParam = $objParams.name - $chkName = $eventNameParam + ">" + $EventName - Write-Verbose $chkName - If ($eventNameParam -eq $EventRuleItem.EventRuleName) { - $originalState = $objParams.Enabled - try { - $objParams.Enabled = $EventRuleItem.Enabled - Write-Host "Update: [$($EventRuleItem.SiteName)] [$($EventRuleItem.EventRuleName)] $originalState->$($EventRuleItem.Enabled)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - if ($pscmdlet.ShouldProcess($EventRuleItem.EventRuleName, "Enabled=$originalState" )) { - - if ($EventRuleItem.Trigger -eq "Folder Monitor") { - try { if ($EventRuleItem.FM_Path -ne $objParams.path) {$objParams.path = $EventRuleItem.FM_Path}} catch {$warnCount++} - try { if ($EventRuleItem.FM_CheckHealthInterval -ne $objParams.CheckHealthInterval) {$objParams.CheckHealthInterval = $EventRuleItem.FM_CheckHealthInterval}} catch {$warnCount++} - try { if ($EventRuleItem.FM_CheckHealth -ne $objParams.CheckHealth) {$objParams.CheckHealth = $EventRuleItem.FM_CheckHealth}} catch {$warnCount++} - try { if ($EventRuleItem.FM_IncludeSubfolders -ne $objParams.IncludeSubfolders) {$objParams.IncludeSubfolders = $EventRuleItem.FM_IncludeSubfolders}} catch {$warnCount++} - try { if ($EventRuleItem.FM_UseAlternateCredentials -ne $objParams.UseAlternateCredentials) {$objParams.UseAlternateCredentials = $EventRuleItem.FM_UseAlternateCredentials}} catch {$warnCount++} - try { if ($EventRuleItem.FM_UserName -ne $objParams.UserName) {$objParams.UserName = $EventRuleItem.FM_UserName}} catch {$warnCount++} - try { if ($EventRuleItem.FM_Password -ne $objParams.Password) {$objParams.Password = $EventRuleItem.FM_Password}} catch {$warnCount++} - try { if ($EventRuleItem.FM_UseFileSystemNotifications -ne $objParams.UseFileSystemNotifications) {$objParams.UseFileSystemNotifications = $EventRuleItem.FM_UseFileSystemNotifications }} catch {$warnCount++} - try { if ($EventRuleItem.FM_UsePeriodicDirectoryPoll -ne $objParams.UsePeriodicDirectoryPoll) {$objParams.UsePeriodicDirectoryPoll = $EventRuleItem.FM_UsePeriodicDirectoryPoll}} catch {$warnCount++} - try { if ($EventRuleItem.FM_PollIntervalSeconds -ne $objParams.PollIntervalSeconds) {$objParams.PollIntervalSeconds = $EventRuleItem.FM_PollIntervalSeconds }} catch {$warnCount++} - try { if ($EventRuleItem.FM_ArchiveSubFolderName -ne $objParams.ArchiveSubFolderName) {$objParams.ArchiveSubFolderName = $EventRuleItem.FM_ArchiveSubFolderName }} catch {$warnCount++} - try { if ($EventRuleItem.FM_UseInteractiveLogon -ne $objParams.UseInteractiveLogon) {$objParams.UseInteractiveLogon = $EventRuleItem.FM_UseInteractiveLogon }} catch {$warnCount++} - try { if ($EventRuleItem.FM_ArchiveLeftovers -ne $objParams.ArchiveLeftovers) {$objParams.ArchiveLeftovers = $EventRuleItem.FM_ArchiveLeftovers}} catch {$warnCount++} - try { if ($EventRuleItem.FM_AddTimestampToArchivedFileNames -ne $objParams.AddTimestampToArchivedFileNames) {$objParams.AddTimestampToArchivedFileNames = $EventRuleItem.FM_AddTimestampToArchivedFileNames }} catch {$warnCount++} - try { if ($EventRuleItem.FM_PollIntervalType -ne $objParams.PollIntervalType) {$objParams.PollIntervalType = $EventRuleItem.FM_PollIntervalType }} catch {$warnCount++} - try { if ($EventRuleItem.FM_PollInterval -ne $objParams.PollInterval) {$objParams.PollInterval = $EventRuleItem.FM_PollInterval }} catch {$warnCount++} - } - - if ($EventRuleItem.Trigger -eq "Scheduler (Timer) Event") { - try { if ($EventRuleItem.SCH_DailyEveryWeekDay -ne $objParams.DailyEveryWeekDay) {$objParams.DailyEveryWeekDay = $EventRuleItem.SCH_DailyEveryWeekDay} } catch {$warnCount++} - try { if ($EventRuleItem.SCH_DailyDayPeriod -ne $objParams.DailyDayPeriod) {$objParams.DailyDayPeriod = $EventRuleItem.SCH_DailyDayPeriod}} catch {$warnCount++} - try { if ($EventRuleItem.SCH_WeeklyWeekPeriod -ne $objParams.WeeklyWeekPeriod) {$objParams.WeeklyWeekPeriod = $EventRuleItem.SCH_WeeklyWeekPeriod}} catch {$warnCount++} - try { if ($EventRuleItem.SCH_WeeklySunday -ne $objParams.WeeklySunday) {$objParams.WeeklySunday = $EventRuleItem.SCH_WeeklySunday}} catch {$warnCount++} - try { if ($EventRuleItem.SCH_WeeklyMonday -ne $objParams.WeeklyMonday) {$objParams.WeeklyMonday = $EventRuleItem.SCH_WeeklyMonday}} catch {$warnCount++} - try { if ($EventRuleItem.SCH_WeeklyTuesday -ne $objParams.WeeklyTuesday) {$objParams.WeeklyTuesday = $EventRuleItem.SCH_WeeklyTuesday }} catch {$warnCount++} - try { if ($EventRuleItem.SCH_WeeklyWednesday -ne $objParams.WeeklyWednesday) {$objParams.WeeklyWednesday = $EventRuleItem.SCH_WeeklyWednesday}} catch {$warnCount++} - try { if ($EventRuleItem.SCH_WeeklyThursday -ne $objParams.WeeklyThursday) {$objParams.WeeklyThursday = $EventRuleItem.SCH_WeeklyThursday}} catch {$warnCount++} - try { if ($EventRuleItem.SCH_WeeklyFriday -ne $objParams.WeeklyFriday) {$objParams.WeeklyFriday = $EventRuleItem.SCH_WeeklyFriday}} catch {$warnCount++} - try { if ($EventRuleItem.SCH_WeeklySaturday -ne $objParams.WeeklySaturday) {$objParams.WeeklySaturday = $EventRuleItem.SCH_WeeklySaturday} } catch {$warnCount++} - try { if ($EventRuleItem.SCH_MonthlyFixedDay -ne $objParams.MonthlyFixedDay) {$objParams.MonthlyFixedDay = $EventRuleItem.SCH_MonthlyFixedDay} } catch {$warnCount++} - try { if ($EventRuleItem.SCH_MonthlyDayPeriod -ne $objParams.MonthlyDayPeriod) {$objParams.MonthlyDayPeriod = $EventRuleItem.SCH_MonthlyDayPeriod}} catch {$warnCount++} - try { if ($EventRuleItem.SCH_MonthlyMonthPeriod -ne $objParams.MonthlyMonthPeriod) {$objParams.MonthlyMonthPeriod = $EventRuleItem.SCH_MonthlyMonthPeriod}} catch {$warnCount++} - try { if ($EventRuleItem.SCH_MonthlyRelativeWeekday -ne $objParams.MonthlyRelativeWeekday) {$objParams.MonthlyRelativeWeekday = $EventRuleItem.SCH_MonthlyRelativeWeekday} } catch {$warnCount++} - try { if ($EventRuleItem.SCH_MonthlyWeekday -ne $objParams.MonthlyWeekday) {$objParams.MonthlyWeekday = $EventRuleItem.SCH_MonthlyWeekday} } catch {$warnCount++} - try { if ($EventRuleItem.SCH_YearlyFixedDay -ne $objParams.YearlyFixedDay) {$objParams.YearlyFixedDay = $EventRuleItem.SCH_YearlyFixedDay} } catch {$warnCount++} - try { if ($EventRuleItem.SCH_YearlyMonth -ne $objParams.YearlyMonth) {$objParams.YearlyMonth = $EventRuleItem.SCH_YearlyMonth }} catch {$warnCount++} - try { if ($EventRuleItem.SCH_YearlyDayPeriod -ne $objParams.YearlyDayPeriod) {$objParams.YearlyDayPeriod = $EventRuleItem.SCH_YearlyDayPeriod} } catch {$warnCount++} - try { if ($EventRuleItem.SCH_YearlyRelativeWeekday -ne $objParams.YearlyRelativeWeekday) {$objParams.YearlyRelativeWeekday = $EventRuleItem.SCH_YearlyRelativeWeekday} } catch {$warnCount++} - try { if ($EventRuleItem.SCH_YearlyWeekday -ne $objParams.YearlyWeekday) {$objParams.YearlyWeekday = $EventRuleItem.SCH_YearlyWeekday} } catch {$warnCount++} - try { if ($EventRuleItem.SCH_RepeatPattern -ne $objParams.RepeatPattern) {$objParams.RepeatPattern = $EventRuleItem.SCH_RepeatPattern} } catch {$warnCount++} - try { if ($EventRuleItem.SCH_RepeatRate -ne $objParams.RepeatRate) {$objParams.RepeatRate = $EventRuleItem.SCH_RepeatRate }} catch {$warnCount++} - try { if ($EventRuleItem.SCH_RepeatEnabled -ne $objParams.RepeatEnabled) {$objParams.RepeatEnabled = $EventRuleItem.SCH_RepeatEnabled} } catch {$warnCount++} - try { if ($EventRuleItem.SCH_DateTimeEnd -ne $objParams.DateTimeEnd) {$objParams.DateTimeEnd = $EventRuleItem.SCH_DateTimeEnd} } catch {$warnCount++} - try { if ($EventRuleItem.SCH_TimeEndEnabled -ne $objParams.TimeEndEnabled) {$objParams.TimeEndEnabled = $EventRuleItem.SCH_TimeEndEnabled} } catch {$warnCount++} - try { if ($EventRuleItem.SCH_DateEndEnabled -ne $objParams.DateEndEnabled) {$objParams.DateEndEnabled = $EventRuleItem.SCH_DateEndEnabled} } catch {$warnCount++} - try { if ($EventRuleItem.SCH_RundayCalendar -ne $objParams.RundayCalendar) {$objParams.RundayCalendar = $EventRuleItem.SCH_RundayCalendar} } catch {$warnCount++} - try { if ($EventRuleItem.SCH_HolidayCalendar -ne $objParams.HolidayCalendar) { $objParams.HolidayCalendar = $EventRuleItem.SCH_HolidayCalendar} } catch {$warnCount++} - #try { if ($EventRuleItem.FM_CheckHealthInterval -ne $objParams.CheckHealthInterval) {ry {$objParams.NextRun = $EventRuleItem.SCH_NextRun } catch} {} - try { if ($EventRuleItem.SCH_Recurrence -ne $objParams.Recurrence) {$objParams.Recurrence = $EventRuleItem.SCH_Recurrence }} catch {$warnCount++} - try { if ($EventRuleItem.SCH_DateTimeStart -ne $objParams.DateTimeStart) {$objParams.DateTimeStart = $EventRuleItem.SCH_DateTimeStart} } catch {$warnCount++} - } - - if ($script:EftServer.HAEnabled) { - try { - $EFTHAParams = $EventRuleItem.HA_SchedulingParams -split "," - $EFTHAParams = $EFTHAParams | Where-Object {$_ -ne ""} - - if ($EFTHAParams.lenght -gt 0) { - $params = new-object -ComObject "SFTPCOMInterface.CIRoundRobinEventRuleSchedulingParams" - foreach ($nodeName in $EFTHABackupParams) { - $params.Add($nodeName) - } - $objEvent.SetHASchedulingParams($params) - } - } - catch { - $warnCount++ - } - try { - $EFTHABackupParams = $EventRuleItem.HA_SchedulingBackupParams -split "," - $EFTHABackupParams = $EFTHABackupParams | Where-Object {$_ -ne ""} - if ($EFTHAParams.lenght -gt 0) { - $paramsBackup = new-object -ComObject "SFTPCOMInterface.CIRoundRobinEventRuleSchedulingParams" - foreach ($nodeName in $EFTHABackupParams) { - $paramsBackup.Add($nodeName) - } - $objEvent.SetHABackupSchedulingParams($paramsBackup) - } - } - catch { - $warnCount++ - } - } - $objEvent.SetParams($objParams) - } - $changed++ - if($warnCount -gt 0) { - Write-host " WARN [$warnCount]" -ForegroundColor Yellow -NoNewline - } - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - $processed = $true - break - } - catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_EVENTRULE_NOT_FOUND { Write-host "MXE_EVENTRULE_NOT_FOUND : $_ " -ForegroundColor Red } - $MXE_EVENT_FM_FOLDER_NOT_ACCESSIBLE { Write-host "MXE_EVENT_FM_FOLDER_NOT_ACCESSIBLE : $_ " -ForegroundColor Red } - $MXE_EVENTRULE_CHANGEDESC_MISSING { Write-host "MXE_EVENTRULE_CHANGEDESC_MISSING : $_ " -ForegroundColor Red } - $MXE_EVENT_AW_TASK_DOES_NOT_EXIST { Write-host "MXE_EVENT_AW_TASK_DOES_NOT_EXIST : $_ " -ForegroundColor Red } - $MXE_EVENT_COMMAND_DOES_NOT_EXIST { Write-host "MXE_EVENT_COMMAND_DOES_NOT_EXIST : $_ " -ForegroundColor Red } - $MXE_EVENT_PGP_PASS_INVALID { Write-host "MXE_EVENT_PGP_PASS_INVALID : $_ " -ForegroundColor Red } - $MXE_EVENT_INVALID { Write-host "MXE_EVENT_INVALID : $_ " -ForegroundColor Red } - Default { Write-host "Exception : $_" -ForegroundColor Red} - } - $errorCount++ - } - } - } - if ($processed) { - break - } - } - } - if ($processed) { - break - } - } - -} -$script:EftServer.close() - -Write-host " Updated: " -NoNewline -Write-host "$updateCount " -NoNewline -ForegroundColor green -Write-host "Errors: "-NoNewline -Write-host "$errorCount " -ForegroundColor red -Write-host " " - - - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Export-SerialsKeys.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Export-SerialsKeys.ps1 deleted file mode 100644 index 719cd51..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Export-SerialsKeys.ps1 +++ /dev/null @@ -1,72 +0,0 @@ -## -## 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. -<# - - .SYNOPSIS - This Script retrives prduct serial codes from the node - .DESCRIPTION - This script will query the Windows registry and collect the serial numbers used by the node - .EXAMPLE - .\EFT.Export-SerialsKeys.ps1 | Tee-Object Executive_Config_Report.txt - .\EFT.Export-SerialsKeys.ps1 > report.txt - .NOTES - Globalscape Inc. - Version: 1.0 - Last Modified Date: 09/24/2017 - This script is intended to be run safetly without impacting or changing any EFT configuration, so you can use it any time as many times you would like. -#> -[CmdletBinding()] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $Hostname = "localhost" -) - -$serials = @() -$DMZGateway = "IOleVariance.Source2" -$EFTAS2 = "HIERCOJ\GREEN" -$AWE = "NL.wga.wGm.B2008" -$EFT6Baseline = "RDK" -$EFT7Baseline = "R2D2" -$EFT6Enterprise = "Win64.compat/wow64" -$EFT7Enterprise = "SMB.cluster\availability" -$HighSecurity = "GRR\TRIAM" -$DMZ3SingleSite = "IOleVariance.Source3" -$DMZ3MultiSite = "IOleVariance.Source4" -$Workspaces = "IOleVariance.Source7" -$ARM = "ARM_RANdl.1" -$PGP = "SPLehP\dlog8" -$CIC = "HKEY_CLASSES_ROOT\IOleVariance.Source6" -$EFT73WTCCAL = "NNIF\NAMUH" -$EFT73WTCCAL = "DTI\EWB" -$EFT73SMBFileTransferClient = "SCL" -$EFT73SMBFolderMonitorEventRule = "SFM" -$EFT73SMBTimerEventModule = "STM" - -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "DMZGateway" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($DMZGateway).GetValue('1')) } } catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "EFTAS2" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($EFTAS2).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "AWE" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($AWE).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "EFT6Baseline" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($EFT6Baseline).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "EFT7Baseline" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($EFT7Baseline).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "EFT6Enterprise" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($EFT6Enterprise).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "EFT7Enterprise" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($EFT7Enterprise).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "HighSecurity" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($HighSecurity).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "DMZ3SingleSite" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($DMZ3SingleSite).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "DMZ3MultiSite" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($DMZ3MultiSite).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "Workspaces" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($Workspaces).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "ARM" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($ARM).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "PGP" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($PGP).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "CIC" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($CIC).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "EFT73WTCCAL" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($EFT73WTCCAL).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname; Name = "EFT73WTCCAL" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($EFT73WTCCAL).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname;Name = "EFT73SMBFileTransferClient" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($EFT73SMBFileTransferClient).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname;Name = "EFT73SMBFolderMonitorEventRule" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($EFT73SMBFolderMonitorEventRule).GetValue('1')) } }catch {} -try { $serials += new-object psobject -Property @{ ComputerName = $Hostname;Name = "EFT73SMBTimerEventModule" ; Serial = [System.Text.Encoding]::ASCII.GetString([Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('ClassesRoot',$Hostname).OpenSubKey($EFT73SMBTimerEventModule).GetValue('1')) } }catch {} - -$serials | Format-Table - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.FolderPermissions.Export-OrphanPaths.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.FolderPermissions.Export-OrphanPaths.ps1 deleted file mode 100644 index 246912f..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.FolderPermissions.Export-OrphanPaths.ps1 +++ /dev/null @@ -1,98 +0,0 @@ -## -## 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 \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.FolderPermissions.Export.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.FolderPermissions.Export.ps1 deleted file mode 100644 index b62d212..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.FolderPermissions.Export.ps1 +++ /dev/null @@ -1,207 +0,0 @@ -## -## 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 = 0, Mandatory = $false, HelpMessage = "path filter (I.E. /usr/*), wildcards allowed")] - [String]$path = "", - - [Parameter(Position = 1, Mandatory = $false, HelpMessage = "Client name, filter to this client (Optional)")] - [String]$client = "", - - [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, - - [Parameter(Position = 7, Mandatory = $False, HelpMessage = "Validate Physical Path exists and Client (user or group exists) ")] - [switch] $Validate = $false, - - [Parameter(Mandatory = $false, HelpMessage = "Show inherited permissions")] - [switch]$showInherited = $false -) -## To Export to CSV use: -## .\EFT.FolderPermissions.Export.ps1 |Format-Table -## .\EFT.FolderPermissions.Export.ps1 | Export-csv permissions.csv -NoTypeInformation -## .\EFT.FolderPermissions.Export.ps1 -EFTSiteName "MySite" -## .\EFT.FolderPermissions.Export.ps1 -FolderFilter "/usr/*" -## .\EFT.FolderPermissions.Export.ps1 -FolderFilter "/usr/*" -client "Guest" -## .\EFT.FolderPermissions.Export.ps1 -EFTSiteName "MySite" | Where-Object {$_.Permissions -gt 1152} | format-table - -Function PermissionsToInt($permission) { - - $permissionAsInt = 0 - - if ($null -ne $permission) { - if ($permission.FileUpload -eq $true) {$permissionAsInt += 1} - if ($permission.FileDelete -eq $true) {$permissionAsInt += 2} - if ($permission.FileRename -eq $true) {$permissionAsInt += 4} - if ($permission.FileAppend -eq $true) {$permissionAsInt += 8} - if ($permission.FileDownload -eq $true) {$permissionAsInt += 16} - if ($permission.DirCreate -eq $true) {$permissionAsInt += 32} - if ($permission.DirDelete -eq $true) {$permissionAsInt += 64} - if ($permission.DirList -eq $true) {$permissionAsInt += 128} - if ($permission.DirShowHidden -eq $true) {$permissionAsInt += 256} - if ($permission.DirShowReadOnly -eq $true) {$permissionAsInt += 512} - if ($permission.DirShowInList -eq $true) {$permissionAsInt += 1024} - } - return $permissionAsInt -} -Function StripVirtualPortion ($path) { - if ($path -like "* - Virtual*") { - $path = $path.Substring(0, $path.Indexof(" - Virtual")) - } - return $path -} - -$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 - $errorCount = 0 - # Retrieve all the paths that have permissions in the config and decorate the orphans with a * - $folders = $script:EftSite.GetPermPathsList("-do") - if ($Validate) { - $users = $script:EftSite.GetUsers() - $groups = $script:EftSite.GetPermissionGroups() - } - $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] -eq "*") { - continue - } - - if ($path -ne "" -and $folder -notlike $path) { - continue - } - - $folder = StripVirtualPortion($folder) - try { - $permissions = $script:EftSite.GetFolderPermissions($folder) - } - catch [System.Runtime.InteropServices.COMException] { - switch ($_) { - $MXE_FOLDER_NOT_FOUND { $Errors = "**MXE_FOLDER_NOT_FOUND** : $_ " } - $MXE_INVALID_FOLDER_NAME { $Errors = "**MXE_INVALID_FOLDER_NAME** : $_ "} - Default { $Errors = "**Exception** : $_"} - } - $errorCount++ - continue - } - Foreach ($permission in $permissions) { - - ## Is this filtered to a client? - if ($null -ne $client -and $client.Length -gt 0 -and $permission.Client -ne $client) { - continue - } - - $permissionsAsInt = PermissionsToInt $permission - $InheritedFrom = $permission.InheritedFrom - if ($InheritedFrom[-1] -ne '/') { - $InheritedFrom = $InheritedFrom + "/" - } - - ## Is this $showInherited - if ($showInherited -eq $false -and $permission.IsInherited -eq $true) { - continue - } - if ($Validate) { - try { - $physicalPath = $script:EftSite.GetPhysicalPath($folder) - - if (Test-Path $physicalPath) { - $ValidPath = "OK" - } - else { - $ValidPath = "FOLDER_NOT_FOUND: $physicalPath" - } - } - catch [System.Runtime.InteropServices.COMException] { - switch ($_) { - $MXE_FOLDER_NOT_FOUND { $ValidPath = "MXE_FOLDER_NOT_FOUND :$physicalPath $_ " } - Default { $ValidPath = "Exception: $_"} - } - } - catch { - $ValidPath = "ERROR : $physicalPath $_" - } - - - if ($users -contains $permission.Client -or $groups -contains $permission.Client) { - $ValidClient = "OK" - } - else { - $ValidClient = "USER_GROUP_NOT_FOUND" - } - } - - $results += new-object PSObject -Property @{ - SiteName = $script:EftSite.Name; - Path = $folder; - Client = $permission.Client; - Permissions = $permissionsAsInt; - IsInherited = $permission.IsInherited; - InheritedFrom = $InheritedFrom; - ValidPath = $ValidPath; - ValidClient = $ValidClient; - } - - } - } - -} -$results | Sort-Object SiteName, Path, Client - -$script:EftServer.close() - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.FolderPermissions.Import.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.FolderPermissions.Import.ps1 deleted file mode 100644 index a707207..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.FolderPermissions.Import.ps1 +++ /dev/null @@ -1,142 +0,0 @@ -## -## 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(SupportsShouldProcess)] -Param( - [Parameter(Position = 0, Mandatory = $false, HelpMessage = "Enter the permissions CSV file ")] - [string] $PermissionsCsvFile = "permissions.csv", - - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False )] - [switch]$Quiet = $false -) -Function IntToPermissions($permissionAsInt, $permission) { - - if ($null -ne $permission ) { - $permission.FileUpload = [bool](($permissionAsInt -band 1) -eq 1) - $permission.FileDelete = [bool](($permissionAsInt -band 2) -eq 2) - $permission.FileRename = [bool](($permissionAsInt -band 4) -eq 4) - $permission.FileAppend = [bool](($permissionAsInt -band 8) -eq 8) - $permission.FileDownload = [bool](($permissionAsInt -band 16) -eq 16) - $permission.DirCreate = [bool](($permissionAsInt -band 32) -eq 32) - $permission.DirDelete = [bool](($permissionAsInt -band 64) -eq 64) - $permission.DirList = [bool](($permissionAsInt -band 128) -eq 128) - $permission.DirShowHidden = [bool](($permissionAsInt -band 256) -eq 256) - $permission.DirShowReadOnly = [bool](($permissionAsInt -band 512) -eq 512) - $permission.DirShowInList = [bool](($permissionAsInt -band 1024) -eq 1024) - } - - return $permission -} - -if ($PermissionsCsvFile -eq "") { - #Uncomment the following to enter paramters for each site - # $EFTPermissions = @( - # @{ SiteName = "MySite"; Path = "\"; Client= "" IsInherited = "" ; InheritedFrom =""; Permissions = "" } - # @{ SiteName = "MySite"; Path = "\"; Client= "" IsInherited = "" ; InheritedFrom =""; Permissions = "" } - #) -} -else { - $EFTPermissions = Import-Csv $PermissionsCsvFile - # "SiteName","Path", "Client","Permissions",IsInherited","InheritedFrom" -} - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' -$MXE_FOLDER_NOT_FOUND = "MX Error: 82 (00000052)" -$MXE_INVALID_FOLDER_NAME = "MX Error: 97 (00000061)" -$MXE_FOLDER_NOT_EMPTY = "MX Error: 117 (00000075)" - -$MAX_PAD = 100 -$PAD_CHR = "." - -$EFTServer = new-object -ComObject "SFTPCOMInterface.CIServer" - -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $script:EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() - -$SiteList = @{} -for ($j = 0; $j -le $sitesCount - 1; $j++ ) { - $script:EftSite = $script:EftSites.Item($j) - $SiteList.Add($script:EftSite.Name, $script:EftSite.ID) -} - -Write-host "Importing Folder Permissions:" -$Imported = 0 -$errorCount = 0 -foreach ($EFTPermission in $EFTPermissions) { - try { - $script:EftSite = $script:EftSites.SiteByID($SiteList[$EFTPermission.SiteName]) - $requestedPermissionsAsInt = [int]$EFTPermission.Permissions - $folderPath = $EFTPermission.Path - $permissionsInherited = [bool]::Parse($EFTPermission.IsInherited) - if (!$permissionsInherited) { - Write-host "Importing: [$($EFTPermission.SiteName)] $($EFTPermission.Client) on $folderPath ->$requestedPermissionsAsInt".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $permission = IntToPermissions $requestedPermissionsAsInt $script:EftSite.GetBlankPermission($folderPath, $EFTPermission.Client) - $script:EftSite.SetPermission($permission, $false) - $Imported++ - Write-host " OK $($sw.ElapsedMilliseconds )ms" -ForegroundColor Green - } - } - catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_FOLDER_NOT_FOUND { Write-host "MXE_FOLDER_NOT_FOUND : $_ " -ForegroundColor Red } - $MXE_INVALID_FOLDER_NAME { Write-host "MXE_INVALID_FOLDER_NAME : $_ " -ForegroundColor Red } - $MXE_FOLDER_NOT_EMPTY { Write-host "MXE_FOLDER_NOT_EMPTY : $_ " -ForegroundColor Red } - Default { Write-host "Exception : $_" -ForegroundColor Red} - } - $errorCount++ - continue - } -} -$script:EftServer.close() - -Write-host " Imported: " -NoNewline -Write-host "$Imported " -NoNewline -ForegroundColor green -Write-host "Errors: "-NoNewline -Write-host "$errorCount " -ForegroundColor red -Write-host " " - - - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.FolderPermissions.Remove-OrphanPaths.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.FolderPermissions.Remove-OrphanPaths.ps1 deleted file mode 100644 index 6a7dbbc..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.FolderPermissions.Remove-OrphanPaths.ps1 +++ /dev/null @@ -1,187 +0,0 @@ -## 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(SupportsShouldProcess)] -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 -) -Function StripVirtualPortion ($path) { - if ($path -like "* - Virtual*") { - $path = $path.Substring(0, $path.Indexof(" - Virtual")) - } - return $path -} - -# -# the script will recreate the original physical path remove the permissions associated then remove -# -Write-host "******* EFT Remove Orphan permissions in paths SCRIPT 1.0 *************************************************" -ForegroundColor Yellow -if ($Quiet -eq $false) { - Write-host "When permissions are added to folders using EFT and if folders are deleted from the file system and not from EFT, " -ForegroundColor Yellow - Write-host "permissions still be stored in EFT and considered orphaned, this is as designed behiavour as when network is " -ForegroundColor Yellow - Write-host "unavialbile permissions must be kept so when the network access is restored permissions are not removed" -ForegroundColor Yellow - Write-host "" - Write-host "This script will create a virtual folder with original path associated with the orphan path" -ForegroundColor Yellow - Write-host "then it will remove the virtual folder using EFT API and removing its permisions from the EFT configuration" -ForegroundColor Yellow - Write-host " WARNING NOTES:" -ForegroundColor Yellow - Write-host " > This script will modify your EFT configuration and these changes can't be undone" -ForegroundColor Yellow - Write-host " > You must perform backups of your EFT config before using this script" -ForegroundColor Yellow - Write-host " > It is recommend you test this script in a non-production environment before " -ForegroundColor Yellow - Write-host " using in production to validate its functionality" -ForegroundColor Yellow - Write-host "******************************************************************************" -ForegroundColor Yellow -} -$CurrentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name -if ($EFTAdminAuthType -eq 1) { - $EFTAdminUsername = $CurrentUserName -} -$EftService = Get-Service "EFT *" -$adminPrivileges = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' - -#Output parameters -Write-Host "Current datetime : $(Get-Date -f $df)" -Write-Host "Current User : $CurrentUserName" -Write-Host "Admin Privileges : $adminPrivileges" -Write-host "EFT Server Service : " -NoNewline -$OriginalEFTServiceState = $EftService.Status -if ($EftService.Status -eq "Running") {Write-host "$($OriginalEFTServiceState)" -ForegroundColor Green} else {Write-host "$($OriginalEFTServiceState)" -ForegroundColor Red} -Write-host "EFT Admin Hostname : $EFTAdminHostname" -Write-host "EFT Admin Port : $EFTAdminPort" -Write-host "EFT Admin Auth Type : $EFTAdminAuthType" -Write-host "EFT Site Name : $EFTSiteName" -Write-host "EFT Admin Username : $EFTAdminUsername" - -if ($Quiet -eq $false) { - $continue = Read-Host -Prompt "Have you read and understand the warning notes (y/n)?" - if ($continue.ToUpper() -ne "Y") { - exit - } -} - -$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)" -$MXE_FOLDER_NOT_EMPTY = "MX Error: 117 (00000075)" - -$MAX_PAD = 100 -$PAD_CHR = "." - -$EFTServer = new-object -ComObject "SFTPCOMInterface.CIServer" - -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $script:EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() -$fixCount = 0 -$skipCount = 0 -$errorCount = 0 - -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 - } - } - $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") | Where-Object {$_[-1] -eq "*"} - - Foreach ($folder in $folderList) { - $i++ - Write-host "[$siteName] Removing orphan: $($folder) ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - # check if folder paths ends with * (orphans) and ignore - if ($folder[-1] -ne "*") { - Write-host " SKIPPED ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - Write-host "Folder without orphan permissions" - $skipCount++ - continue - } - $folder = $folder.Substring(0, $folder.Length - 1) - - $folder = StripVirtualPortion($folder) - try { - $physicalPath = $script:EftSite.GetPhysicalPath($folder) - - if (Test-Path $physicalPath) { - Write-host " SKIPPED ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Yellow - Write-host " WARNING: Pysical path '$physicalPath' does exist, possible access permissions issues for EFT service account?" - $skipCount++ - continue - } - #recreate original Path - - if ($pscmdlet.ShouldProcess($folder, "Remove($physicalPath) " )) { - $script:EftSite.CreateVirtualFolder($folder, $physicalPath, $false) - $script:EftSite.RemoveFolder($folder) - } - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - $fixcount++ - } - catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_FOLDER_NOT_FOUND { Write-host "MXE_FOLDER_NOT_FOUND : $_ " -ForegroundColor Red } - $MXE_INVALID_FOLDER_NAME { Write-host "MXE_INVALID_FOLDER_NAME : $_ " -ForegroundColor Red } - $MXE_FOLDER_NOT_EMPTY { Write-host "MXE_FOLDER_NOT_EMPTY : $_ " -ForegroundColor Red } - Default { Write-host "Exception : $_" -ForegroundColor Red} - } - $errorCount++ - continue - } - } - -} - -$script:EftServer.close() - -Write-host " Fixed: " -NoNewline -Write-host "$fixcount " -NoNewline -ForegroundColor green -Write-host "Skipped: " -NoNewline -Write-host "$skipCount " -NoNewline -ForegroundColor Yellow -Write-host "Errors: "-NoNewline -Write-host "$errorCount " -ForegroundColor red -Write-host " " - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.HA.ReconfigureAdvanceSettings.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.HA.ReconfigureAdvanceSettings.ps1 deleted file mode 100644 index d23633d..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.HA.ReconfigureAdvanceSettings.ps1 +++ /dev/null @@ -1,132 +0,0 @@ -## -## 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. - -<# -.SYNOPSIS - Exports PGP keys used in evet rules with its associated metadata. - .DESCRIPTION - This script will retrieve all PGP Keys used from all the event rules for all or a specific EFT site - -DrainingTimeoutSecs -Draining timeout in seconds allows you to adjust the time for ongoing event rules and transfers to complete before draining starts. -Default is 900 seconds (15 minutes). -Maximum is 86400 seconds (24 hours). -If set to 0, then immediately shutdown and do not drain. -HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\GlobalSCAPE Inc.\EFT Server 7.4\DrainingTimeoutSecs=900 - -ClusterOutOfSyncHealSecs -Amount of time in seconds that an HA node will wait for incoming administrative messages to arrive before declaring itself to be out-of-sync with the cluster and initiating draining and restart. -Default is 30 seconds. -If out of sync is detected, the node attempts to heal; if it can heal within the timeout period, the system resyncs and continues to operate as expected. -If out of sync is detected and cannot be repaired within the heal timeout period, the node will enter drain mode and then restart the service. -If set to 0, then do not attempt to heal; continue to operate the node out of sync. -HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\GlobalSCAPE Inc.\EFT Server 7.4\ClusterOutOfSyncHealSecs=30 - -ClusterCoherenceQueueMsmqType -By default the MSMQ Broadcasting. TCP method of broadcasting ftp.cfg changes was developed for environments that do not support multicast (e.g., Azure and vMotion). Although AWS does not support Multicast, this was developed prior to the support of this option and so uses the AWS SQS/SNS services for now. -To use the TCP instead of MSMQ Broadcasting, set the Advanced Registry key ClusterCoherenceQueueMsmqType to msmq-iterative -To use MSMQ Broadcasting, either delete the key or set the ClusterCoherenceQueueMsmqType = msmq-broadcasting -HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\GlobalSCAPE Inc.\EFT Server 7.4\ClusterCoherenceQueueMsmqType=msmq-multicast - -ClusterCoherenceQueueDetectPrivateIP -Used to explicitly define the IP/Subnet via registry entry/advanced property, localized per node. -The key should be created in the EFT Server 7.4 registry location -HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\GlobalSCAPE Inc.\EFT Server 7.4\ClusterCoherenceQueueDetectPrivateIP=autodetect - -It can either be set to autodetect (which is the default, which causes it to find and use the first private subnet it finds), or it can be set to the prefix of the interface to use (e.g., “192.168.0", "192.168." or "192.168" just the prefix of the subnet, with no quotes). -Changes made in the registry are recorded in the ActiveNodes.json (located in the HA cluster's Shared configuration folder), which is used automatically by the EFT nodes to pass information between themselves and should not be edited. -If you do not choose to use the default subnet on a particular EFT node, that node will simply place the IP address you put for the advanced properties key in the “IP” field. That IP address will be the one the other nodes use to try to talk to it. - - -.EXAMPLE - .\EFT.HA.ReconfigureAdvanceSettings.ps1 - - Reconfigure EFT to use TCP Unicast (msmq-iterative) with default values - This script may restart your EFT Service - -#> -[CmdletBinding()] -param ( - [Parameter(Position = 6, Mandatory = $False)] - [int] [ValidateRange(0, 86400)] $DrainingTimeoutSecs = 900, - - [Parameter(Position = 6, Mandatory = $False )] - [int] $ClusterOutOfSyncHealSecs = 30, - - [Parameter(Position = 6, Mandatory = $False )] - [string][ValidateSet("msmq-iterative","msmq-broadcasting","msmq-multicast")] $ClusterCoherenceQueueMsmqType = "msmq-iterative", - - [Parameter(Position = 6, Mandatory = $False )] - [int]$ClusterCoherenceQueueDetectPrivateIP = 0, - - [Parameter(Position = 6, Mandatory = $False )] - [switch]$Quiet = $false - -) -Write-host "******* EFT Reconfigure HA Mode SCRIPT 1.0 *************************************************" -ForegroundColor Yellow -if ($Quiet -eq $false) { - Write-host " WARNING NOTES:" -ForegroundColor Yellow - Write-host " > This script will modify your EFT registry settings it's recommended you make a backup " -ForegroundColor Yellow - Write-host " > You must perform backups of your EFT config and registry before using this script" -ForegroundColor Yellow - Write-host " > It is recommend you test this script in a non-production environment before " -ForegroundColor Yellow - Write-host " using in production to validate its functionality" -ForegroundColor Yellow - Write-host "******************************************************************************" -ForegroundColor Yellow -} -$CurrentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name -$EftService = Get-Service "EFT *" -$adminPrivileges = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' - - - -#Output parameters -Write-Host "Current datetime : $(Get-Date -f $df)" -Write-Host "Current User : $CurrentUserName" -Write-Host "Admin Privileges : $adminPrivileges" -Write-host "EFT Server Service : " -NoNewline -$OriginalEFTServiceState = $EftService.Status -if ($EftService.Status -eq "Running") {Write-host "$($OriginalEFTServiceState)" -ForegroundColor Green} else {Write-host "$($OriginalEFTServiceState)" -ForegroundColor Red} -Write-host "DrainingTimeoutSecs : $DrainingTimeoutSecs" -Write-host "ClusterOutOfSyncHealSecs : $ClusterOutOfSyncHealSecs" -Write-host "ClusterCoherenceQueueMsmqType : $ClusterCoherenceQueueMsmqType" -Write-host "ClusterCoherenceQueueDetectPrivateIP: $ClusterCoherenceQueueDetectPrivateIP" - -if ($Quiet -eq $false) { - $continue = Read-Host -Prompt "Have you read and understand the warning notes (y/n)?" - if ($continue.ToUpper() -ne "Y") { - exit - } -} - - -$EFTServerPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\" -New-Item -Path $EFTServerPath -Name "EFT Server 7.4" -Force | Out-Null - -$EFTServer74RegPath = "$($EFTServerPath)\EFT Server 7.4" -Set-ItemProperty -Path $EFTServer74RegPath -Name DrainingTimeoutSecs -value $DrainingTimeoutSecs -Force -Set-ItemProperty -Path $EFTServer74RegPath -Name ClusterOutOfSyncHealSecs -value $ClusterOutOfSyncHealSecs -Force -Set-ItemProperty -Path $EFTServer74RegPath -Name ClusterCoherenceQueueMsmqType -value $ClusterCoherenceQueueMsmqType -Force -Set-ItemProperty -Path $EFTServer74RegPath -Name ClusterCoherenceQueueDetectPrivateIP -value $ClusterCoherenceQueueDetectPrivateIP -Force - -$EftService = Get-Service "EFT *" - -$restart = "y" -if ($Quiet -eq $false) { - $restart = Read-Host "Do you want to restart EFT Service now (y/n)? " -} - -if ($restart.ToUpper() -eq "Y" ) { - $EftService | Restart-Service - - $sw.Restart() - Write-host "Waiting EFT Service to be Started ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $EftService.WaitForStatus("Running", "00:00:30") - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.HealthCheck.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.HealthCheck.ps1 deleted file mode 100644 index f998e9b..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.HealthCheck.ps1 +++ /dev/null @@ -1,154 +0,0 @@ -## -## Copyright (C) 2019 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. - -<# - .SYNOPSIS - performs a series of Healthchecks to a node and exports the results . - .DESCRIPTION - performs a series of Healthchecks to a node and exports the results - .EXAMPLE - .\EFT.Healthcheck..ps1 | Export-Csv .\HealthCheck_Report.csv -NoTypeInformation -#> -[CmdletBinding()] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password - -) -function Invoke-Check_CA001 () { - $score = 0 - - if ([System.Environment]::OSVersion.Version.Major -ge 6 -and [System.Environment]::OSVersion.Version.Minor -ge 3 ) { - # Windows Server 2012 R2 - $score = 0.5 - } - if ([System.Environment]::OSVersion.Version.Major -ge 10 ) { - $score = 1 - } - return new-object psobject -Property @{ - Category = "Architecture" ; - Code = "CA001"; Description = "Unsupported versions of OS running EFT"; Recommendation = "Migrate EFT to a Microsoft and Globalscape supported OS Version" - Source = ""; Severity = "High" - Value = (Get-WmiObject -class Win32_OperatingSystem).Caption; - Recommended = "Windows Server 2016" ; - Score = $score - } - -} -function Invoke-Check_CA002 () { - - -$EftServicePath = Get-WmiObject win32_service | Where-Object { $_.name -Like "EFT Server*"} | Select-Object pathname -ExpandProperty pathname -$EftServicePath = $EftServicePath -replace """", "" -$EftFileVersion = Get-ItemProperty $EftServicePath -name "VersionInfo" | Select-Object VersionInfo -ExpandProperty VersionInfo - - $score = 0 - - if ($EftFileVersion.ProductVersion.split(',')[0].trim() -eq 7 -and $EftFileVersion.ProductVersion.split(',')[1].trim() -ge 3) { - # EFT 7.3.X - $score = 0.5 - } - if ($EftFileVersion.ProductVersion.split(',')[0].trim() -eq 7 -and $EftFileVersion.ProductVersion.split(',')[1].trim() -eq 4 -and $EftFileVersion.ProductVersion.split(',')[2].trim() -eq 13 -and $EftFileVersion.ProductVersion.split(',')[3].trim() -eq 14 ) { - $score = 0.75 - } - if ($EftFileVersion.ProductVersion.split(',')[0].trim() -eq 7 -and $EftFileVersion.ProductVersion.split(',')[1].trim() -eq 4 -and $EftFileVersion.ProductVersion.split(',')[2].trim() -eq 13 -and $EftFileVersion.ProductVersion.split(',')[3].trim() -eq 15 ) { - $score = 1 - } - return new-object psobject -Property @{ - Category = "Architecture" ; - Code = "CA002"; Description = "Unsupported versions of EFT "; Recommendation = "Upgrade to EFT to GA release" - Source = ""; Severity = "High" - Value = $EftFileVersion.ProductVersion; - Recommended = "7.4.13.15" ; - Score = $score - } - -} - - -function Invoke-Check_CA003 (){ -## Check more than 1000 files in logs and logs size -} - -function Invoke-Check_CA004 (){ - ## Check for file invalid characters in event rules - return new-object psobject -Property @{ - Category = "Architecture" ; - Code = "CA004"; Description = "Unsupported versions of EFT "; Recommendation = "Upgrade to EFT to GA release" - Source = ""; Severity = "High" - Value = $EftFileVersion.ProductVersion; - Recommended = "7.4.13.15" ; - Score = $score - } - } -function Invoke-EFTConfiguration_Checks () { - $script:EftServer = $null - $script:EftSites = $null - $script:EftSite = $null - - # Check Service Account permissions on MSMQ - # Check Service Account Permissions on file share - - $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() - - 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) - - } - - $script:EftServer.close() - $script:EftSite = $null - $script:EftSites = $null - $script:EftServer = $null -} - -## Main validation checks -$results = @() -$results += Invoke-Check_CA001 -$results += Invoke-Check_CA002 -$results += Invoke-EFTConfiguration_Checks - -$results | Sort-Object Code - - - - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.InvokeEventRule.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.InvokeEventRule.ps1 deleted file mode 100644 index 44ff0b7..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.InvokeEventRule.ps1 +++ /dev/null @@ -1,220 +0,0 @@ -[CmdletBinding()] -Param( - [Parameter(Position = 0, Mandatory = $true, HelpMessage = "Enter the event rule name")] - [string] $EventRuleName = "PROCESS-Pull", - - [Parameter(Position = 1, Mandatory = $false, HelpMessage = "Enter a host name or IP address")] - [String] $EFTHost = "https://localhost:4433", - - [Parameter(Position = 2, Mandatory = $false, HelpMessage = "Enter login")] - [String] $EFTAdminUsername = "admin", - - [Parameter(Position = 3, Mandatory = $false, HelpMessage = "Enter password")] - [String] $Password = "Super2003" -) -## Make sure you have HKLM\SOFTWARE\WOW6432Node\GlobalScape Inc.\EFT Server 7.4\EventWebServiceResponseAddContextVariables = 1 -# to get all the context variables in the response body - - -$sw = [Diagnostics.Stopwatch]::StartNew() -$MAX_TIMEOUT = 1000 * 30 -$WAIT_SECONDS = 2 - -Enum ResultCodes { - UnhandledException = -1 - Success = 0 - ErrorInvokingWebService = 1 - UnkownResponse = 2 - EventRuleNotFound = 3 - FailureInvokingEventRule = 4 - ResponseTimeout = 5 - FilesWithErrors = 6 -} - -$customWebclientCode = @" -using System.Net; -public class CustomWebclientCode : WebClient { - public int TimeoutSeconds; - protected override WebRequest GetWebRequest(System.Uri address) { - WebRequest request = base.GetWebRequest(address); - if (request != null) { request.Timeout = TimeoutSeconds * 1000; } - return request; - } - public CustomWebclientCode() { - TimeoutSeconds = 300; // Timeout value by default - } -} -"@ - -## Private Functions -function Invoke-EventRule($RequestID) { - $output = "" - $url = "$EFTHost/WebService/InvokeEventRule?EventRuleName=$EventRuleName&EventParams=VAR.REQUEST_ID=$RequestID" - $webclient = New-Object CustomWebclientCode - $credCache = new-object System.Net.CredentialCache - #Setting timeout to 900 seconds - $webclient.TimeoutSeconds = 900 - $creds = new-object System.Net.NetworkCredential($EFTAdminUsername, $Password) - $credCache.Add($url, "Basic", $creds) - $webclient.Credentials = $credCache - [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true } - try { - $output = $webclient.DownloadString($url) - [System.Net.ServicePointManager]::ServerCertificateValidationCallback = $null - } - catch { - Write-Error "Error Calling EFT Web Service $_" - $returnCode = [ResultCodes]::ErrorInvokingWebService - } - - try { - $xml = New-Object -TypeName System.Xml.XmlDocument - $xml.LoadXml($output) - switch ($xml.root.ResultCode) { - "1" { $returnCode = [ResultCodes]::Success} - "-1" { $returnCode = [ResultCodes]::EventRuleNotFound} - "0" { $returnCode = [ResultCodes]::FailureInvokingEventRule} - default { $returnCode = [ResultCodes]::UnkownResponse} - } - - } - catch { - Write-Error "Error parsing Web Service result $_" - $returnCode = [ResultCodes]::UnkownResponse - } - return $returnCode, $xml -} -function Wait-File ($path) { - $fileReady = $false - $sw.Restart() - - while ($sw.ElapsedMilliseconds -le $MAX_TIMEOUT) { - if (test-path $path) { - $fileReady = $true - break - } - Start-Sleep $WAIT_SECONDS - } - $sw.Stop() - if (!($fileReady)) { - return [ResultCodes]::ResponseTimeout - } - else { - return [ResultCodes]::Success - } -} - -function Exec-Query( $sql, $parameters = @{}, $conn, $timeout = 30, [bool]$Wait = $false) { - - $cmd = new-object system.Data.SqlClient.SqlCommand($sql, $conn) - $cmd.CommandTimeout = $timeout - foreach ($p in $parameters.Keys) { - [Void] $cmd.Parameters.AddWithValue("@$p", $parameters[$p]) - } - $ds = New-Object system.Data.DataSet - $da = New-Object system.Data.SqlClient.SqlDataAdapter($cmd) - - # Query DB until results are found - - if (!($Wait)) { - $da.fill($ds) | Out-Null - return [ResultCodes]::Success, $ds - } - - #Query and wait for data - $dataReady = $false - $sw.Restart() - while ($sw.ElapsedMilliseconds -le $MAX_TIMEOUT) { - $da.fill($ds) | Out-Null - - if ($null -ne $ds.Tables[0] -and $ds.Tables[0].Rows.Count -ge 1) { - $dataReady = $true - break - } - Start-Sleep $WAIT_SECONDS - } - $sw.Stop() - if (!($dataReady)) { - return [ResultCodes]::ResponseTimeout, $null - } - else { - return [ResultCodes]::Success, $ds - } -} - - -## Main -Add-Type -TypeDefinition $customWebclientCode -Language CSharp -$returnCode = [ResultCodes]::Success - -$RequestID = [guid]::NewGuid() -write-host "RequestID: $RequestID" -$responsePath = "$RequestID" - -## Invoke EFT Event Rule -$output = Invoke-EventRule $RequestID -$returnCode = $output[0] -$responseXml = $output[1] - -# retrive the Event Transaction context value of the transaction -$EventTransactionId = $responseXml.root.ContextVariables.Variable | Where-Object { $_.Name -eq "EVENT.TRANSACTION_ID"} | Select-Object -ExpandProperty "#cdata-section" -Write-host "EventTransactionId: $EventTransactionId" - -#Exit if Error -if ($returnCode -ne [ResultCodes]::Success) { - return $returnCode -} - - -## Query for Files transfers -$sqlConn = New-Object System.Data.SqlClient.SqlConnection -$sqlConn.ConnectionString = "Server=GS0334;Integrated Security=true;Initial Catalog=EFTDB" - -$sqlConn.Open() -$result = exec-query 'select * from tbl_Transactions WHERE TransactionGUID = @EventTransactionId' -parameter @{EventTransactionId = $EventTransactionId} -conn $sqlConn -Wait $true - -$returnCode = $result[0] -if ($returnCode -ne [ResultCodes]::Success) { - return $returnCode -} -$data = $result[1] -$transactionID = $data.tables[0].TransactionID - -Write-host "transactionID: $transactionID" - -$result = exec-query 'Select * from tbl_Actions where TransactionID = @TransactionID' -parameter @{TransactionID = $transactionID} -conn $sqlConn - -$returnCode = $result[0] -if ($returnCode -ne [ResultCodes]::Success) { - return $returnCode -} -$actionTransactions = $result[1] - -Write-host "Actions" -$actionTransactions.tables[0] | Format-Table - -Write-host "Client Operations" -$transferTransactions = exec-query 'select * from tbl_ClientOperations where TransactionID = @TransactionID' -parameter @{TransactionID = $transactionID} -conn $sqlConn -$transferTransactions.tables[0] | Format-List - -foreach ($row in $transferTransactions.tables[0].Rows){ - if ($row.ResultID -ne 1 ) - { - $returnCode = [ResultCodes]::FilesWithErrors - } -} - -if ($returnCode -ne [ResultCodes]::Success) { - return $returnCode -} - -$sqlConn.Close() - -# ## Move the response to history -# if (!(Test-path $SchedulerQueueHistory)) { -# New-Item -ItemType directory -Path $SchedulerQueueHistory -# } -# $ArchivePath = "$SchedulerQueueHistory$RequestID" -# Move-Item $responsePath $ArchivePath - -$returnCode \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.PowerTools.Powershell.psd1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.PowerTools.Powershell.psd1 deleted file mode 100644 index cb1a581..0000000 Binary files a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.PowerTools.Powershell.psd1 and /dev/null differ diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.PowerTools.Powershell.psm1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.PowerTools.Powershell.psm1 deleted file mode 100644 index dc66041..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.PowerTools.Powershell.psm1 +++ /dev/null @@ -1,2322 +0,0 @@ -## -## 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. - - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - - -##################################################################### -## Server -##################################################################### -#region Server Functions -<# - .SYNOPSIS - Connects to an EFT Server - .DESCRIPTION - Given a host, port, authentication type, connects to an EFT server - .EXAMPLE - Connect-Eft localhost 1100 0 admin admin - This commands will connect to an EFT server listening in localhost using port 1100 and using - admin/admin as username/password. -#> -function Connect-Eft { - Param( - [Parameter(Position = 0, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $Hostname = "localhost", - - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] - [ValidateRange(0, 65535)] - $Port = 1100, - - [Parameter(Position = 2, 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)] - $AuthType = 1, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter login")] - [String] $Login, - - [Parameter(Position = 4, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password - ) - - Write-Verbose "hostname :$hostname" - Write-Verbose "port :$port" - Write-Verbose "Login :$login" - Write-Verbose "len(Password) :$password.length" - - $script:EftServer = new-object -ComObject "SFTPCOMInterface.CIServer" - - $script:EftServer.ConnectEx($hostname, $port, $AuthType, $login, $password) - $script:EftSites = $script:EftServer.Sites() - Write-Host "EFT Server connected: " $hostname -ForegroundColor Green -} - -<# - .SYNOPSIS - Disconnect the connection to EFT Server - .EXAMPLE - Disconnect-Eft - This commands will disconnect from an EFT server. -#> -function Disconnect-Eft() { - - if ($script:EftSite -ne $null) { - $result = [System.Runtime.Interopservices.Marshal]::ReleaseComObject($script:EftSite) - $script:EftSite = $null - } - if ($script:EftSites -ne $null) { - $result = [System.Runtime.Interopservices.Marshal]::ReleaseComObject($script:EftSites) - $script:EftSites = $null - } - if ($script:EftServer -ne $null) { - $script:EftServer.Close() - $result = [System.Runtime.Interopservices.Marshal]::ReleaseComObject($script:EftServer) - $script:EftServer = $null - } -} - -<# - .SYNOPSIS - Writes to host the status of connection to EFT - .EXAMPLE - Show-EftConnection -#> -function Show-EftConnection() { - if ($script:EftServer -eq $null) { - Write-Host "Disconnected" -ForegroundColor Red - } - else { - Write-Host "Connected" -ForegroundColor Green - } -} -#endregion - -##################################################################### -## Site and Sites -##################################################################### -#region Site Functions -function Get-EftSites() { - if ($script:EftServer -eq $null) { - Write-Host "You need to connect to EFT Server first" -ForegroundColor Red - exit - } - else { - $results = @() - for ($i = 0; $i -le $script:EftSites.Count() - 1; $i++ ) { - $site = $script:EftSites.Item($i) - $row = New-Object PSObject - $row | Add-Member -type NoteProperty -name SiteName -Value $site.Name - $row | Add-Member -type NoteProperty -name IsRunning -Value $site.IsStarted - $row | Add-Member -type NoteProperty -name "Active Sessions" -Value $site.GetConnectedCount() - $row | Add-Member -type NoteProperty -name UsersDefined -Value $site.UsersDefined - $row | Add-Member -type NoteProperty -name "WTC Sessions Active" -Value $site.WTCSessionsActive - $row | Add-Member -type NoteProperty -name "WTC Sessions Remaining" -Value $site.WTCSessionsActive - $row | Add-Member -type NoteProperty -name "Active Uploads" -Value $site.GetUploadCount() - $row | Add-Member -type NoteProperty -name "Active Downloads" -Value $site.GetDownloadCount() - $results += $row - } - return $results - Write-Host "Site '$siteName' not found" -ForegroundColor Red - } -} - - -function Get-EftSite { - [CmdletBinding()] - - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName - ) - - Write-Verbose "SiteName :$siteName" - - if ($script:EftServer -eq $null) { - Write-Host "You need to connect to EFT Server first" -ForegroundColor Red - return $null - } - else { - if ($script:EftSite -ne $null -and $script:EftSite.Name -eq $siteName) { - return $script:EftSite - } - else { - for ($i = 0; $i -le $script:EftSites.Count() - 1; $i++ ) { - $script:EftSite = $script:EftSites.Item($i) - if ($script:EftSite.Name -eq $siteName) { - Write-Host "Site '$siteName' selected" -ForegroundColor Green - return $script:EftSite - } - } - } - Write-Host "Site '$siteName' not found" -ForegroundColor Red - } - return $nulls -} -#endregion - - -##################################################### -## Users -##################################################### -#region User Functions -function GetUserSettings() { - param([String]$username) - - try { - if ($EftSite.DoesUsernameExist($username)) { - $global:user = $EftSite.GetUserSettings($username) - Write-Host "User '$username' selected" -ForegroundColor Green - return $global:user - } - else { - Write-Host "User '$username' doesn't exist" -ForegroundColor Red - return - } - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "Exception : $error[0]" -ForegroundColor Red - } -} - -function Get-EftUsers { - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName - ) - - $results = @() - - $dummy = Get-EftSite -siteName $siteName - - if ($script:EftSite -eq $null) { - Write-Host "You need to select a EFT Site first use Get-EftUsers -siteName " -ForegroundColor Red - } - else { - $users = $script:EftSite.GetUsers() - for ($i = 0; $i -le $users.length - 1; $i++ ) { - $username = $users[$i] - $detail = $script:EftSite.GetUserSettings($users[$i]) - $homeFolder = [String]$detail.GetHomeDirString() - - try { - $permission = $script:EftSite.GetFolderPermissions($homeFolder) | Where-Object {$_.Client -eq $username} - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "Permissions not found for User: $username and folder $homeFolder " -ForegroundColor Red - Write-Host "Exception : $error[0]" -ForegroundColor Red - } - - $permissionsAsInt = -1 - $permissionsAsInt = PermissionsToInt $permission - - $permissionGroups = "" - - try { - $permissionGroupsList = $script:EftSite.GetPermissionGroupsOfUser($username) - - for ($j = 0; $j -lt $permissionGroupsList.length; $j++ ) { - if ($permissionGroups.Length -gt 0) { - $permissionGroups += "|" - } - $permissionGroups += $permissionGroupsList[$j] - } - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "Groups not found for User: $username " -ForegroundColor Red - Write-Host "Exception : $error[0]" -ForegroundColor Red - } - - $o = "" - $v = New-Object Runtime.InteropServices.VariantWrapper($o) - - $expirationDate = New-Object DateTime - - $dummy = $detail.GetExpirationDate($o) - - $PhysicalHomefolder = "" - try { - $PhysicalHomefolder = [String]$script:EftSite.GetPhysicalPath($homeFolder) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "PhysicalHomefolder not found for folder : $homeFolder " -ForegroundColor Red - Write-Host "Exception : $error[0]" -ForegroundColor Red - } - ## SettingsTemplate, Username, Password, PasswordType, IsEnabled, FullName, ExpirationDate, - ## Description, Phone, Fax, Pager, Email, Custom1, Custom2, Custom3, Comments, HomeFolder, HomeFolderPermissions, Groups - - $results += [PSObject] @{ - SettingsTemplate = [String]$script:EftSite.GetUserSettingsLevel($users[$i]); - Username = $users[$i]; - Fullname = $detail.FullName; - Email = $detail.Email; - IsUserEnabled = [bool]$detail.GetEnableAccount(); - ExpirationDate = $o; - LastConnectionTime = $detail.LastConnectionTime; - CreationDate = $detail.AccountCreationTime; - LastActivity = $detail.LastModificationTime; - DaysInactive = [int]$LastConnectTimeSpan.TotalDays; - Homefolder = $homeFolder; - PhysicalHomefolder = $PhysicalHomefolder; - Description = $detail.Description; - Phone = $detail.Phone; - Fax = $detail.Fax; - Pager = $detail.Pager; - Custom1 = $detail.Custom1; - Custom2 = $detail.Custom2; - Custom3 = $detail.Custom3; - Comments = $detail.Comments; - HomeFolderPermissions = $permissionsAsInt; - Groups = $permissionGroups; - - - } - } - } - - return $results -} - -Function Get-EftInactiveUsers { - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName, - [Parameter(Mandatory = $true, HelpMessage = "Enter days inactive")] [int]$daysInactive - ) - - ## TODO: Add error trapping - - $users = @(Get-EftUsers -siteName $siteName) - $results = @() - - ##Write-Host "Get-EftInactiveUsers Process $($users.length) users" -ForegroundColor Red - - for ($i = 0; $i -lt $users.length; $i++ ) { - ##Write-Host "Get-EftInactiveUsers Process user '$($users[$i].Username)'" -ForegroundColor Red - - $detail = $script:EftSite.GetUserSettings($users[$i].Username) - - # Check creation time to as LastConnectTime is not set to a value (defaults to - # 11/30/1999) until user accessed site. - $CreateTimeSpan = [System.DateTime]::Now - [datetime]$detail.AccountCreationTime; - $LastConnectTimeSpan = [System.DateTime]::Now - [datetime]$detail.LastConnectionTime; - - - if ($LastConnectTimeSpan.TotalDays -ge $daysInactive -And $CreateTimeSpan.TotalDays -ge $daysInactive) { - ##Username, Email, IsEnabled, LastConnectionTime, CreationDate, LastActivity, InactivityDays, Homefolder, PhysicalHomefolder - - $results += [PSObject] @{ - Username = $users[$i].Username; - Email = $detail.Email; - IsUserEnabled = [bool]$detail.GetEnableAccount(); - LastConnectionTime = $detail.LastConnectionTime; - CreationDate = $detail.AccountCreationTime; - LastActivity = $detail.LastModificationTime; - DaysInactive = [int]$LastConnectTimeSpan.TotalDays; - Homefolder = [String]$detail.GetHomeDirString(); - PhysicalHomefolder = [String]$script:EftSite.GetPhysicalPath([String]$detail.GetHomeDirString()); - } - } - } - - return $results - -} - -<# - .SYNOPSIS - Removes inactive users (for x days) of an EFT site. Supports -WhatIf - .DESCRIPTION - Given an EFT site, removes users that have been inactive for at least -daysInactive. Supports -WhatIf - .PARAMETER siteName - EFT Site to query. Must exist. - .PARAMETER daysInactive - Days since last activity. - .EXAMPLE - Remove-EftInactiveUsers -siteName 'SOME_SITE' -daysInactive 12 -WhatIf -#> -Function Remove-EftInactiveUsers { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName, - [Parameter(Mandatory = $true, HelpMessage = "Enter days inactive")] [int]$daysInactive - ) - - ## TODO: Add error trapping - - $users = @(Get-EftInactiveUsers -siteName $siteName -daysInactive $daysInactive) - - if ($pscmdlet.ShouldProcess($siteName, 'RemoveInactiveUsers')) { - ## Delete the user. - try { - for ($i = 0; $i -lt $users.length; $i++ ) { - $users = $script:EftSite.RemoveUser($users[$i].Username) - } - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "User not found" -ForegroundColor Red - Write-Host "Exception : $error[0]" -ForegroundColor Red - } - } - else { - for ($i = 0; $i -lt $users.length; $i++ ) { - Write-Host "What if: Would remove user '$($users[$i].Username)' inactive for $($users[$i].DaysInactive) days." -ForegroundColor White - } - } -} - -<# - .SYNOPSIS - Disables inactive users (for x days) of an EFT site. Supports -WhatIf - .DESCRIPTION - Given an EFT site, disables users that have been inactive for at least -daysInactive. Supports -WhatIf - .PARAMETER siteName - EFT Site to query. Must exist. - .PARAMETER daysInactive - Days since last activity. - .EXAMPLE - Disable-EftInactiveUsers -siteName 'SOME_SITE' -daysInactive 12 -WhatIf -#> -Function Disable-EftInactiveUsers { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName, - [Parameter(Mandatory = $true, HelpMessage = "Enter days inactive")] [int]$daysInactive - ) - - ## TODO: Add error trapping - - $users = @(Get-EftInactiveUsers -siteName $siteName -daysInactive $daysInactive) - - if ($pscmdlet.ShouldProcess($siteName, 'DisableInactiveUsers')) { - ## Disable the user. - try { - for ($i = 0; $i -lt $users.length; $i++ ) { - if ($users[$i].IsUserEnabled -eq $true) { - $userSettings = $script:EftSite.GetUserSettings($users[$i].Username) - $userSettings.SetEnableAccount(0) - } - } - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "User not found" -ForegroundColor Red - Write-Host "Exception : $error[0]" -ForegroundColor Red - } - } - else { - for ($i = 0; $i -lt $users.length; $i++ ) { - if ($users[$i].IsUserEnabled -eq $true) { - Write-Host "What if: Would disable user '$($users[$i].Username)' inactive for $($users[$i].DaysInactive) days." -ForegroundColor White - } - } - } -} - -<# - .SYNOPSIS - Creates a CSV or XML file with list of inactive users (for x days) of an EFT site - .DESCRIPTION - Given an EFT site, get a list of users that have been inactive for at least -daysInactive - .PARAMETER siteName - EFT Site to query. Must exist. - .PARAMETER daysInactive - Days since last activity. - .PARAMETER exportType - Optional. The type of output file format. CSV|XML Defaults to CSV - .PARAMETER fileName - Output file name. May be relative or absolute path. Existing file will be overwritten. - .EXAMPLE - Export-EftInactiveUsers -siteName 'SOME_SITE' -daysInactive 12 -fileName "InactiveUsers.csv" -#> -Function Export-EftInactiveUsers { - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName, - [Parameter(Mandatory = $true, HelpMessage = "Enter days inactive")] [int]$daysInactive, - [Parameter(Mandatory = $false, HelpMessage = "Type of export (CSV (default), XML)")] [ValidateSet("XML", "CSV")] [String]$exportType = "CSV", - [Parameter(Mandatory = $true, HelpMessage = "File name")] [String] [ValidateScript( {Test-Path $_ -isValid})] $fileName - ) - - ## TODO: Add error trapping - - $users = @(Get-EftInactiveUsers -siteName $siteName -daysInactive $daysInactive) - - - ## Delete existing file if exists - if (Test-Path $fileName) { - Remove-Item $fileName - } - - $results = @() - - for ($i = 0; $i -lt $users.length; $i++ ) { - $obj = new-object PSObject - $obj | add-member -membertype NoteProperty -name "Username" -value $users[$i].Username - $obj | add-member -membertype NoteProperty -name "Email" -value $users[$i].Email - $obj | add-member -membertype NoteProperty -name "IsEnabled" -value $users[$i].IsUserEnabled - $obj | add-member -membertype NoteProperty -name "LastConnectionTime" -value $users[$i].LastConnectionTime - $obj | add-member -membertype NoteProperty -name "CreationDate" -value $users[$i].CreationDate - $obj | add-member -membertype NoteProperty -name "LastActivity" -value $users[$i].LastActivity - $obj | add-member -membertype NoteProperty -name "DaysInactive" -value $users[$i].DaysInactive - $obj | add-member -membertype NoteProperty -name "Homefolder" -value $users[$i].Homefolder - $obj | add-member -membertype NoteProperty -name "PhysicalHomefolder" -value $users[$i].PhysicalHomefolder - - $results += $obj - } - - if ($exportType -contains "CSV") { - $results | Export-Csv -Path $fileName -NoTypeInformation - } - elseif ($exportType -contains "XML") { - $results | Export-Clixml $fileName - } - -} - -<# - .SYNOPSIS - Creates a CSV or XML file with list of users of an EFT site - .DESCRIPTION - Given an EFT site, get a list of users. - .PARAMETER siteName - EFT Site to query. Must exist. - .PARAMETER exportType - Optional. The type of output file format. CSV|XML Defaults to CSV - .PARAMETER fileName - Output file name. May be relative or absolute path. Existing file will be overwritten. - .EXAMPLE - Export-EftUsers -siteName 'SOME_SITE' -fileName "Users.csv" -#> -Function Export-EftUsers { - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName, - [Parameter(Mandatory = $false, HelpMessage = "Type of export (CSV (default), XML)")] [ValidateSet("XML", "CSV")] [String]$exportType = "CSV", - [Parameter(Mandatory = $true, HelpMessage = "File name")] [String] [ValidateScript( {Test-Path $_ -isValid})] $fileName - ) - - ## TODO: Add error trapping - - $users = @(Get-EftUsers -siteName $siteName) - - - ## Delete existing file if exists - if (Test-Path $fileName) { - Remove-Item $fileName - } - - $results = @() - - for ($i = 0; $i -lt $users.length; $i++ ) { - - $obj = new-object PSObject - $obj | add-member -membertype NoteProperty -name "SettingsTemplate" -value $users[$i].SettingsTemplate - $obj | add-member -membertype NoteProperty -name "Username" -value $users[$i].Username - $obj | add-member -membertype NoteProperty -name "Password" -value $users[$i].Password - $obj | add-member -membertype NoteProperty -name "PasswordType" -value $users[$i].PasswordType - $obj | add-member -membertype NoteProperty -name "IsEnabled" -value $users[$i].IsUserEnabled - $obj | add-member -membertype NoteProperty -name "FullName" -value $users[$i].FullName - $obj | add-member -membertype NoteProperty -name "ExpirationDate" -value $users[$i].ExpirationDate - $obj | add-member -membertype NoteProperty -name "Email" -value $users[$i].Email - $obj | add-member -membertype NoteProperty -name "Description" -value $users[$i].Description - $obj | add-member -membertype NoteProperty -name "Phone" -value $users[$i].Phone - $obj | add-member -membertype NoteProperty -name "Fax" -value $users[$i].Fax - $obj | add-member -membertype NoteProperty -name "Pager" -value $users[$i].Pager - $obj | add-member -membertype NoteProperty -name "Custom1" -value $users[$i].Custom1 - $obj | add-member -membertype NoteProperty -name "Custom2" -value $users[$i].Custom2 - $obj | add-member -membertype NoteProperty -name "Custom3" -value $users[$i].Custom3 - $obj | add-member -membertype NoteProperty -name "Comments" -value $users[$i].Comments - $obj | add-member -membertype NoteProperty -name "Homefolder" -value $users[$i].Homefolder - $obj | add-member -membertype NoteProperty -name "PhysicalHomefolder" -value $users[$i].PhysicalHomefolder - $obj | add-member -membertype NoteProperty -name "HomeFolderPermissions" -value $users[$i].HomeFolderPermissions - $obj | add-member -membertype NoteProperty -name "Groups" -value $users[$i].Groups - $obj | add-member -membertype NoteProperty -name "CreationDate" -value $users[$i].CreationDate - - $results += $obj - } - - if ($exportType -contains "CSV") { - $results | Export-Csv -Path $fileName -NoTypeInformation - } - elseif ($exportType -contains "XML") { - $results | Export-Clixml $fileName - } - -} - -<# - .SYNOPSIS - Counts files within a folder path and its size - .DESCRIPTION - Given a path, it will count the number of files and the total size in bytes. - By default you can specify if the calculation will include subdirectories or just the current path - .PARAMETER path - the path where the count will start. path must exist. - .PARAMETER searchOptions - Optional. The search options. AllDirectories|TopDirectoryOnly Defaults to AllDirectories - .OUTPUTS - Output two values: - Foldersize: Total size in bytes - Filecount: Total count of files - LastException: Array with total exceptions found during the count process - - .EXAMPLE - $t = Get-CountFiles "C:\temp" - $t = Get-CountFiles -path "C:\temp" -searchOptions "TopDirectoryOnly" - - $t[0] # Outputs "Foldersize" - $t[1] # Outputs "Filecount" - $t[2] # Outputs "LastException" - .NOTES - LastException only contains the last exception as it could be too expensive to collect all exceptions from each file in the count. -#> -function Get-CountFiles { - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a path")] [ValidateScript( {Test-Path $_ })] [string]$path, - [Parameter(Mandatory = $false, HelpMessage = "Search Options: (AllDirectories (default), TopDirectoryOnly)")] [ValidateSet("AllDirectories", "TopDirectoryOnly")] [string]$searchOptions = 'AllDirectories' - ) - $foldersize = 0 - $filecount = 0 - $LastException = "" - $directoryFiles = $null; - try { - $directoryFiles = [System.IO.Directory]::EnumerateFiles($path, "*", $searchOptions) - } - catch { - $LastException = "Can't get enumerate files for folder '$path' Exception : $error[0]" - } - - if ($directoryFiles -ne $null) { - foreach ($directoryFile in $directoryFiles) { - try { - $file = New-Object System.IO.FileInfo -ArgumentList $directoryFile - $foldersize += $file.Length; - $filecount++; - } - catch { - $LastException = "Can't get file size from file '$directoryFile' Exception : $error[0]" - } - } - } - return $foldersize, $filecount, $LastException -} - -function Export-EftUserStorageSpace { - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName, - [Parameter(Mandatory = $false, HelpMessage = "Type of export (CSV (default), XML)")] [ValidateSet("XML", "CSV")] [String]$exportType = "CSV", - [Parameter(Mandatory = $true, HelpMessage = "File name")] [String] [ValidateScript( {Test-Path $_ -isValid})] $fileName - ) - - $users = @(Get-EftUsers -siteName $siteName) - - - ## Delete existing file if exists - if (Test-Path $fileName) { - Remove-Item $fileName - } - - $results = @() - - - for ($i = 0; $i -lt $users.length; $i++ ) { - $countResults = Get-CountFiles $users[$i].PhysicalHomefolder - - $obj = new-object PSObject - $obj | add-member -membertype NoteProperty -name "SettingsTemplate" -value $users[$i].SettingsTemplate - $obj | add-member -membertype NoteProperty -name "Username" -value $users[$i].Username - $obj | add-member -membertype NoteProperty -name "Email" -value $users[$i].Email - $obj | add-member -membertype NoteProperty -name "IsEnabled" -value $users[$i].IsUserEnabled - $obj | add-member -membertype NoteProperty -name "FullName" -value $users[$i].FullName - $obj | add-member -membertype NoteProperty -name "Homefolder" -value $users[$i].Homefolder - $obj | add-member -membertype NoteProperty -name "PhysicalHomefolder" -value $users[$i].PhysicalHomefolder - $obj | add-member -membertype NoteProperty -name "FolderSize" -value $countResults[0] - $obj | add-member -membertype NoteProperty -name "FileCount" -value $countResults[1] - $obj | add-member -membertype NoteProperty -name "FileCountLastException" -value $countResults[2] - $results += $obj - } - - if ($exportType -contains "CSV") { - $results | Export-Csv -Path $fileName -NoTypeInformation - } - elseif ($exportType -contains "XML") { - $results | Export-Clixml $fileName - } - -} -<# - .SYNOPSIS - Given a CSV file, adds or updates users for an EFT site - .DESCRIPTION - Given an EFT site, a CSV file of same format exported by Export-EftUsers, adds or updates users. Supports -WhatIf - .PARAMETER siteName - EFT Site to query. Must exist. - .PARAMETER fileName - Input file name. May be relative or absolute path. - .EXAMPLE - Import-EftUsersCsv -siteName 'SOME_SITE' -fileName "Users.csv" -#> -Function Import-EftUsersCsv { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName, - [Parameter(Mandatory = $true, HelpMessage = "File name")] [String] [ValidateScript( {Test-Path $_ -isValid})] $fileName - ) - - ## TODO: Add error trapping - - $dummy = Get-EftSite -siteName $siteName - - if ($script:EftSite -eq $null) { - Write-Host "You need to select a EFT Site first use Import-EftUsersCsv -siteName " -ForegroundColor Red - } - else { - ## Get existing users - $existingUsers = $script:EftSite.GetUsers() - - $isWhatIf = $true - if ($pscmdlet.ShouldProcess($siteName, 'AddUpdateUsers')) { - $isWhatIf = $false - } - - - ## Open the CSV file and process - $users = Import-Csv $fileName - ForEach ($user in $users) { - $login = $user.Username - $isNewUser = $true - - if ($existingUsers -contains $login) { - Write-Verbose "User '$($user.Username)' already exists." - $isNewUser = $false - } - - if ($isWhatIf -eq $false) { - - if ($isNewUser -eq $true) { - ## Add the user. - try { - $newUser = new-object -ComObject "SFTPCOMInterface.CINewUserData" - - $newUser.Login = $login - $newUser.Password = if ([string]::IsNullOrEmpty($user.Password)) { "" } else { $user.Password } - $newUser.PasswordType = if ([string]::IsNullOrEmpty($user.PasswordType)) { 0 } else { [int]$user.PasswordType } - $newUser.Description = if ([string]::IsNullOrEmpty($user.Description)) { "" } else { $user.Description } - $newUser.FullName = if ([string]::IsNullOrEmpty($user.FullName)) { "" } else { $user.FullName } - $newUser.Email = if ([string]::IsNullOrEmpty($user.Email)) { "" } else { $user.Email } - $newUser.CreateHomeFolder = $false - $newUser.FullPermissionsForHomeFolder = $false - $newUser.SettingsLevel = if ([string]::IsNullOrEmpty($user.SettingsTemplate)) { "" } else { $user.SettingsTemplate } - $newUser.TwoFactorAuthentication = -2 - - - $script:EftSite.CreateUserEx2($newUser) - - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "Failed adding user '$($login)'" -ForegroundColor Red - Write-Host "Exception : $($_.Exception.Message)" -ForegroundColor Red - return - } - } - - - ## Get user settings. - $userSettings = $script:EftSite.GetUserSettings($login); - - $userSettings.Phone = if ([string]::IsNullOrEmpty($user.Phone)) { "" } else { $user.Phone } - $userSettings.Fax = if ([string]::IsNullOrEmpty($user.Fax)) { "" } else { $user.Fax } - $userSettings.Pager = if ([string]::IsNullOrEmpty($user.Pager)) { "" } else { $user.Pager } - $userSettings.Custom1 = if ([string]::IsNullOrEmpty($user.Custom1)) { "" } else { $user.Custom1 } - $userSettings.Custom2 = if ([string]::IsNullOrEmpty($user.Custom2)) { "" } else { $user.Custom2 } - $userSettings.Custom3 = if ([string]::IsNullOrEmpty($user.Custom3)) { "" } else { $user.Custom3 } - $userSettings.Comment = if ([string]::IsNullOrEmpty($user.Comment)) { "" } else { $user.Comment } - - if ([System.Convert]::ToBoolean($user.IsEnabled)) {$userSettings.SetEnableAccount(1)} else {$userSettings.SetEnableAccount(0)} - - if (-not $isNewUser) { - if ([string]::IsNullOrEmpty($user.Description)) { - $userSettings.SetDescription( "" ) - } - else { - $userSettings.SetDescription( $user.Description ) - } - $userSettings.FullName = if ([string]::IsNullOrEmpty($user.FullName)) { "" } else { $user.FullName } - $userSettings.Email = if ([string]::IsNullOrEmpty($user.Email)) { "" } else { $user.Email } - - try { - if (-not ([string]::IsNullOrEmpty($user.Password))) { - $script:EftSite.ChangeUserPassword($login, $user.Password, [int]$user.PasswordType); - } - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "Failed changing password for '$($login)'. Did you re-use password?" -ForegroundColor Red - } - - if (-not ([string]::IsNullOrEmpty($user.SettingsTemplate))) { - $script:EftSite.MoveUserToSettingsLevel($login, $user.SettingsTemplate) - } - - } - - - - - ## Is there an expiration date? - if (-not ([string]::IsNullOrEmpty($user.ExpirationDate))) { - $expirationDate = Get-Date -Date $user.ExpirationDate - $userSettings.SetExpirationDate($expirationDate, $true); - Write-Verbose "Set Expiration Date: $($expirationDate)" - } - - ## See if home folder needs to be updated. - if (-not ([string]::IsNullOrEmpty($user.HomeFolder))) { - if ($user.HomeFolder -ne $userSettings.GetHomeDirString()) { - try { - Write-Verbose "Create home folder: $($user.HomeFolder)" - $script:EftSite.CreatePhysicalFolder($user.HomeFolder) - - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "Unable to create physical folder for '$($user.HomeFolder)'. Probably already exists." -ForegroundColor Red - } - - - try { - Write-Verbose "Assign home folder: $($user.HomeFolder)" - $userSettings.SetHomeDir(1); - $userSettings.SetHomeDirIsRoot(1); - $userSettings.SetHomeDirString($user.HomeFolder) - - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "Unable to set home folder '$($user.HomeFolder)' for user '$($login)'." -ForegroundColor Red - Write-Host "Exception : $($_.Exception.Message)" -ForegroundColor Red - return - } - } - } - - ## Home folder permissions. - ## Get existing permissions - $requestedPermissionsAsInt = [int]$user.HomeFolderPermissions - $permission = $script:EftSite.GetFolderPermissions($user.HomeFolder) | Where-Object {$_.Client -eq $login} - $permissionsAsInt = PermissionsToInt $permission - - if ($permission -eq $null -or $requestedPermissionsAsInt -ne $permissionsAsInt) { - ## Are permissions being removed? - if ($requestedPermissionsAsInt -eq -1) { - $script:EftSite.RemovePermission($user.HomeFolder, $login) - } - else { - ## Is there a permissions object on home folder? - $permission = IntToPermissions $requestedPermissionsAsInt $script:EftSite.GetBlankPermission($user.HomeFolder, $login) - $script:EftSite.SetPermission($permission, $false) - } - } - - - ## Groups - if (-not ([string]::IsNullOrEmpty($user.Groups))) { - $requestedGroups = $user.Groups.Split([string[]]"|", 'None') - $existingGroups = $script:EftSite.GetPermissionGroupsOfUser($login) - - $groupsToAdd = $requestedGroups | where {$existingGroups -notcontains $_} - $groupsToRemove = $existingGroups | where {$requestedGroups -notcontains $_} - - foreach ($gta in $groupsToAdd) { - Write-Verbose "Group to add '$($gta)'." - try { - $script:EftSite.AddUserToPermissionGroup($login, $gta) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "Unable to add user '$($login)' to permission group '$($gta)'. Group may not exist." -ForegroundColor Red - } - } - - foreach ($gtr in $groupsToRemove) { - Write-Verbose "Group to remove '$($gtr)'." - try { - $script:EftSite.RemoveUserFromPermissionGroup($login, $gtr) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "Unable to remove user '$($login)' from permission group '$($gtr)'. Group may not exist." -ForegroundColor Red - } - } - } - } - else { - if ($isNewUser) { - Write-Host "What if: Would add user '$($user.Username)'." -ForegroundColor White - } - else { - Write-Host "What if: Would update user '$($user.Username)'." -ForegroundColor White - } - } - } - } -} -#endregion - - -##################################################### -## VFS Folders -##################################################### -#region Folder Functions -Function GetEftFolders($startingFolder, [ref]$folderList) { - - $folderString = $script:EftSite.GetFolderList($startingFolder) - if ($folderString -ne "") { - $folders = $folderString.Split([string[]]"`r`n", 'None') - - For ($i = 0; $i -lt $folders.Length; $i++) { - if ($folders[$i] -ne "") { - - if ($startingFolder[-1] -ne '/') { - $fullyQualifiedFolder = $startingFolder + "/" + $folders[$i] - } - else { - $fullyQualifiedFolder = $startingFolder + $folders[$i] - } - - $folderList.Value += $fullyQualifiedFolder - GetEftFolders $fullyQualifiedFolder $folderList - } - } - } -} - - -<# - .SYNOPSIS - Creates a CSV or XML file with list of VFS folders - .DESCRIPTION - Given an EFT site, get a list of VFS folders starting from a given path. The path is of the form /xxx/yyy - .PARAMETER siteName - EFT Site to query. Must exist. - .PARAMETER startingFolder - Virtual folder to start from. For instance, if you wanted to get all folders of users, pass /Usr - .PARAMETER client - Optional. Filter to show only folder permissions associated with a given user (client) - .PARAMETER showInherited - Optional. True/False whether to export all of the folders whether permissions are inherited or not. Defaults to False. - .PARAMETER exportType - Optional. The type of output file format. CSV|XML Defaults to CSV - .PARAMETER fileName - Output file name. May be relative or absolute path. Existing file will be overwritten. - .EXAMPLE - Export-EftFolders -siteName 'SOME_SITE' -startingFolder "/usr" -showInherited $true -fileName "Folders.csv" -client ron -#> -Function Export-EftFolders { - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName, - [Parameter(Mandatory = $true, HelpMessage = "Starting folder (I.E. /usr/Bob)")] [String]$startingFolder, - [Parameter(Mandatory = $false, HelpMessage = "Client name, filter to this client (Optional)")] [String]$client, - [Parameter(Mandatory = $false, HelpMessage = "Show inherited permissions")] [bool]$showInherited = $false, - [Parameter(Mandatory = $false, HelpMessage = "Type of export (CSV (default), XML)")] [ValidateSet("XML", "CSV")] [String]$exportType = "CSV", - [Parameter(Mandatory = $true, HelpMessage = "File name")] [String] [ValidateScript( {Test-Path $_ -isValid})] $fileName - ) - - ## TODO: Add error trapping - - $dummy = Get-EftSite -siteName $siteName - - $folderList = @() - $folderDetailsList = @() - - $folderList += $startingFolder - - ## Get list of all folders under $startingFolder - GetEftFolders $startingFolder ([ref]$folderList) - - ## Now get details on each folder. - - - Foreach ($folder in $folderList) { - ## Foreach $script:EftSite.GetFolderPermissions($folder) see if $showInherited - - $permissions = $script:EftSite.GetFolderPermissions($folder) - - Foreach ($permission in $permissions) { - - ## Is this filtered to a client? - if ($client -ne $null -and $client.Length -gt 0 -and $permission.Client -ne $client) { - continue - } - - ## Is this $showInherited - if ($showInherited -eq $false -and $permission.IsInherited -eq $true) { - continue - } - - $permissionsAsInt = PermissionsToInt $permission - - $obj = new-object PSObject - $obj | add-member -membertype NoteProperty -name "Client" -value $permission.Client - $obj | add-member -membertype NoteProperty -name "Path" -value $folder - $obj | add-member -membertype NoteProperty -name "PhysicalPath" -value $script:EftSite.GetPhysicalPath($folder) - $obj | add-member -membertype NoteProperty -name "Permissions" -value $permissionsAsInt - $obj | add-member -membertype NoteProperty -name "Inherited" -value $permission.IsInherited - $obj | add-member -membertype NoteProperty -name "InheritedFrom" -value $permission.InheritedFrom - - $folderDetailsList += $obj - } - } - - - ## Delete existing file if exists - if (Test-Path $fileName) { - Remove-Item $fileName - } - - - if ($exportType -contains "CSV") { - $folderDetailsList | Export-Csv -Path $fileName -NoTypeInformation - } - elseif ($exportType -contains "XML") { - $folderDetailsList | Export-Clixml $fileName - } - -} - - -<# - .SYNOPSIS - Given a CSV file, checks and creates VFS folders and sets permissions where required - .DESCRIPTION - Given an EFT site, a CSV file of same format exported by Export-EftFolders, adds or updates VFS folders and permissions. Supports -WhatIf - .PARAMETER siteName - EFT Site to process. Must exist. - .PARAMETER fileName - Input file name. May be relative or absolute path. - .EXAMPLE - Import-EftFoldersCsv -siteName 'SOME_SITE' -fileName "VFS.csv" -#> -Function Import-EftFoldersCsv { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName, - [Parameter(Mandatory = $true, HelpMessage = "File name")] [ValidateScript( {Test-Path $_ -isValid})] [String]$fileName - ) - - - ## TODO: Add error trapping - - $dummy = Get-EftSite -siteName $siteName - - if ($script:EftSite -eq $null) { - Write-Host "You need to select a EFT Site first to use Import-EftFoldersCsv" -ForegroundColor Red - } - else { - - $isWhatIf = $true - if ($pscmdlet.ShouldProcess($siteName, 'AddUpdateFolders')) { - $isWhatIf = $false - } - - $rootFolder = $script:EftSite.GetRootFolder() - - ## Open the CSV file and process "Client","Path","PhysicalPath","Permissions","Inherited","InheritedFrom" - $folders = Import-Csv $fileName - ForEach ($folder in $folders) { - $folderPath = $folder.Path - if ($folderPath[-1] -ne '/') { - $folderPath += "/" - } - - Write-Verbose "Examining folder '$($folderPath)'" - - ## See if folder exists - $isNewFolder = $false - $isPhysicalFolder = $false - - try { - $folderList = $script:EftSite.GetFolderList($folderPath) - } - catch [System.Runtime.InteropServices.COMException] { - $isNewFolder = $true - ## Is requested folder physical or virtual? - if ($folder.PhysicalPath.StartsWith($rootFolder, "CurrentCultureIgnoreCase")) { - $isPhysicalFolder = $true - } - } - - - ## If -WhatIf is False, then act on folder. - if ($isWhatIf -eq $false) { - ## Create folder, if required. - if ($isNewFolder) { - if ($isPhysicalFolder) { - Write-Verbose "Create 'physical' folder $($folderPath)" - $script:EftSite.CreatePhysicalFolder($folderPath) - } - else { - Write-Verbose "Create 'virtual' folder $($folderPath) pointing to $($folder.PhysicalPath)" - $script:EftSite.CreateVirtualFolder($folderPath, $folder.PhysicalPath) - } - } - - ## Check Permissions - $requestedPermissionsAsInt = [int]$folder.Permissions - $permissionsInherited = [System.Convert]::ToBoolean($folder.Inherited) - - ## Are permissions being removed? - if ($requestedPermissionsAsInt -eq -1) { - Write-Verbose "Remove user '$($folder.Client)' permissions from $($folderPath)" - $script:EftSite.RemovePermission($folderPath, $folder.Client) - } - else { - if (-not ($permissionsInherited)) { - Write-Verbose "Set permissions for user '$($folder.Client)' on $($folderPath). Requested permissions $($requestedPermissionsAsInt)" - $permission = IntToPermissions $requestedPermissionsAsInt $script:EftSite.GetBlankPermission($folderPath, $folder.Client) - $script:EftSite.SetPermission($permission, $false) - } - } - } - else { - if ($isNewFolder) { - Write-Host "What if: Would add new folder '$($folderPath)'." -ForegroundColor White - } - else { - Write-Host "What if: Would update folder '$($folderPath)'." -ForegroundColor White - } - } - } - } -} -#endregion - - -##################################################### -## SQL Query -##################################################### -#region -<# - .SYNOPSIS - Creates a CSV or XML file with results of a SQL Query - .DESCRIPTION - Connects to a database (SQL Server) and executes a given select query. Outputs result in either CSV format or XML format. - .PARAMETER dataSource - The data source instance. I.E. host\instance or .\instance - .PARAMETER database - The database to open. - .PARAMETER connectionString - Optional. Allows for creation and submission of a connection string. This overrides internally created connection string. - .PARAMETER userName - Optional. Use SQL Server user name (implies parameter -password also given). - .PARAMETER password - Optional. Password for -userName - .PARAMETER query - The SQL query to execute. Any valid SQL that returns data may be used. - .PARAMETER exportType - Optional. The type of output file format. CSV|XML Defaults to CSV - .PARAMETER fileName - Output file name. May be relative or absolute path. Existing file will be overwritten. - .EXAMPLE - Export-EftSqlQuery -dataSource "IS350\SQLEXPRESS" -database [Some_Table] -query "select * from dbo.Directives" -fileName "SqlQuery.csv" -#> -Function Export-EftSqlQuery { - - param( - [Parameter(Mandatory = $true, HelpMessage = "SQL Instance")] [String]$dataSource, - [Parameter(Mandatory = $true, HelpMessage = "SQL Database")] [String]$database, - [Parameter(Mandatory = $false, HelpMessage = "SQL Connection String (Optional connection string)")] [String]$connectionString, - [Parameter(Mandatory = $false, HelpMessage = "SQL User Name (Optional)")] [String]$userName, - [Parameter(Mandatory = $false, HelpMessage = "SQL Password (Optional)")] [String]$password, - [Parameter(Mandatory = $true, HelpMessage = "SQL Query")] [String]$query, - [Parameter(Mandatory = $false, HelpMessage = "Type of export (CSV (default), XML)")] [ValidateSet("XML", "CSV")] [String]$exportType = "CSV", - [Parameter(Mandatory = $true, HelpMessage = "File name")] [String] [ValidateScript( {Test-Path $_ -isValid})] $fileName - ) - - ## Create connection string - - $cnxString = "Data Source=$dataSource; " + "Initial Catalog=$database" + "; Integrated Security=SSPI" - - if ($userName -ne $null -and $userName.Length -gt 0) { - $cnxString += "; User ID=$userName; Password=$password" - } - - if ($connectionString -ne $null -and $connectionString.Length -gt 0) { - $cnxString = $connectionString - } - - - ## Open connection to SQL. - - $connection = new-object system.data.SqlClient.SQLConnection($cnxString) - $command = new-object system.data.sqlclient.sqlcommand($query, $connection) - $connection.Open() - - $reader = $command.ExecuteReader() - - $results = @() - while ($reader.Read()) { - $row = @{} - for ($i = 0; $i -lt $reader.FieldCount; $i++) { - $row[$reader.GetName($i)] = $reader.GetValue($i) - } - $results += new-object psobject -property $row - } - - $connection.Close() - - - ## Delete existing file if exists - if (Test-Path $fileName) { - Remove-Item $fileName - } - - - if ($exportType -contains "CSV") { - $results | Export-Csv -Path $fileName -NoTypeInformation - } - elseif ($exportType -contains "XML") { - $results | Export-Clixml $fileName - } - -} -#endregion - - -##################################################### -## ARM3 -##################################################### -#region ARM Report functions -<# - .SYNOPSIS - Exports a EFT Report into HTML format - .DESCRIPTION - Connects to EFT and Runs a report based on the name of the report and generate the output into an outputfile - .PARAMETER ReportName - The name of the Report to execute. I.E. PCI DSS Compliance Report - .PARAMETER ReportOutputPath - Full path where report will be generated. I.E. C:\temp\out.html - .PARAMETER ReportFromDate - Optional. Allows to pass a From date for the report to be generated, if omitted, then default is current date. - .PARAMETER ReportToDate - Optional. Allows to pass a To date for the report to be generated, if omitted, then default is current date. - .EXAMPLE - Export-EFTReport -reportName "Executive Summary Report" -reportOutputPath "C:\temp\exec.txt" -reportFromDate "01/01/2012" -reportToDate "03/02/2018" - -#> -Function Export-EFTReport { - param( - [Parameter(Mandatory = $true, HelpMessage = "ReportName")] [String]$reportName, - [Parameter(Mandatory = $true, HelpMessage = "ReportOutputPath")] [ValidateScript( {Test-Path $_ -isValid})] [String]$reportOutputPath, - [Parameter(Mandatory = $false, HelpMessage = "ReportFromDate")] [DateTime]$reportFromDate = $(Get-Date), - [Parameter(Mandatory = $false, HelpMessage = "ReportToDate")] [DateTime]$reportToDate = $(Get-Date) - ) - - $reportParams = New-object -Comobject "SFTPCOMInterface.CIReportActionParams" - # HTMLFormat = 0, - # PDFFormat = 1, - # VPFormat = 2 - $reportParams.ReportFileFormat = 0 - # Predefined = 0, - # Range = 1 - $reportParams.DateFormat = 1 - $reportParams.FromDate = $reportFromDate - $reportParams.ToDate = $reportToDate - Write-Host "From: $reportFromDate" - Write-Host "To: $reportToDate" - foreach ($report in $script:eftserver.AvailableReports) { - if ($report.Name -eq $reportName) { - $reportParams.Report = $report - $script:eftServer.GenerateReport($reportParams, $reportOutputPath) - } - } -} - -<# - .SYNOPSIS - Exports al EFT Report names avaialble in EFT - .DESCRIPTION - Exports al EFT Report names avaialble in EFT (only if ARM is enable) - .EXAMPLE - Get-EFTReports -#> -Function Get-EFTReports { - param() - $results = @() - foreach ($report in $script:eftserver.AvailableReports) { - $obj = new-object PSObject - $obj | add-member -membertype NoteProperty -name "Name" -value $report.Name - $obj | add-member -membertype NoteProperty -name "DefinitionPath" -value $report.DefinitionPath - $results += $obj - } - return $results -} - - -##################################################### -## Event Rules, AWE, & Cust CMD -##################################################### -#region Event Rule, AWE, and Custom Command functions -<# - .SYNOPSIS - Exports EFT Event Rules into XML format - .DESCRIPTION - Connects to EFT and exports EFT Event Rules based on the name of the event rule and generate one XML for each event rule match into the specified path - .PARAMETER siteName - The name of the site name to be process. I.E. MySite - .PARAMETER EventName - The name of the event rule(s) I.E. "Event Rule 1" , "Event*" (wildcards are supported ) - .PARAMETER ExportFolderPath - Full path where XML files will be generated. I.E. C:\temp\SiteA\eventRules . if path doesn't exist it will be created. - .EXAMPLE - Export-Eventrules -siteName MySite -name "Event Rule 1*" -path "C:\temp\SiteA\eventRules" - -#> -Function Export-EventRules { - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name: ")] [String]$siteName, - [Parameter(Mandatory = $true, HelpMessage = "Enter Event Rule Name (use * for all): ")] [String]$EventName, - [Parameter(Mandatory = $false, HelpMessage = "Enter Folder to export to: ")] [ValidateScript( {Test-Path $_ -isValid})] [String]$ExportFolderPath - ) - - if (!(RefreshServer $siteName)) { - return - } - - if ($ExportFolderPath -eq $null -or $ExportFolderPath.Length -eq 0) { - $ExportFolderPath = "." - } - If ($ExportFolderPath.substring($exportfolderpath.Length - 1) -eq "\") { - $ExportFolderPath = $ExportFolderPath.substring(0, $exportfolderpath.Length - 1) - } - $ExportFolderPath = Resolve-Path($ExportFolderPath) - - If ($EventName -eq "*") { - Write-host "All (*) events requested. Exporting all events!" - $eftsite.ExportEventRules($ExportFolderPath + "\All Events.xml") - Write-Host "Complete!" -ForegroundColor Green - } - else { - #[enum]::GetNames($Type) - $EventType = $script:EftServer.AvailableEvents - foreach ($eventtype in $EventType) { - - Try { - $eRules = $script:eftsite.EventRules($eventType.type) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "COM Exception : $error[0]" -ForegroundColor Magenta - } - - If ($erules) { - If ($eRules.Count() -gt 0) { - - For ($iRule = 0; $iRule -lt $eRules.Count(); $iRule++) { - $objEvent = $eRules.Item($iRule) - $objParams = $objEvent.GetParams() - $chkName = $objParams.name + ">" + $EventName - Write-Verbose $chkName - If ($objParams.name -like $EventName) { - $rulename = $objParams.name - $exportedfilename = RemoveInvalidChars $objParams.name - $exportedfilename = $eventType.Name + "_" + $exportedfilename + ".xml" - $exportedfilename = Join-path $ExportFolderPath $exportedfilename - Write-host "Exporting [" $rulename "] to file (" $exportedfilename ")." - $objEvent.Export($exportedfilename) - } - } - } - } - } - } -} - - -<# - .SYNOPSIS - Exports EFT Event Rules into XML format - .DESCRIPTION - Connects to EFT and exports EFT Event Rules based on the name of the event rule and generate one XML for each event rule match into the specified path - .PARAMETER siteName - The name of the site name to be process. I.E. MySite - .PARAMETER EventName - The name of the event rule(s) I.E. "Event Rule 1" , "Event*" (wildcards are supported ) - .PARAMETER ExportFolderPath - Full path where XML files will be generated. I.E. C:\temp\SiteA\eventRules . if path doesn't exist it will be created. - .EXAMPLE - Export-Eventrules -siteName MySite -name "Event Rule 1*" -path "C:\temp\SiteA\eventRules" - -#> -Function Remove-EventRules { - [CmdletBinding(SupportsShouldProcess = $true)] - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name: ")] [String]$siteName, - [Parameter(Mandatory = $true, HelpMessage = "Enter Event Rule Name (use * for all): ")] [String]$EventName - ) - - if (!(RefreshServer $siteName)) { - return - } - - #[enum]::GetNames($Type) - $EventType = $script:EftServer.AvailableEvents - foreach ($eventtype in $EventType) { - - Try { - $eRules = $script:eftsite.EventRules($eventType.type) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "COM Exception : $error[0]" -ForegroundColor Magenta - } - - If ($erules) { - If ($eRules.Count() -gt 0) { - For ($iRule = $eRules.Count() - 1; $iRule -ge 0 ; $iRule--) { - Try { - $objEvent = $eRules.Item($iRule) - $objParams = $objEvent.GetParams() - $chkName = $objParams.name + ">" + $EventName - Write-Verbose $chkName - If ($objParams.name -like $EventName) { - $rulename = $objParams.name - if ($pscmdlet.ShouldProcess($rulename, "Removed" )) { - $eRules.Delete($iRule) - } - Write-host "Removed [" $rulename "] ." - } - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "COM Exception : $error[0]" -ForegroundColor Magenta - } - } - } - } - } - -} -<# - .SYNOPSIS - Exports EFT Advanced Workflow into aml format - .DESCRIPTION - Connects to EFT and exports Advanced Workflow based on the name of the workflow and generate one XML for each workflow name match into the specified path. - .PARAMETER siteName - The name of the site name to be process. I.E. MySite - .PARAMETER TaskName - The name of the advanced workflow(s) I.E. "WorkflowA*" (wildcards are supported) - .PARAMETER ExportFolderPath - Full path where XML files will be generated. I.E. C:\temp\SiteA\workflows\ . if path doesn't exist it will be created. - .EXAMPLE - Export-AdvancedWorkflows -siteName MySite -TaskName "WorkflowA*" -ExportFolderPath "C:\temp\SiteA\workflows\" - -#> -Function Export-AdvancedWorkflows { - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName, - [Parameter(Mandatory = $true, HelpMessage = "Enter Advanced Work Name")] [String]$TaskName, - [Parameter(Mandatory = $true, HelpMessage = "ExportFolderPath")] [ValidateScript( {Test-Path $_ -isValid})] [String]$ExportFolderPath - ) - - - if (!(RefreshServer $siteName)) { - return - } - - If ($ExportFolderPath.substring($exportfolderpath.Length - 1) -eq "\") { - $ExportFolderPath = $ExportFolderPath.substring(0, $exportfolderpath.Length - 1) - } - Write-Host "Getting AWE Tasks" - $taskCount = $EFTSite.AdvancedWorkflowsCount - Write-Host "Found $taskCount AWE Tasks" - If ($taskcount -gt 0) { - For ($iTask = 0; $iTask -lt $taskCount; $iTask++) { - $objTask = $eftsite.GetAdvancedWorkflowParams($itask) - # Write-Host "current Task: " $objTask.Name - If ($objTask.Name -Like $TaskName) { - $exportedfilename = RemoveInvalidChars $objTask.Name - $task = $objTask.Name - $exportedfilename = $ExportFolderPath + "\" + $exportedfilename + ".xml" - Write-host "Exporting [" $task "] to file (" $exportedfilename ")." - Export-Clixml -path $exportedfilename -inputObject $objTask -depth 4 - } - } - } - else { - Write-Host "No AWE Tasks found in site." - } -} - -<# - .SYNOPSIS - Exports EFT Custom Command into xml format - .DESCRIPTION - Connects to EFT and exports Custom Command based on the name of the custom command and generate one XML for each custom command name match into the specified path - .PARAMETER siteName - TThe name of the site name to be process. I.E. MySite - .PARAMETER CustomCommandName - The name of the Custom Command(s) I.E. "CommandA*" (wildcards are supported) - .PARAMETER ExportFolderPath - Full path where XML files will be generated. I.E. C:\temp\SiteA\commands . if path doesn't exist it will be created. - .EXAMPLE - Export-CustomCommands -siteName MySite -CustomCommandName "CommandA*" -ExportFolderPath "C:\temp\SiteA\commands" - -#> -Function Export-CustomCommands { - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName, - [Parameter(Mandatory = $true, HelpMessage = "Enter Custom Command Name")] [String]$CustomCommandName, - [Parameter(Mandatory = $true, HelpMessage = "Enter Folder to export to: ")] [ValidateScript( {Test-Path $_ -isValid})] [String]$ExportFolderPath - ) - - if (!(RefreshServer $siteName)) { - return - } - - If ($ExportFolderPath.substring($exportfolderpath.Length - 1) -eq "\") { - $ExportFolderPath = $ExportFolderPath.substring(0, $exportfolderpath.Length - 1) - } - - $customcommandslist = $eftsite.GetCommands() - - If ($customcommandslist) { - $total = $customcommandslist.getupperbound(0) + 1 - Write-host "Total Custom Commands Found:`t" $total - - ForEach ($iCC in $customcommandslist) { - Write-host "Processing: " $iCC -ForegroundColor Magenta - If ($icc -Like $CustomCommandName) { - $ccSettings = $eftsite.GetCommandSettings($iCC) - $exportedfilename = RemoveInvalidChars $ccSettings.Name - $exportedfilename = $ExportFolderPath + "\" + $exportedfilename + ".xml" - Write-host "Exporting [" $iCC "] to file (" $exportedfilename ")." - Export-Clixml -path $exportedfilename -inputObject $ccSettings -depth 4 - } - } - } -} - -<# - .SYNOPSIS - Imports EFT Event Rules from xml format - .DESCRIPTION - Connects to EFT and imports Event Rules xml files under the specified path - .PARAMETER siteName - The name of the site name to be process. I.E. MySite - .PARAMETER ImportFolderPath - Full path where XML files will be generated. I.E. C:\temp\SiteA\eventRules\ - .EXAMPLE - Import-Eventrules -siteName MySite -ImportFolderPath "C:\temp\SiteA\eventRules\" - -#> -Function Import-EventRules { - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName, - [Parameter(Mandatory = $true, HelpMessage = "Enter event rule folder")] [String]$EventFolder, - [Parameter(Mandatory = $true, HelpMessage = "Enter Folder Path where XML files are located:")] [ValidateScript( {Test-Path $_ -isValid})] [String]$ImportFolderPath - ) - - if (!(RefreshServer $siteName)) { - return - } - - $EventFolders = $EFTsite.EventRuleFolders() - $objEventFolder = $EventFolders.Find($EventFolder) - If (!$objEventFolder) { - Write-Host "Event folder not found: " $EventFolder - Write-Host "Creating folder instead..." - $count = $EventFolders.Count() - $result = $EventFolders.Add($count, $eventFolder) - $objEventFolder = $EventFolders.Find($EventFolder) - } - - Get-ChildItem $ImportFolderPath -Filter *.xml | Foreach-Object { - $currentFile = $_.FullName - Write-Host "Importing file: $currentfile" - $result = $objEventFolder.Import($currentFile) - } -} - -<# - .SYNOPSIS - Imports EFT Advanced Workflow from xml format - .DESCRIPTION - Connects to EFT and imports Advanced Workflows xml files under the specified path - .PARAMETER siteName - The name of the site name to be process. I.E. MySite - .PARAMETER ImportFolderPath - Full path where XML files will be generated. I.E. C:\temp\SiteA\workflows\ - .EXAMPLE - Import-AdvancedWorkflows -siteName MySite -path "C:\temp\SiteA\workflows\" - -#> -Function Import-AdvancedWorkflows { - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName, - [Parameter(Mandatory = $true, HelpMessage = "Enter Folder Path containing exported XML files")] [ValidateScript( {Test-Path $_ -isValid})] [String]$ImportFolderPath - ) - - if (!(RefreshServer $siteName)) { - return - } - - Get-ChildItem $ImportFolderPath -Filter *.xml | Foreach-Object { - $currentFile = $_.FullName - - - Write-Host "Processing file: $currentFile" - $objParams = Import-Clixml $currentFile - - <# AWE OBJ properties - Name - Description - Code - LogMode - TimeoutSeconds #> - - $aweindex = $null - Write-Host "Checking for Task existence: " $objParams.Name - $aweIndex = $eftsite.GetAdvancedWorkflowIndex($objParams.Name) - - If ($aweIndex -ge 0) { - $aweparams = $EFTSite.GetAdvancedWorkflowParams($aweIndex) - } - else { - Write-Host "AWE Task not found on server. Will attempt to add new workflow instead." -ForegroundColor Yellow - $aweparams = new-object -ComObject "SFTPCOMInterface.CIAdvancedWorkflowParams" - } - - $aweparams.Name = "$($objParams.Name)" - $aweparams.Description = "$($objParams.Description)" - $aweparams.Code = "$($objParams.Code)" - $aweparams.LogMode = "$($objParams.LogMode)" - $aweparams.TimeoutSeconds = "$($objParams.TimeoutSeconds)" - - If ($aweIndex -ge 0) { - Write-Host "Updating Workflow: " $aweparams.Name - $eftsite.SetAdvancedWorkflowParams($aweindex, $aweparams) - - } - else { - Write-Host "Adding workflow: " $aweparams.Name - $newIDX = $eftsite.AddAdvancedWorkflow($AWEParams) - } - } -} - -<# - .SYNOPSIS - Imports EFT Custom Command from xml format - .DESCRIPTION - Connects to EFT and imports Custom commands xml files under the specified path - .PARAMETER siteName - The name of the target Import Site. I.E. MySite - .PARAMETER ImportFolderPath - Full path where XML files exist. I.E. C:\temp\SiteA\commands\ - .EXAMPLE - Import-CustomCommands -siteName MySite -ImportFolderPath "C:\temp\SiteA\commands\" - -#> -Function Import-CustomCommands { - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a site name")] [String]$siteName, - [Parameter(Mandatory = $true, HelpMessage = "Enter Folder Path containing exported XML files")] [ValidateScript( {Test-Path $_ -isValid})] [String]$ImportFolderPath - ) - - - if ($EFTServer) { - $EftServer.RefreshSettings() - } - else { - Write-host "Not connected to EFT. Use [ Connect-EFT ] first!" -ForegroundColor Red - return - } - $dummy = Get-EftSite -siteName $siteName - - Get-ChildItem $ImportFolderPath -Filter *.xml | Foreach-Object { - $currentFile = $_.FullName - $ccsettings = $null - - Write-Host "Processing file: $currentfile" - $ccObj = Import-Clixml $currentFile - - <# OBJ Properties - Name - Description - EnableProcessTimeOut - Executable - IsEnabled - LogPath - MinNumOfParams - MinNumOfParamsMsg - Parameters - ProcessTimeOut - RedirectOutputToClient - RedirectOutputToLog - RequireParams - #> - - try { - $ccName = $ccObj.Name - Write-Host "Checking for Custom Command in target site: " $ccName -ForegroundColor Cyan - $ccSettings = $eftsite.GetCommandSettings($ccObj.Name) - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "$ccName not found! AttemptingS to add Command instead." -ForegroundColor Yellow - $ccSettings = $null - } - - If (!$ccsettings) { - Write-Host "Creating command $ccName" -ForegroundColor Cyan - $ccSettings = $eftsite.CreateCommand($ccObj.Name) - } - else { - Write-Host "Updating existing Command settings." -ForegroundColor Cyan - } - - $cs = $ccObj.IsEnabled - $ccSettings.IsEnabled = "$($cs)" - $cs = $ccObj.Description - $ccSettings.Description = "$($cs)" - $cs = $ccObj.EnableProcessTimeOut - $ccSettings.EnableProcessTimeOut = "$($cs)" - $cs = $ccObj.Executable - $ccSettings.Executable = "$($cs)" - $cs = $ccObj.LogPath - $ccSettings.LogPath = "$($cs)" - $cs = $ccObj.MinNumOfParams - $ccSettings.MinNumOfParams = "$($cs)" - $cs = $ccObj.MinNumOfParamsMsg - $ccSettings.MinNumOfParamsMsg = "$($cs)" - $cs = $ccObj.Parameters - $ccSettings.Parameters = "$($cs)" - $cs = $ccObj.ProcessTimeOut - $ccSettings.ProcessTimeOut = "$($cs)" - $cs = $ccObj.RedirectOutputToClient - $ccSettings.RedirectOutputToClient = "$($cs)" - $cs = $ccObj.RedirectOutputToLog - $ccSettings.RedirectOutputToLog = "$($cs)" - $cs = $ccObj.RequireParams - $ccSettings.RequireParams = "$($cs)" - - Write-Host "Applying changes" -ForegroundColor Green - $eftServer.ApplyChanges() - } -} - -Function Publish-EventRules { - param( - #region GET SOURCE SERVER INFO - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin hostname that EFT accepts administrative connections.")] - [AllowEmptyString()][string]$srcHost = $(Read-Host "Enter Source Host (Default ""Localhost""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin port number where EFT accepts administrative connections.")] - [AllowNull()][System.Nullable[int]]$srcPort = $(Read-Host "Enter Source EFTPort (Default ""1100""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin authentication type (0-2). EFTLogin = 0, IWALogin = 1, NetLogon = 2.")] - [AllowNull()][System.Nullable[int]]$srcAuthType = $(Read-Host "Enter Authentication (Default 1 = IWALogin): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT Admin Username.")][AllowEmptyString()] - [string]$srcLogin = $(Read-Host "Enter EFTAdminUsername (Default ""$env:UserDomain\$env:UserName""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT Admin Password. leave empty if you are using IWALogin (Currently User Logged On User")] - [AllowEmptyString()][string]$srcPassword = $($(Read-Host -asSecureString "Enter EFT Admin password (Emtpy): ") | convertfrom-securestring ), - - [Parameter(Mandatory = $true, HelpMessage = "The source Sitename.")] - [string]$srcSite = $(Read-Host "Enter the Source sitename): "), - #endregion - #region GET DEST SERVER INFO - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin hostname that EFT accepts administrative connections.:")] - [AllowEmptyString()][string]$dstHost = $(Read-Host "Enter Destination Host (Default ""Localhost""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin port number where EFT accepts administrative connections.")] - [AllowNull()][System.Nullable[int]]$dstPort = $(Read-Host "Enter Destination EFTPort (Default ""1100""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin authentication type (0-2). EFTLogin = 0, IWALogin = 1, NetLogon = 2.")] - [AllowNull()][System.Nullable[int]]$dstAuthType = $(Read-Host "Enter Authentication (Default 1 = IWALogin): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT Admin Username.")] - [AllowEmptyString()][string]$dstLogin = $(Read-Host "Enter EFTAdminUsername (Default ""$env:UserDomain\$env:UserName""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT Admin Password. leave empty if you are using IWALogin (Currently User Logged On User")] - [AllowEmptyString()][string]$dstPassword = $($(Read-Host -asSecureString "Enter EFT Admin password (Emtpy): ") | convertfrom-securestring ), - - [Parameter(Mandatory = $true, HelpMessage = "The destination Sitename.")] - [string]$dstSite = $(Read-Host "Enter the destination sitename): "), - #endregion - #region GET WORK FOLDERS, FILES, AND ITEM INFO - [Parameter(Mandatory = $true, HelpMessage = "Enter Working Folder Path to process files")] - [ValidateScript( {Test-Path $_ -isValid})] [String]$WorkingFolder = $(Read-Host "Enter Working Folder Path to process files: "), - - [Parameter(Mandatory = $true, HelpMessage = "Enter Dictionary file Path")] - [ValidateScript( {Test-Path $_ -isValid})] [String]$dictionary = (Read-Host "Input location of dictionary file: "), - - [Parameter(Mandatory = $true, HelpMessage = "Enter Event Rule Name (use * for all): ")] - [String]$EventName = $(Read-Host "Input Event Name (* for all): "), - - [Parameter(Mandatory = $true, HelpMessage = "Enter Event Folder Name to import to: ")] - [String]$EventFolder = $(Read-Host "Input Event Folder: ") - - #endregion - ) - - #region Check for null values - if ($srcHost -eq $null -or $srcHost -eq "") { - $srcHost = "Localhost" - } - - if ($srcPort -eq $null -or $srcPort -eq "") { - $srcPort = "1100" - } - - if ($srcAuthType -eq $null -or $srcAuthType -eq "") { - $srcAuthType = "1" - } - - if ($srcLogin -eq $null -or $srcLogin -eq "") { - $srcLogin = "$env:UserDomain\$env:UserName" - } - - if ($srcPassword -eq $null -or $srcPassword -eq "") { - $srcPassword = "nonegiven" - } - - if ($dstHost -eq $null -or $dstHost -eq "") { - $dstHost = "Localhost" - } - - if ($dstPort -eq $null -or $dstPort -eq "") { - $dstPort = "1100" - } - - if ($dstAuthType -eq $null -or $dstAuthType -eq "") { - $dstAuthType = "1" - } - - if ($dstLogin -eq $null -or $dstLogin -eq "") { - $dstLogin = "$env:UserDomain\$env:UserName" - } - - if ($dstPassword -eq $null -or $dstPassword -eq "") { - $dstPassword = "nonegiven" - } - #endregion - - $WorkingFolder = $WorkingFolder + "\ers" - $chkFN = Test-Path $WorkingFolder - If ($chkFN -eq $false) { - $fn = new-item $WorkingFolder -ItemType directory - } - - - Write-Host "Connecting to Source server: " $srcHost - Connect-EFT -hostname $srcHost -port $srcPort -AuthType $srcAuthType -login $srcLogin -password $srcPassword - Write-Host "Exporting Rules..." -ForegroundColor Cyan - Export-EventRules -siteName $srcSite -eventname $eventName -ExportFolderPath $workingFolder - Write-Host "Export complete! Disconnecting from source server." -ForegroundColor Green - Disconnect-EFT - - #Run exported item through dictionary. - Write-Host "Running rules through dictionary..." -ForegroundColor Cyan - Get-ChildItem $workingFolder -Filter *.xml | Foreach-Object { - Convert-PathsFromDictionary -targetfile $_.FullName -dictionary $dictionary - } - $convertedFolder = $workingFolder + "\ConversionComplete" - Write-Host "Conversion complete!`nConnecting to destination server!" -ForegroundColor Green - - Connect-EFT -hostname $dstHost -port $dstPort -AuthType $dstAuthType -login $dstLogin -password $dstPassword - Write-Host "Importing Event Rules" -ForegroundColor Cyan - Import-EventRules -siteName $dstSite -ImportFolderPath $convertedFolder -EventFolder $EventFolder - Write-Host "Import complete!" -ForegroundColor Green - Disconnect-EFT - - Write-Host "Disconnected from Destination Server...`nRules Successfully Published!" -ForegroundColor Green -} - -Function Publish-AdvancedWorkflows { - param( - #region GET SOURCE SERVER INFO - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin hostname that EFT accepts administrative connections.")] - [AllowEmptyString()][string]$srcHost = $(Read-Host "Enter Source Host (Default ""Localhost""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin port number where EFT accepts administrative connections.")] - [AllowNull()][System.Nullable[int]]$srcPort = $(Read-Host "Enter Source EFTPort (Default ""1100""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin authentication type (0-2). EFTLogin = 0, IWALogin = 1, NetLogon = 2.")] - [AllowNull()][System.Nullable[int]]$srcAuthType = $(Read-Host "Enter Authentication (Default 1 = IWALogin): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT Admin Username.")][AllowEmptyString()] - [string]$srcLogin = $(Read-Host "Enter EFTAdminUsername (Default ""$env:UserDomain\$env:UserName""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT Admin Password. leave empty if you are using IWALogin (Currently User Logged On User")] - [AllowEmptyString()][string]$srcPassword = $($(Read-Host -asSecureString "Enter EFT Admin password (Emtpy): ") | convertfrom-securestring ), - - [Parameter(Mandatory = $true, HelpMessage = "The source Sitename.")] - [string]$srcSite = $(Read-Host "Enter the Source sitename): "), - #endregion - #region GET DEST SERVER INFO - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin hostname that EFT accepts administrative connections.:")] - [AllowEmptyString()][string]$dstHost = $(Read-Host "Enter Destination Host (Default ""Localhost""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin port number where EFT accepts administrative connections.")] - [AllowNull()][System.Nullable[int]]$dstPort = $(Read-Host "Enter Destination EFTPort (Default ""1100""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin authentication type (0-2). EFTLogin = 0, IWALogin = 1, NetLogon = 2.")] - [AllowNull()][System.Nullable[int]]$dstAuthType = $(Read-Host "Enter Authentication (Default 1 = IWALogin): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT Admin Username.")] - [AllowEmptyString()][string]$dstLogin = $(Read-Host "Enter EFTAdminUsername (Default ""$env:UserDomain\$env:UserName""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT Admin Password. leave empty if you are using IWALogin (Currently User Logged On User")] - [AllowEmptyString()][string]$dstPassword = $($(Read-Host -asSecureString "Enter EFT Admin password (Emtpy): ") | convertfrom-securestring ), - - [Parameter(Mandatory = $true, HelpMessage = "The destination Sitename.")] - [string]$dstSite = $(Read-Host "Enter the destination sitename): "), - #endregion - #region GET WORK FOLDERS, FILES, AND ITEM INFO - [Parameter(Mandatory = $true, HelpMessage = "Enter Working Folder Path to process files")] - [ValidateScript( {Test-Path $_ -isValid})] [String]$WorkingFolder = $(Read-Host "Enter Working Folder Path to process files: "), - - [Parameter(Mandatory = $true, HelpMessage = "Enter Dictionary file Path")] - [ValidateScript( {Test-Path $_ -isValid})] [String]$dictionary = (Read-Host "Input location of dictionary file: "), - - [Parameter(Mandatory = $true, HelpMessage = "Enter AWE Task name: ")] - [String]$TaskName = $(Read-Host "Input AWE Task: ") - #endregion - ) - #region Check for null values - if ($srcHost -eq $null -or $srcHost -eq "") { - $srcHost = "Localhost" - } - - if ($srcPort -eq $null -or $srcPort -eq "") { - $srcPort = "1100" - } - - if ($srcAuthType -eq $null -or $srcAuthType -eq "") { - $srcAuthType = "1" - } - - if ($srcLogin -eq $null -or $srcLogin -eq "") { - $srcLogin = "$env:UserDomain\$env:UserName" - } - - if ($srcPassword -eq $null -or $srcPassword -eq "") { - $srcPassword = "nonegiven" - } - - if ($dstHost -eq $null -or $dstHost -eq "") { - $dstHost = "Localhost" - } - - if ($dstPort -eq $null -or $dstPort -eq "") { - $dstPort = "1100" - } - - if ($dstAuthType -eq $null -or $dstAuthType -eq "") { - $dstAuthType = "1" - } - - if ($dstLogin -eq $null -or $dstLogin -eq "") { - $dstLogin = "$env:UserDomain\$env:UserName" - } - - if ($dstPassword -eq $null -or $dstPassword -eq "") { - $dstPassword = "nonegiven" - } - #endregion - - $WorkingFolder = $WorkingFolder + "\awe" - - $chkFN = Test-Path $WorkingFolder - If ($chkFN -eq $false) { - $fn = new-item $WorkingFolder -ItemType directory - } - - - Write-Host "Connecting to Source server: " $srcHost - Connect-EFT -hostname $srcHost -port $srcPort -AuthType $srcAuthType -login $srcLogin -password $srcPassword - Write-Host "Exporting AWE Tasks..." -ForegroundColor Cyan - Export-AdvancedWorkflows -siteName $srcSite -TaskName $TaskName -ExportFolderPath $workingFolder - Write-Host "Export complete! Disconnecting from source server." -ForegroundColor Green - Disconnect-EFT - - #Run exported item through dictionary. - Write-Host "Running rules through dictionary..." -ForegroundColor Cyan - Get-ChildItem $workingFolder -Filter *.xml | Foreach-Object { - Convert-PathsFromDictionary -targetfile $_.FullName -dictionary $dictionary - } - $convertedFolder = $workingFolder + "\ConversionComplete" - Write-Host "Conversion complete!`nConnecting to destination server!" -ForegroundColor Green - - Connect-EFT -hostname $dstHost -port $dstPort -AuthType $dstAuthType -login $dstLogin -password $dstPassword - Write-Host "Importing Event Rules" -ForegroundColor Cyan - Import-AdvancedWorkflows -siteName $dstSite -ImportFolderPath $convertedFolder - Write-Host "Import complete!" -ForegroundColor Green - Disconnect-EFT - - Write-Host "Disconnected from Destination Server...`nRules Successfully Published!" -ForegroundColor Green -} - -Function Publish-CustomCommands { - param( - #region GET SOURCE SERVER INFO - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin hostname that EFT accepts administrative connections.")] - [AllowEmptyString()][string]$srcHost = $(Read-Host "Enter Source Host (Default ""Localhost""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin port number where EFT accepts administrative connections.")] - [AllowNull()][System.Nullable[int]]$srcPort = $(Read-Host "Enter Source EFTPort (Default ""1100""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin authentication type (0-2). EFTLogin = 0, IWALogin = 1, NetLogon = 2.")] - [AllowNull()][System.Nullable[int]]$srcAuthType = $(Read-Host "Enter Authentication (Default 1 = IWALogin): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT Admin Username.")][AllowEmptyString()] - [string]$srcLogin = $(Read-Host "Enter EFTAdminUsername (Default ""$env:UserDomain\$env:UserName""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT Admin Password. leave empty if you are using IWALogin (Currently User Logged On User")] - [AllowEmptyString()][string]$srcPassword = $($(Read-Host -asSecureString "Enter EFT Admin password (Emtpy): ") | convertfrom-securestring ), - - [Parameter(Mandatory = $true, HelpMessage = "The source Sitename.")] - [string]$srcSite = $(Read-Host "Enter the Source sitename): "), - #endregion - #region GET DEST SERVER INFO - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin hostname that EFT accepts administrative connections.:")] - [AllowEmptyString()][string]$dstHost = $(Read-Host "Enter Destination Host (Default ""Localhost""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin port number where EFT accepts administrative connections.")] - [AllowNull()][System.Nullable[int]]$dstPort = $(Read-Host "Enter Destination EFTPort (Default ""1100""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT admin authentication type (0-2). EFTLogin = 0, IWALogin = 1, NetLogon = 2.")] - [AllowNull()][System.Nullable[int]]$dstAuthType = $(Read-Host "Enter Authentication (Default 1 = IWALogin): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT Admin Username.")] - [AllowEmptyString()][string]$dstLogin = $(Read-Host "Enter EFTAdminUsername (Default ""$env:UserDomain\$env:UserName""): "), - - [Parameter(Mandatory = $true, HelpMessage = "The EFT Admin Password. leave empty if you are using IWALogin (Currently User Logged On User")] - [AllowEmptyString()][string]$dstPassword = $($(Read-Host -asSecureString "Enter EFT Admin password (Emtpy): ") | convertfrom-securestring ), - - [Parameter(Mandatory = $true, HelpMessage = "The destination Sitename.")] - [string]$dstSite = $(Read-Host "Enter the destination sitename): "), - #endregion - #region GET WORK FOLDERS, FILES, AND ITEM INFO - [Parameter(Mandatory = $true, HelpMessage = "Enter Working Folder Path to process files")] - [ValidateScript( {Test-Path $_ -isValid})] [String]$WorkingFolder = $(Read-Host "Enter Working Folder Path to process files: "), - - [Parameter(Mandatory = $true, HelpMessage = "Enter Dictionary file Path")] - [ValidateScript( {Test-Path $_ -isValid})] [String]$dictionary = (Read-Host "Input location of dictionary file: "), - - [Parameter(Mandatory = $true, HelpMessage = "Enter Custom Command Name: ")] - [String]$CustomCommandName = $(Read-Host "Input Command Name: ") - #endregion - ) - #region Check for null values - if ($srcHost -eq $null -or $srcHost -eq "") { - $srcHost = "Localhost" - } - - if ($srcPort -eq $null -or $srcPort -eq "") { - $srcPort = "1100" - } - - if ($srcAuthType -eq $null -or $srcAuthType -eq "") { - $srcAuthType = "1" - } - - if ($srcLogin -eq $null -or $srcLogin -eq "") { - $srcLogin = "$env:UserDomain\$env:UserName" - } - - if ($srcPassword -eq $null -or $srcPassword -eq "") { - $srcPassword = "nonegiven" - } - - if ($dstHost -eq $null -or $dstHost -eq "") { - $dstHost = "Localhost" - } - - if ($dstPort -eq $null -or $dstPort -eq "") { - $dstPort = "1100" - } - - if ($dstAuthType -eq $null -or $dstAuthType -eq "") { - $dstAuthType = "1" - } - - if ($dstLogin -eq $null -or $dstLogin -eq "") { - $dstLogin = "$env:UserDomain\$env:UserName" - } - - if ($dstPassword -eq $null -or $dstPassword -eq "") { - $dstPassword = "nonegiven" - } - #endregion - - $WorkingFolder = $WorkingFolder + "\ccs" - - $chkFN = Test-Path $WorkingFolder - If ($chkFN -eq $false) { - $fn = new-item $WorkingFolder -ItemType directory - } - - Write-Host "Connecting to Source server: " $srcHost - Connect-EFT -hostname $srcHost -port $srcPort -AuthType $srcAuthType -login $srcLogin -password $srcPassword - Write-Host "Exporting Custom Commands..." -ForegroundColor Cyan - Export-CustomCommands -siteName $srcSite -CustomCommandName $CustomCommandName -ExportFolderPath $workingFolder - Write-Host "Export complete! Disconnecting from source server." -ForegroundColor Green - Disconnect-EFT - - #Run exported item through dictionary. - Write-Host "Running commands through dictionary..." -ForegroundColor Cyan - Get-ChildItem $workingFolder -Filter *.xml | Foreach-Object { - Convert-PathsFromDictionary -targetfile $_.FullName -dictionary $dictionary - } - $convertedFolder = $workingFolder + "\ConversionComplete" - Write-Host "Conversion complete!`nConnecting to destination server!" -ForegroundColor Green - - Connect-EFT -hostname $dstHost -port $dstPort -AuthType $dstAuthType -login $dstLogin -password $dstPassword - Write-Host "Importing Custom Commands..." -ForegroundColor Cyan - Import-CustomCommands -siteName $dstSite -ImportFolderPath $convertedFolder - Write-Host "Import complete!" -ForegroundColor Green - Disconnect-EFT - - Write-Host "Disconnected from Destination Server...`nRules Successfully Published!" -ForegroundColor Green -} -#endregion - -##################################################### -## Other Utility Functions -##################################################### -#region Other Public Functions - - -# Dictionary.csv -# ---------------------------------- -# Key,Value -# "C:\temp\dev\", "C:\temp\prod\" -# "C:\temp1\dev\", "C:\temp1\prod\" -# "C:\temp2\dev\", "C:\temp2\prod\" -# ---------------------------------- -<# - .SYNOPSIS - Finds and replaces strings within a file using a dictionary. - .DESCRIPTION - Reads a file, looks for a string and replaces it with a new string based on the input of a dictionary file. The new data to a new file under a 'ConversionComplete' subdirectory - .PARAMETER targetfile - The full path of the target file to be manipulated. I.E. C:\temp\events.xml - .PARAMETER dictionary - The full path of the dictionary file that you want to use as source. I.E. C:\temp\path_dictionary.csv - .EXAMPLE - Convert-PathsFromDictionary -targetfile C:\temp\events.xml -dictionary C:\temp\path_dictionary.csv -#> -Function Convert-PathsFromDictionary { - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter Target File Path")] [ValidateScript( {Test-Path $_ -isValid})] [String]$targetfile, - [Parameter(Mandatory = $true, HelpMessage = "Enter Dictionary file Path")] [ValidateScript( {Test-Path $_ -isValid})] [String]$dictionary - ) - - $targetFileName = Split-Path -Path $targetfile -leaf - $targetFolder = Split-Path -Path $targetfile - - $conversionFolder = $targetFolder + "\ConversionComplete" - $chkFN = Test-Path $conversionFolder - If ($chkFN -eq $false) { - $fn = new-item $conversionFolder -ItemType directory - } - - $destinationFile = $conversionFolder + "\" + $targetfilename - - $dictionaryList = Get-Content $dictionary - $dictionaryList | ForEach-Object { - $paths = $_.split(",") - Write-host "Checking for paths: " $paths[0] - Write-Host "Replacing with: " $paths[1] - (Get-Content $targetfile).replace($paths[0], $paths[1]) | Set-Content $destinationFile - } -} - - -#endregion - -##################################################### -## Private functions -##################################################### -#region Private Functions -Function PermissionsToInt($permission) { - - $permissionAsInt = 0 - - if ($permission -ne $null) { - if ($permission.FileUpload -eq $true) {$permissionAsInt += 1} - if ($permission.FileDelete -eq $true) {$permissionAsInt += 2} - if ($permission.FileRename -eq $true) {$permissionAsInt += 4} - if ($permission.FileAppend -eq $true) {$permissionAsInt += 8} - if ($permission.FileDownload -eq $true) {$permissionAsInt += 16} - if ($permission.DirCreate -eq $true) {$permissionAsInt += 32} - if ($permission.DirDelete -eq $true) {$permissionAsInt += 64} - if ($permission.DirList -eq $true) {$permissionAsInt += 128} - if ($permission.DirShowHidden -eq $true) {$permissionAsInt += 256} - if ($permission.DirShowReadOnly -eq $true) {$permissionAsInt += 512} - if ($permission.DirShowInList -eq $true) {$permissionAsInt += 1024} - } - - return $permissionAsInt -} - -Function IntToPermissions($permissionAsInt, $permission) { - - if ($permission -ne $null) { - $permission.FileUpload = [bool](($permissionAsInt -band 1) -eq 1) - $permission.FileDelete = [bool](($permissionAsInt -band 2) -eq 2) - $permission.FileRename = [bool](($permissionAsInt -band 4) -eq 4) - $permission.FileAppend = [bool](($permissionAsInt -band 8) -eq 8) - $permission.FileDownload = [bool](($permissionAsInt -band 16) -eq 16) - $permission.DirCreate = [bool](($permissionAsInt -band 32) -eq 32) - $permission.DirDelete = [bool](($permissionAsInt -band 64) -eq 64) - $permission.DirList = [bool](($permissionAsInt -band 128) -eq 128) - $permission.DirShowHidden = [bool](($permissionAsInt -band 256) -eq 256) - $permission.DirShowReadOnly = [bool](($permissionAsInt -band 512) -eq 512) - $permission.DirShowInList = [bool](($permissionAsInt -band 1024) -eq 1024) - } - - return $permission -} - -Function DisplayPermissions($permission) { - - if ($permission -ne $null) { - Write-Host "permission.FileUpload = '$($permission.FileUpload)'" -ForegroundColor White - Write-Host "permission.FileDelete = '$($permission.FileDelete)'" -ForegroundColor White - Write-Host "permission.FileRename = '$($permission.FileRename)'" -ForegroundColor White - Write-Host "permission.FileAppend = '$($permission.FileAppend)'" -ForegroundColor White - Write-Host "permission.FileDownload = '$($permission.FileDownload)'" -ForegroundColor White - Write-Host "permission.DirCreate = '$($permission.DirCreate)'" -ForegroundColor White - Write-Host "permission.DirDelete = '$($permission.DirDelete)'" -ForegroundColor White - Write-Host "permission.DirList = '$($permission.DirList)'" -ForegroundColor White - Write-Host "permission.DirShowHidden = '$($permission.DirShowHidden)'" -ForegroundColor White - Write-Host "permission.DirShowReadOnly = '$($permission.DirShowReadOnly)'" -ForegroundColor White - Write-Host "permission.DirShowInList = '$($permission.DirShowInList)'" -ForegroundColor White - } - else { - Write-Host "permission is null" -ForegroundColor White - } -} - -Function RemoveInvalidChars($path) { - $path -replace ("[{0}]" -f (([System.IO.Path]::GetInvalidFileNameChars()| ForEach-Object {[regex]::Escape($_)}) -join '|')), '_' - #return $path -} - - -Function RefreshServer($sitename) { - if ($EFTServer) { - $EftServer.RefreshSettings() - } - else { - Write-host "Not connected to EFT. Use [ Connect-EFT ] first!" -ForegroundColor Red - return $false - } - Get-EftSite -siteName $siteName | Out-Null - return $true -} -#endregion -## -## 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. - -<# - .SYNOPSIS - Encode to plain text to Base64. - .DESCRIPTION - Converts plain text to Base 64 encoded text. - .PARAMETER PlainText - The plain text you want to convert. I.E. SomeSecretPassword - .EXAMPLE - ConvertTo-Base64 -PlainText SomeSecretPassword -#> -Function Convert-StringToBase64 { - [CmdletBinding()] - param( - [Parameter(Mandatory = $true, HelpMessage = "Input Text to Encode", ValueFromPipeline)] [String]$PlainText - ) - - $encodedText = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($PlainText)) - return $encodedText -} - -<# - .SYNOPSIS - Decode Base64 to plain text. - .DESCRIPTION - Converts Base64 encoded text to plain text. - .PARAMETER EncodedText - The plain text you want to convert. I.E. SomeSecretPassword - .EXAMPLE - ConvertFrom-Base64 -EncodedText SomeSecretPassword -#> -Function Convert-StringFromBase64 { - [CmdletBinding()] - param( - [Parameter(Mandatory = $true, HelpMessage = "Input Text to Decode", Position = 1, ValueFromPipeline)] [String]$EncodedText - ) - - $decodedText = [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($EncodedText)) - return $decodedText -} - - -##################################################### -## Module Members Exports (CMDLETS) -##################################################### -#region Module CMDLET exports -Export-ModuleMember -Function 'Connect-EFT' -Export-ModuleMember -Function 'Disconnect-EFT' -Export-ModuleMember -Function 'Show-EftConnection' - -Export-ModuleMember -Function 'Get-EftSites' -Export-ModuleMember -Function 'Get-EftSite' - -Export-ModuleMember -Function 'Get-EftUsers' -Export-ModuleMember -Function 'Get-EftInactiveUsers' - -Export-ModuleMember -Function 'Get-EFTReports' - -Export-ModuleMember -Function 'Remove-EftInactiveUsers' -Export-ModuleMember -Function 'Disable-EftInactiveUsers' -Export-ModuleMember -Function 'Export-EftInactiveUsers' -Export-ModuleMember -Function 'Export-EftUsers' -Export-ModuleMember -Function 'Export-EftUserStorageSpace' -Export-ModuleMember -Function 'Import-EftUsersCSV' - - -Export-ModuleMember -Function 'Export-EftFolders' -Export-ModuleMember -Function 'Import-EftFoldersCsv' - -Export-ModuleMember -Function 'Export-EFTReport' -Export-ModuleMember -Function 'Export-EftSqlQuery' - -Export-ModuleMember -Function 'Export-EventRules' -Export-ModuleMember -Function 'Export-CustomCommands' -Export-ModuleMember -Function 'Convert-PathsFromDictionary' -Export-ModuleMember -Function 'Import-CustomCommands' -Export-ModuleMember -Function 'Import-EventRules' -Export-ModuleMember -Function 'Export-AdvancedWorkflows' -Export-ModuleMember -Function 'Import-AdvancedWorkflows' -Export-ModuleMember -Function 'Export-EventRulesEnableState' -Export-ModuleMember -Function 'Import-EventRulesEnableState' -Export-ModuleMember -Function 'Remove-EventRules' - -Export-ModuleMember -Function 'Publish-AdvancedWorkflows' -Export-ModuleMember -Function 'Publish-EventRules' -Export-ModuleMember -Function 'Publish-CustomCommands' - -Export-ModuleMember -Function 'Get-CountFiles' - -Export-ModuleMember -Variable 'EftServer' -Export-ModuleMember -Variable 'EftSites' -Export-ModuleMember -Variable 'EftSite' - -Export-ModuleMember -Function 'Convert-StringToBase64' -Export-ModuleMember -Function 'Convert-StringFromBase64' -#endregion diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.RegistrySettings.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.RegistrySettings.ps1 deleted file mode 100644 index 172792c..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.RegistrySettings.ps1 +++ /dev/null @@ -1,214 +0,0 @@ -## -## Copyright (C) 2019 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. - -<# - .SYNOPSIS - Get the current registry settings of the EFT Server - .DESCRIPTION - This script will list the current registry settings of the EFT Server - - .EXAMPLE - .\EFT.RegistrySettings.ps1 - - This script may restart your EFT Service - -#> -[CmdletBinding()] -param ( - [Parameter(Position = 6, Mandatory = $False)] - [int] [ValidateRange(0, 86400)] $DrainingTimeoutSecs = 900, - - [Parameter(Position = 6, Mandatory = $False )] - [int] $ClusterOutOfSyncHealSecs = 30, - - [Parameter(Position = 6, Mandatory = $False )] - [string][ValidateSet("msmq-iterative","msmq-broadcasting","msmq-multicast")] $ClusterCoherenceQueueMsmqType = "msmq-iterative", - - [Parameter(Position = 6, Mandatory = $False )] - [int]$ClusterCoherenceQueueDetectPrivateIP = 0, - - [Parameter(Position = 6, Mandatory = $False )] - [switch]$Quiet = $false -) - -#DEBUGGING LINE -#$RegPath = "HKLM:\SOFTWARE\WOW6432Node\GlobalSCAPE Inc.\EFT Server 7.4" -#$RegName = "ShowQuotaControls" - -function Test-RegistryKeyValue -{ - <# - .SYNOPSIS - Tests if a registry value exists. - - .DESCRIPTION - CHecks to see if registry path and name exists. Returns either True or False. - - .EXAMPLE - Test-RegistryKeyValue -Path 'HKLM:\SOFTWARE\WOW6432Node\GlobalSCAPE Inc.\EFT Server 7.4' -Name 'ShowQuotaControls' - Returns `True` if `HKLM:\SOFTWARE\WOW6432Node\GlobalSCAPE Inc.\EFT Server 7.` contains a value named 'ShowQuotaControls'. `False` otherwise. - #> - - [CmdletBinding()] - param( - [Parameter(Mandatory=$true)] - [string] - # The path to the registry key where the value should be set. - $Path, - - [Parameter(Mandatory=$true)] - [string] - # The name of the value being set. - $Name - ) - - - if( -not (Test-Path -Path $Path -PathType Container) ) - { - #DEBUGGING LINE - #Write-host "Reg Path does not exist" - return $false - - } - - $properties = Get-ItemProperty -Path $Path - if( -not $properties ) - { - #DEBUGGING LINE - #Write-host "Reg Path does not exist" - return $false - - } - - $member = Get-Member -InputObject $properties -Name $Name - if( $member ) - { - #DEBUGGING LINE - #Write-host "Registry Name exists" - return $true - - } - else - { - #DEBUGGING LINE - #Write-host "Reg Name does not exist" - return $false - - } - -} - -function Get-RegInfo { -Param ([string]$RegPath, [string]$RegName) -#DEBUGGING LINE -#Write-host "Get-RegInfo Running" - - if( -not (Test-RegistryKeyValue -Path $RegPath -Name $RegName)) - { - Write-host $RegPath : "Key Does not Exist" - } - else - { - Write-host $RegPath\$RegName : (Get-ItemProperty -Path $RegPath -Name $RegName).$RegName - } - -} -@() - - $results += new-object psobject -Property @{ Name = "MySite"; Path = "\"; Description = ""; } - $results += new-object psobject -Property @{ Name = "MySite2222"; Path = "asasdasd"; Description = ""; } - - $results | select Name, Path, Description - $results | ForEach-Object {Test-path $_.Path} - foreach ($row in $results) {$row.Name} - - ## - try { - for ($i = 0 ; $i -le $results.count - 1; $i++) { - $u = $results[$i] - #Concatenate all columns except the mentioned in the ExcludedProperty - $Hash = -join ( $u | Select-Object * -ExcludeProperty SiteName, SCH_NextRun, Validpath, CheckSum) - $Hash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($Hash))) | Select-Object -ExpandProperty Hash - $results[$i].CheckSum = $Hash - } -} -catch { - $results[$i].CheckSum = "NA" -} - - - -Write-host "******* EFT Registry Checker *************************************************" -ForegroundColor Yellow -if ($Quiet -eq $false) { - Write-host " WARNING NOTES:" -ForegroundColor Yellow - Write-host " > This script will modify your EFT registry settings it's recommended you make a backup " -ForegroundColor Yellow - Write-host " > You must perform backups of your EFT config and registry before using this script" -ForegroundColor Yellow - Write-host " > It is recommend you test this script in a non-production environment before " -ForegroundColor Yellow - Write-host " using in production to validate its functionality" -ForegroundColor Yellow - Write-host "******************************************************************************" -ForegroundColor Yellow -} -$CurrentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name -$EftService = Get-Service "EFT *" -$adminPrivileges = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' - - - -#Output parameters -Write-Host "Current datetime : $(Get-Date -f $df)" -Write-Host "Current User : $CurrentUserName" -Write-Host "Admin Privileges : $adminPrivileges" -Write-host "EFT Server Service : " -NoNewline -$OriginalEFTServiceState = $EftService.Status -if ($EftService.Status -eq "Running") {Write-host "$($OriginalEFTServiceState)" -ForegroundColor Green} else {Write-host "$($OriginalEFTServiceState)" -ForegroundColor Red} - -Write-host "" -Write-host "HA Settings" -Write-host "" -Get-RegInfo -RegPath "HKLM:\SOFTWARE\WOW6432Node\GlobalSCAPE Inc.\EFT Server 7.4" -RegName "ShowQuotaControls" -Write-host "ClusterOutOfSyncHealSecs : $ClusterOutOfSyncHealSecs" -Write-host "ClusterCoherenceQueueMsmqType : $ClusterCoherenceQueueMsmqType" -Write-host "ClusterCoherenceQueueDetectPrivateIP: $ClusterCoherenceQueueDetectPrivateIP" - -<# - -if ($Quiet -eq $false) { - $continue = Read-Host -Prompt "Have you read and understand the warning notes (y/n)?" - if ($continue.ToUpper() -ne "Y") { - exit - } -} - - -$EFTServerPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\" -New-Item -Path $EFTServerPath -Name "EFT Server 7.4" -Force | Out-Null - -$EFTServer74RegPath = "$($EFTServerPath)\EFT Server 7.4" -Set-ItemProperty -Path $EFTServer74RegPath -Name DrainingTimeoutSecs -value $DrainingTimeoutSecs -Force -Set-ItemProperty -Path $EFTServer74RegPath -Name ClusterOutOfSyncHealSecs -value $ClusterOutOfSyncHealSecs -Force -Set-ItemProperty -Path $EFTServer74RegPath -Name ClusterCoherenceQueueMsmqType -value $ClusterCoherenceQueueMsmqType -Force -Set-ItemProperty -Path $EFTServer74RegPath -Name ClusterCoherenceQueueDetectPrivateIP -value $ClusterCoherenceQueueDetectPrivateIP -Force - -$EftService = Get-Service "EFT *" - -$restart = "y" -if ($Quiet -eq $false) { - $restart = Read-Host "Do you want to restart EFT Service now (y/n)? " -} - -if ($restart.ToUpper() -eq "Y" ) { - $EftService | Restart-Service - - $sw.Restart() - Write-host "Waiting EFT Service to be Started ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $EftService.WaitForStatus("Running", "00:00:30") - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -#> \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Report.Configuration.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Report.Configuration.ps1 deleted file mode 100644 index c3b5b58..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Report.Configuration.ps1 +++ /dev/null @@ -1,925 +0,0 @@ -## -## 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. - -<# - - .SYNOPSIS - This Script generates a useful configuration information used as report after a Globalscape Quick Start service is completed - .DESCRIPTION - This script will connect to you EFT Server using EFT SFTPCOMInterface API and extract configuration information and it will be output into a TXT file (-ReportFile) - Some cases depending on the EFT version some information won't be available by EFT SFPTCOMInterface API, in such case values will be apperead as ERROR. - .EXAMPLE - .\EFT.Report.ps1 | Tee-Object Executive_Config_Report.txt - .\EFT.Report.ps1 > report.txt - .NOTES - Globalscape Inc. - Version: 1.0 - Last Modified Date: 09/24/2017 - This script is intended to be run safetly without impacting or changing any EFT configuration, so you can use it any time as many times you would like. -#> -[CmdletBinding()] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False, HelpMessage = "HTML Format")] - [switch] $FormatToHTML - -) -function GetRegistrationState ($value) { - $result = -1 - try { - $result = $EFTServer.ModuleRegistrationState($value) - } - catch { } - switch ($result) { - -1 { return "Unknown" } - 0 { return "Registered" } - 1 { return "Evaluation" } - 2 { return "Expired" } - } -} -function GetSiteNodeState($value) { - switch ($value) { - 0 { return "SiteIsRunning" } - 1 { return "SiteIsStopped" } - 2 { return "SiteFailedToStart" } - } -} -function GetDiskType ($value) { - switch ($value) { - 0 { return "$value Unknown" } - 1 { return "$value No Root Directory" } - 2 { return "$value Removable Disk" } - 3 { return "$value Local Drive" } - 4 { return "$value Network Drive" } - 5 { return "$value Compact Disc" } - 6 { return "$value RAM Disk" } - } -} -function GetSerials() { - $serials = @() - - $DMZGateway = "Registry::HKEY_CLASSES_ROOT\IOleVariance.Source2" - $EFTAS2 = "Registry::HKEY_CLASSES_ROOT\HIERCOJ\GREEN" - $AWE = "Registry::HKEY_CLASSES_ROOT\NL.wga.wGm.B2008" - $EFT6Baseline = "Registry::HKEY_CLASSES_ROOT\RDK" - $EFT7Baseline = "Registry::HKEY_CLASSES_ROOT\R2D2" - $EFT6Enterprise = "Registry::HKEY_CLASSES_ROOT\Win64.compat/wow64 " - $EFT7Enterprise = "Registry::HKEY_CLASSES_ROOT\SMB.cluster\availability" - $HighSecurity = "Registry::HKEY_CLASSES_ROOT\GRR\TRIAM" - $DMZ3SingleSite = "Registry::HKEY_CLASSES_ROOT\IOleVariance.Source3" - $DMZ3MultiSite = "Registry::HKEY_CLASSES_ROOT\IOleVariance.Source4" - $Workspaces = "Registry::HKEY_CLASSES_ROOT\IOleVariance.Source7" - $ARM = "Registry::HKEY_CLASSES_ROOT\ARM_RANdl.1" - $PGP = "Registry::HKEY_CLASSES_ROOT\SPLehP\dlog8" - $CIC = "Registry::HKEY_CLASSES_ROOT\HKEY_CLASSES_ROOT\IOleVariance.Source6" - $EFT73WTCCAL = "Registry::HKEY_CLASSES_ROOT\NNIF\NAMUH " - $EFT73WTCCAL = "Registry::HKEY_CLASSES_ROOT\DTI\EWB" - $EFT73SMBFileTransferClient = "Registry::HKEY_CLASSES_ROOT\SCL" - $EFT73SMBFolderMonitorEventRule = "Registry::HKEY_CLASSES_ROOT\SFM" - $EFT73SMBTimerEventModule = "Registry::HKEY_CLASSES_ROOT\STM" - - if (test-path -Path $DMZGateway) { $serials += new-object psobject -Property @{ Name = "DMZGateway" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $DMZGateway).1) } - } - if (test-path -Path $EFTAS2) { $serials += new-object psobject -Property @{ Name = "EFTAS2" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFTAS2).1) } - } - if (test-path -Path $AWE) { $serials += new-object psobject -Property @{ Name = "AWE" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $AWE).1) } - } - if (test-path -Path $EFT6Baseline) { $serials += new-object psobject -Property @{ Name = "EFT6Baseline" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT6Baseline).1) } - } - if (test-path -Path $EFT7Baseline) { $serials += new-object psobject -Property @{ Name = "EFT7Baseline" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT7Baseline).1) } - } - if (test-path -Path $EFT6Enterprise) { $serials += new-object psobject -Property @{ Name = "EFT6Enterprise" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT6Enterprise).1) } - } - if (test-path -Path $EFT7Enterprise) { $serials += new-object psobject -Property @{ Name = "EFT7Enterprise" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT7Enterprise).1) } - } - if (test-path -Path $HighSecurity) { $serials += new-object psobject -Property @{ Name = "HighSecurity" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $HighSecurity).1) } - } - if (test-path -Path $DMZ3SingleSite) { $serials += new-object psobject -Property @{ Name = "DMZ3SingleSite" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $DMZ3SingleSite).1) } - } - if (test-path -Path $DMZ3MultiSite) { $serials += new-object psobject -Property @{ Name = "DMZ3MultiSite" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $DMZ3MultiSite).1) } - } - if (test-path -Path $Workspaces) { $serials += new-object psobject -Property @{ Name = "Workspaces" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $Workspaces).1) } - } - if (test-path -Path $ARM) { $serials += new-object psobject -Property @{ Name = "ARM" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $ARM).1) } - } - if (test-path -Path $PGP) { $serials += new-object psobject -Property @{ Name = "PGP" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $PGP).1) } - } - if (test-path -Path $CIC) { $serials += new-object psobject -Property @{ Name = "CIC" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $CIC).1) } - } - if (test-path -Path $EFT73WTCCAL) { $serials += new-object psobject -Property @{ Name = "EFT73WTCCAL" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT73WTCCAL).1) } - } - if (test-path -Path $EFT73WTCCAL) { $serials += new-object psobject -Property @{ Name = "EFT73WTCCAL" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT73WTCCAL).1) } - } - if (test-path -Path $EFT73SMBFileTransferClient) { $serials += new-object psobject -Property @{ Name = "EFT73SMBFileTransferClient" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT73SMBFileTransferClient).1) } - } - if (test-path -Path $EFT73SMBFolderMonitorEventRule) { $serials += new-object psobject -Property @{ Name = "EFT73SMBFolderMonitorEventRule" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT73SMBFolderMonitorEventRule).1) } - } - if (test-path -Path $EFT73SMBTimerEventModule) { $serials += new-object psobject -Property @{ Name = "EFT73SMBTimerEventModule" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT73SMBTimerEventModule).1) } - } - - return $serials -} - -function GenerateHTMLReport ($report){ - $Header = @" - EFT Configuration Report - $($env:computername) - -"@ - - $fragements = "

EFT Configuration Report

" - $fragements += "Creation Date : $($report.CreationDate)
" - $fragements += "Computer Name : $($report:ComputerName)
" - $fragements += $report.Parameters | Select-Object Name, Value | convertto-html -Fragment -PreContent "

Report Parameters

" - $fragements += "

EFT Configuration

" - - $fragements += "

Server

" - $fragements += "

General

" - $fragements += $report.GeneralStatistics | select-object ServiceStarted, StartTime, Uptime, LastModifiedTime,LastModifiedBy | convertto-html -Fragment -as list -PreContent "

Statistics

" - $fragements += $report.GeneralSettings | select-object ConfigurationFilePath, AllowRemoteAdministration, UseSSLForAdministration, UseUTCInListings| convertto-html -Fragment -as list -PreContent "

General Settings

" - $fragements += $report.ModuleRegistrationState | select-object Module, State | convertto-html -Fragment -PreContent "

Module Registration State

" - $fragements += $report.SerialKeys | convertto-html -Fragment -PreContent "

Serial Keys

" - - $fragements += "

Administration

" - $fragements += $report.Administration | convertto-html -Fragment -as List -PreContent "

Server Administration Connectivity

" - $fragements += $report.AdminAccounts | Select-Object login, permissions | convertto-html -Fragment -PreContent "

Admin Accounts

" - - $fragements += $report.Security | convertto-html -Fragment -as List -PreContent "

Security Settings

" - - $fragements += "

Logs

" - $fragements += $report.LogFileSettings | Select-Object LogPath, LogFormat, LogType, LogRotation | convertto-html -Fragment -as List -PreContent "

Log File Settings

" - $fragements += $report.ARMSettings | Select-Object ARMConnectionStatus, EnableARM, ARMDatabaseType, ARMServerName, ARMDatabaseName, ARMAuthenticationType, ARMUserName, ARMDiagnosticLogging, ARMWhenError,ARMFailureAuditFolder, ARMAttemptToReconnect, ARMReconnectPeriod, ARMNotifyOnDisconnect, ARMNotifyOnReconnect, ARMFailureEmailList | convertto-html -Fragment -as List -PreContent "

Audit Database Settings

" - - $fragements += $report.SMTP | select-object SMTPServer,SMTPPort, SMTPSenderAddr, SMTPSenderName, SMTPUseAuthentication, SMTPLogin, SMTPPassword, SMTPUseImplicitTLS, SMTPAddressBook, SMTPRecipientAddr,SMTPRecipientName | convertto-html -Fragment -as List -PreContent "

SMTP Settings

" - - $fragements += $report.HighAvailability | select-object HAEnabled, HAEventQueue, HAMulticastAddress, HAMulticastPort, HACoherenceQueue, HAConfigurationFilePath, DefaultNodeList, BackupNodeList | convertto-html -Fragment -as List -PreContent "

High Availability

" - - $fragements += "

Sites

" - - - $fragements += "

Site General Settings

" - $fragements += "" - $report.sites | ForEach-Object -Process { $fragements += "" } - $fragements += "" - $report.sites | ForEach-Object -Process { - $fragements +="" - } - $fragements += "
$($_.SiteName)
" - $fragements += $_.SiteGeneralSettings | convertto-html -Fragment - $fragements += "
" - - $fragements += "

Site GS Authentication Settings

" - $fragements += "" - $report.sites | ForEach-Object -Process { $fragements += "" } - $fragements += "" - $report.sites | ForEach-Object -Process { - $fragements +="" - } - $fragements += "
$($_.SiteName)
" - $fragements += $_.SiteGSAuthSettings | convertto-html -Fragment - $fragements += "
" - - $fragements += "

Site ODBC Authentication Settings

" - $fragements += "" - $report.sites | ForEach-Object -Process { $fragements += "" } - $fragements += "" - $report.sites | ForEach-Object -Process { - $fragements +="" - } - $fragements += "
$($_.SiteName)
" - $fragements += $_.SiteODBCAuthSettings | convertto-html -Fragment - $fragements += "
" - - - $fragements += "

Site Active Directory Authentication Settings

" - $fragements += "" - $report.sites | ForEach-Object -Process { $fragements += "" } - $fragements += "" - $report.sites | ForEach-Object -Process { - $fragements +="" - } - $fragements += "
$($_.SiteName)
" - $fragements += $_.SiteADAuthSettings | convertto-html -Fragment - $fragements += "
" - - $fragements += "

Site LDAP Authentication Settings

" - $fragements += "" - $report.sites | ForEach-Object -Process { $fragements += "" } - $fragements += "" - $report.sites | ForEach-Object -Process { - $fragements +="" - } - $fragements += "
$($_.SiteName)
" - $fragements += $_.SiteLDAPAuthSettings | convertto-html -Fragment - $fragements += "
" - - $fragements += "

Site Statistics

" - $fragements += "" - $report.sites | ForEach-Object -Process { $fragements += "" } - $fragements += "" - $report.sites | ForEach-Object -Process { - $fragements +="" - } - $fragements += "
$($_.SiteName)
" - $fragements += $_.SiteStatistics | convertto-html -Fragment - $fragements += "
" - - $fragements += "

Site Connections

" - $fragements += "" - $report.sites | ForEach-Object -Process { $fragements += "" } - $fragements += "" - $report.sites | ForEach-Object -Process { - $fragements +="" - } - $fragements += "
$($_.SiteName)
" - $fragements += $_.SiteConnections | convertto-html -Fragment - $fragements += "
" - - $fragements += "

Site Security Complexity

" - $fragements += "" - $report.sites | ForEach-Object -Process { $fragements += "" } - $fragements += "" - $report.sites | ForEach-Object -Process { - $fragements +="" - } - $fragements += "
$($_.SiteName)
" - $fragements += $_.SiteSecurityComplexity | convertto-html -Fragment - $fragements += "
" - - $fragements += "

Site Security ResetPassword

" - $fragements += "" - $report.sites | ForEach-Object -Process { $fragements += "" } - $fragements += "" - $report.sites | ForEach-Object -Process { - $fragements +="" - } - $fragements += "
$($_.SiteName)
" - $fragements += $_.SiteSecurityResetPassword | convertto-html -Fragment - $fragements += "
" - - $fragements += "

Site Login Invalid Settings

" - $fragements += "" - $report.sites | ForEach-Object -Process { $fragements += "" } - $fragements += "" - $report.sites | ForEach-Object -Process { - $fragements +="" - } - $fragements += "
$($_.SiteName)
" - $fragements += $_.SiteLoginInvalidSettings | convertto-html -Fragment - $fragements += "
" - - $fragements += "

EFT Node Settings

" - - $fragements += $report.EFTFileVersion | convertto-html -Fragment -As List -PreContent "

EFT File Version

" - $fragements += $report.EFTServices |Select-Object Name, Displayname, StartMode, State, Status, Startname, Pathname | convertto-html -Fragment -PreContent "

EFT Services

" - $fragements += $report.EFTSFTPCOMInterfaceFileVersion | convertto-html -Fragment -As List -PreContent "

EFT SFTPCOMInterface File Version

" - $fragements += $report.EFTSFTPCOMInterfaceObject | convertto-html -Fragment -As List -PreContent "

EFT SFTPCOMInterface Object

" - - $fragements += $report.EFTRegistry | Select-Object -ExcludeProperty PSProvider, PSParentPath | convertto-html -Fragment -as list -PreContent "

EFT Registry

" - $fragements += $report.ServerInfo | convertto-html -Fragment -as list -PreContent "

EFT Server Info

" - $fragements += $report.HotFixes | convertto-html -Fragment -PreContent "

OS HotFixes

" - $fragements += $report.DiskInfo | convertto-html -Fragment -PreContent "

Disk Info

" - convertto-html -Head $Header -body $fragements | Out-File EFT.Report.Configuration.html ; invoke-item EFT.Report.Configuration.html -} - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' - - - -$parameters = @() -$parameters += New-object psobject -Property @{Name = "EFTAdminHostname"; Value= $EFTAdminHostname;} -$parameters += New-object psobject -Property @{Name = "EFTAdminPort" ; Value= $EFTAdminPort;} -$parameters += New-object psobject -Property @{Name = "EFTAdminAuthType"; Value= $EFTAdminAuthType;} -$parameters += New-object psobject -Property @{Name = "EFTAdminUsername"; Value= $EFTAdminUsername;} - -$report = new-object psobject -Property @{ - CreationDate = (Get-Date -f $df); - ComputerName = $env:computername; - Parameters = $parameters; - GeneralStatistics = $null; - GeneralSettings = $null; - ModuleRegistrationState = $null; - SerialKeys = $null; - - Administration = $null; - AdminAccounts = $null; - Security = $null; - LogFileSettings = $null; - ARMSettings = $null; - SMTP = $null; - HighAvailability = $null; - Sites = $null; - EFTService = $null; - EFTFileVersion = $null; - EFTServices = $null; - EFTSFTPCOMInterfaceFileVersion = $null; - EFTSFTPCOMInterfaceObject = $null; - EFTRegistry = $null; - ServerInfo = $null; - HotFixes = $null; - DiskInfo = $null; - WindowsServices = $null; -} -$script:EftServer = new-object -ComObject "SFTPCOMInterface.CIServer" -try { - Write-Progress -Activity "Connecting to EFT " -status "EFTAdmin HostName: $EFTAdminHostname" - $sw.Restart() - $script:EftServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - write-Verbose "[$(Get-Date -f $df)] ICIServer.ConnectEx() $($sw.ElapsedMilliseconds)ms" -} -catch [System.Runtime.InteropServices.COMException] { - write-output "Fail to connect to EFT '$($hostname)'. Exception : $($_.Exception.Message)" - throw -} -Write-Progress -Activity "EFT Config" -status "Server Settings" - -$GeneralStatistics = new-object psobject -Property @{ - ServiceStarted = $script:EftServer.IsStarted; - StartTime = $script:EftServer.StartTime; - Uptime = $script:EftServer.Uptime; - LastModifiedTime = $script:EftServer.LastModifiedTime; - LastModifiedBy = $script:EftServer.LastModifiedBy ; -} -$GeneralSettings = new-object psobject -Property @{ - ConfigurationFilePath = $script:EftServer.ConfigurationFilePath; - AllowRemoteAdministration = $script:EftServer.AllowRemoteAdministration; - UseSSLForAdministration = $script:EftServer.UseSSLForAdministration; - UseUTCInListings = $script:EftServer.UseUTCInListings; -} -$report.GeneralStatistics = $GeneralStatistics -$report.GeneralSettings = $GeneralSettings - -$EFTServerModule = 0 -$SSHModule = 1 -$HTTPModule = 2 -$WTCModule = 3 -$ARModule = 4 -$PGPModule = 5 -$HSModule = 6 #(In v7.4.7 and later, this is for the ASM (in Enterprise) or the ESM (in Express) -$AS2Module = 7 -$AWModule = 8 -$DMZGWModule = 9 -$FolderMonitorEventModule = 10 #(v7.2.2 and later) -$TimerEventModule = 11 #(v7.2.2 and later) -$FileTransferClientModule = 12 #(v7.2.2 and later) -$WorkspacesModule = 13 #(v7.2.3 and later) -$AccelerateModule = 14 # (v7.3 and later) -$AAMModule = 15 #(v7.3.3 and later) -$MTCModule = 16 #(v7.3.9 and v7.4.7 and later) -$CICModule = 17 #(v7.3.9 and v7.4.7 and later) -$CCMModule = 18 #(v7.3.9 and v7.4.7 and later) - -$ModuleRegistrationState = @() -try { $ModuleRegistrationState += new-object psobject -Property @{ Module ="EFTServerModule" ; State = GetRegistrationState($EFTServerModule) }} catch { } -try { $ModuleRegistrationState += new-object psobject -Property @{ Module ="SSHModule" ; State = GetRegistrationState($SSHModule) }} catch { } -try { $ModuleRegistrationState += new-object psobject -Property @{ Module ="HTTPModule" ; State = GetRegistrationState($HTTPModule) }} catch { } -try { $ModuleRegistrationState += new-object psobject -Property @{ Module ="WTCModule" ; State = GetRegistrationState($WTCModule) }} catch { } -try { $ModuleRegistrationState += new-object psobject -Property @{ Module ="ARModule" ; State = GetRegistrationState($ARModule) }} catch { } -try { $ModuleRegistrationState += new-object psobject -Property @{ Module ="PGPModule" ; State = GetRegistrationState($PGPModule) }} catch { } -try { $ModuleRegistrationState += new-object psobject -Property @{ Module ="HSModule" ; State = GetRegistrationState($HSModule) }} catch { } -try { $ModuleRegistrationState += new-object psobject -Property @{ Module ="AS2Module" ; State = GetRegistrationState($AS2Module) }} catch { } -try { $ModuleRegistrationState += new-object psobject -Property @{ Module ="AWModule" ; State = GetRegistrationState($AWModule) }} catch { } -try { $ModuleRegistrationState += new-object psobject -Property @{ Module ="DMZGWModule" ; State = GetRegistrationState($DMZGWModule) }} catch { } -try { $ModuleRegistrationState += new-object psobject -Property @{ Module ="FolderMonitorEventModule" ; State = GetRegistrationState($FolderMonitorEventModule) }} catch { } -try { $ModuleRegistrationState += new-object psobject -Property @{ Module ="TimerEventModule" ; State= GetRegistrationState($TimerEventModule) }} catch { } -try { $ModuleRegistrationState += new-object psobject -Property @{ Module ="FileTransferClientModule" ; State = GetRegistrationState($FileTransferClientModule) }} catch { } -try { $ModuleRegistrationState += new-object psobject -Property @{ Module ="AccelerateModule" ; State = GetRegistrationState($AccelerateModule) }} catch { } -try { $ModuleRegistrationState += new-object psobject -Property @{ Module ="AAM" ; State = GetRegistrationState($AAM) } } catch { } - -$report.ModuleRegistrationState = $ModuleRegistrationState -$report.SerialKeys = GetSerials - -$report.Administration = new-object psobject -Property @{ - AdminPort = $EFTServer.AdminPort; - AdminIPAddresses = $EFTServer.GetAdminIPs() -join ';'; - AdminListenIPAddresses = $EFTServer.ListenIPs -join ';'; - WebAdminEnabled = $EFTServer.WebAdminEnabled; - WebAdminPort = $EFTServer.WebAdminPort; -} -$AdminAccounts = @() -ForEach ($admin in $script:EftServer.AdminAccounts) { - $sw.Restart() - $PermissionsCount = $admin.GetPermissionsCount() - $permissionString = "" - for ($i = 0; $i -le $PermissionsCount - 1; $i++) { - $sw.Restart() - $permission = $admin.GetPermission($i) - # AdminPermissionsPolicy: - # ServerManagement = 0, - # SiteManagement = 1, - # STManagement = 2, - # UserCreation = 3, - # ChangePassword = 4, - # COMManagement = 5, - # ReportManagement = 6, - Switch ($permission.Permission) { - 0 { $permissionString = "$permissionString Server Admin(Full);" } - 1 { $permissionString = "$permissionString Site Admin [$($permission.SiteName)];" } - 2 { $permissionString = "$permissionString Template Admin [$($permission.SiteName)->$($permission.TemplateName)]; " } - 3 { $permissionString = "$permissionString User Admin [$($permission.SiteName)->$($permission.TemplateName)];" } - 4 { $permissionString = "$permissionString Change Password Admin [$($permission.SiteName)->$($permission.TemplateName)];" } - 5 { $permissionString = "$permissionString COM;" } - 6 { $permissionString = "$permissionString Report management;" } - 7 { $permissionString = "$permissionString Event Rule Admin [$($permission.SiteName)];" } - } - } - $AdminAccounts += New-Object psobject -Property @{ - Login = $admin.Login; - Permissions = $permissionString; - } -} -$report.AdminAccounts = $AdminAccounts; - -$sslmask = [Convert]::ToString($script:EFTServer.SSLVersionMask, 2) - -While ($SSlmask.length -lt 5) { - $sslmask = "0" + $sslmask -} -# Write-output " TLS 1.2 Enabled : $(($sslmask.substring(0,1) -eq 1))" -# Write-output " TLS 1.1 Enabled : $(($sslmask.substring(1,1) -eq 1))" -# Write-output " TLS 1.0 Enabled : $(($sslmask.substring(4,1) -eq 1))" -# Write-output " SSL 3.0 Enabled : $(($sslmask.substring(3,1) -eq 1))" -# Write-output " SSL 2.0 Enabled : $(($sslmask.substring(2,1) -eq 1))" -$report.Security = New-Object psobject -Property @{ - SSHFIPSEnabled = $script:EftServer.SSHFIPSEnabled; - SSLFIPSEnabled = $script:EftServer.SSLFIPSEnabled; - AllowClearCommandChannel = $script:EftServer.AllowClearCommandChannel; - AllowUnprotectedDataChannel = $script:EftServer.AllowUnprotectedDataChannel; - TLS12Enabled = $(($sslmask.substring(0, 1) -eq 1)) ; - TLS11Enabled = $(($sslmask.substring(1, 1) -eq 1)); - TLS10Enabled = $(($sslmask.substring(4, 1) -eq 1)); - SSL30Enabled = $(($sslmask.substring(3, 1) -eq 1)); - SSL20Enabled = $(($sslmask.substring(2, 1) -eq 1)); -} -if ($script:EftServer.LogMode -eq 0){ - $LogMode = "Standard" -} else { - $LogMode = "Verbose" -} -switch ($script:EFtServer.LogType ) { - 2 { $LogType = "W3C Extended Log File Format "} - 3 { $LogType = "Microsoft IIS Log File Format"} - 4 { $LogType = "NCSA Common Log File Format"} - 5 { $LogType = "None"} -} - -switch ($script:EFtServer.LogRotation) { - 0 {$LogRotation ="Never"} - 1 {$LogRotation ="Daily"} - 2 {$LogRotation ="Weekly"} - 3 {$LogRotation ="Monthly"} -} -$report.LogFileSettings = New-Object psobject -Property @{ - LogPath = $script:EftServer.LogPath; - LogFormat = $LogType; - LogType = $LogMode; - LogRotation = $LogRotation; -} - - -if ( $script:EftServer.ARMDatabaseType -eq 0) { - $ARMDatabaseType = "Oracle" -} else { - $ARMDatabaseType = "SQL Server" -} -if ( $script:EftServer.ARMAuthenticationType -eq 0) { - $ARMAuthenticationType = "Windows Authentication" -} else { - $ARMAuthenticationType = "SQL Authentication" -} -if ($script:EftServer.ARMStopAuditingOnError) { - $ARMWhenError ="Stop Auditing" -} else { - $ARMWhenError = "Audit to folder" -} -if ($script:EftServer.ARMConnectionStatus) { - $ARMConnectionStatus ="CONNECTED" -} else { - $ARMConnectionStatus = "ERROR" -} -try { - if ( $script:EftServer.ARMCommitEventRuleTransferLog -eq 0) { - $ARMCommitEventRuleTransferLog = "None" - } else { - $ARMCommitEventRuleTransferLog = "Failures only" - } -} -catch { - $ARMCommitEventRuleTransferLog = "N/A" -} - -$report.ARMSettings = New-Object psobject -Property @{ - ARMConnectionStatus = $ARMConnectionStatus; - EnableARM = $script:EftServer.EnableARM; - ARMDatabaseType = $ARMDatabaseType; - ARMServerName = $script:EftServer.ARMServerName; - ARMDatabaseName = $script:EftServer.ARMDatabaseName; - ARMAuthenticationType = $ARMAuthenticationType; - ARMUserName = $script:EftServer.ARMUserName ; - ARMDiagnosticLogging = $ARMCommitEventRuleTransferLog; - ARMWhenError = $ARMWhenError ; - ARMFailureAuditFolder = $script:EftServer.ARMFailureAuditFolder ; - ARMAttemptToReconnect = $script:EftServer.ARMHealConnection; - ARMReconnectPeriod = $script:EftServer.ARMReconnectPeriod; - ARMNotifyOnDisconnect = $script:EftServer.ARMNotifyOnDisconnect ; - ARMNotifyOnReconnect = $script:EftServer.ARMNotifyOnReconnect ; - ARMFailureEmailList = $script:EftServer.ARMFailureEmailList; - - -} - -$report.SMTP = New-Object psobject -Property @{ - SMTPServer = $script:EftServer.SMTPServer; - SMTPPort = $script:EftServer.SMTPPort; - SMTPSenderAddr = $script:EftServer.SMTPSenderAddr; - SMTPSenderName = $script:EftServer.SMTPSenderName; - SMTPUseAuthentication = $script:EftServer.SMTPUseAuthentication; - SMTPLogin = $script:EftServer.SMTPLogin; - SMTPPassword = "*****" - SMTPUseImplicitTLS = $script:EftServer.SMTPUseImplicitTLS; - SMTPAddressBook = $script:EftServer.SMTPAddressBook; - SMTPRecipientAddr = $script:EftServer.SMTPRecipientAddr; - SMTPRecipientName = $script:EftServer.SMTPRecipientName; -} - -if($script:EftServer.HAEnabled) { - $report.HighAvailability = New-Object psobject -Property @{ - HAEnabled = $script:EftServer.HAEnabled; - HAEventQueue = $script:EftServer.HAEventQueue; - HAMulticastAddress = $script:EftServer.HAMulticastAddress; - HAMulticastPort = $script:EftServer.HAMulticastPort; - HACoherenceQueue = $script:EftServer.HACoherenceQueue; - HAConfigurationFilePath = $script:EftServer.HAConfigurationFilePath; - DefaultNodeList = $script:EftServer.HAConfigurationDefaultNodeList -join ","; - BackupNodeList = $script:EftServer.HAConfigurationBackupNodeList -join ","; - } -} -else { - $report.HighAvailability = New-Object psobject -Property @{ - HAEnabled = $script:EftServer.HAEnabled; - HAEventQueue = "NA"; - HAMulticastAddress = "NA"; - HAMulticastPort = "NA"; - HACoherenceQueue = "NA"; - HAConfigurationFilePath = "NA"; - DefaultNodeList = "NA"; - BackupNodeList = "NA"; - } -} -$sw.Restart() -$script:EftSites = $script:EftServer.Sites() -write-Verbose "[$(Get-Date -f $df)] ICIServer.Sites() $($sw.ElapsedMilliseconds )ms" - -$sw.Restart() -$count = $script:EftSites.Count() - - -$sites = @() -for ($i = 0; $i -le $count - 1; $i++ ) { - - - $script:EftSite = $script:EftSites.Item($i) - $SiteGuid = $null - try { - $SiteGuid = $script:EftSite.GUID - } - catch [System.Runtime.InteropServices.COMException] { - - } - $SiteId = $script:EftSite.ID - $siteName = $script:EftSite.Name - - $general = @() - $GSParams = @() - $ODBCParams = @() - $ADParams = @() - $LDAPParams = @() - $statistics = @() - $connections = @() - $complexPasswordSettings = @() - $resetPasswordSettings = @() - $LoginInvalidSettings = @() - - Write-Progress -Activity "Processing Sites" -status "Site '$SiteName' $i/$Count" -percentComplete ($i / $Count * 100) - $AuthManagerID = $script:EftSite.GetAuthManagerID() - Switch ($AuthManagerID) { - 0 { $SiteAuthType = "GS Authentication" } - 1 { $SiteAuthType = "Active Directory/NTLM" } - 2 { $SiteAuthType = "ODBC" } - 3 { $SiteAuthType = "LDAP Authentication" } - } - - try { $general += new-object psobject -Property @{ Setting ="SiteName" ; Value = $siteName }} catch { } - try { $general += new-object psobject -Property @{ Setting ="SiteID" ; Value = $SiteID }} catch { } - try { $general += new-object psobject -Property @{ Setting ="SiteGUID" ; Value = $SiteGUID;}} catch { } - try { $general += new-object psobject -Property @{ Setting ="RootFolder" ; Value = $script:EftSite.GetRootFolder();}} catch { } - try { $general += new-object psobject -Property @{ Setting ="SiteAuthType" ; Value = $SiteAuthType;}} catch { } - try { $general += new-object psobject -Property @{ Setting ="ODBCSettings" ; Value = $script:EftSite.ODBCSettings;}} catch { } - try { $general += new-object psobject -Property @{ Setting ="RadiusServerName" ; Value = $script:EftSite.RadiusServerName;}} catch { } - try { $general += new-object psobject -Property @{ Setting ="RadiusServerPort" ; Value = $script:EftSite.RadiusServerPort;}} catch { } - try { $general += new-object psobject -Property @{ Setting ="RadiusNasIdentifier" ; Value = $script:EftSite.RadiusNasIdentifier;}} catch { } - try { $general += new-object psobject -Property @{ Setting ="RadiusSharedSecret" ; Value = $script:EftSite.RadiusSharedSecret;}} catch { } - try { $general += new-object psobject -Property @{ Setting ="RadiusConnectionRetriesCount" ; Value = $script:EftSite.RadiusConnectionRetriesCount;}} catch { } - try { $general += new-object psobject -Property @{ Setting ="RadiusTimeout" ; Value = $script:EftSite.RadiusTimeout;}} catch { } - try { $general += new-object psobject -Property @{ Setting ="RSAConfigurationPath" ; Value = $script:EftSite.RSAConfigurationPath;}} catch { } - - $AMParam = $script:EftSite.GetAMParams() - if( $AMParam.Domain -eq 0 ){ - $ADType = "Active Directory" - } else { - $ADType = "NTLM" - } - switch ($AMParam.LogonAttribute) { - 0 { $ADLogonAttribute = "NT4AccountName" } - 1 { $ADLogonAttribute = "DisplayName"} - 2 { $ADLogonAttribute = "UserPrincipalName"} - 3 { $ADLogonAttribute = "CommonName"} - Default { $ADLogonAttribute = "Unknown"} - } - - try { - $UseWindowsAccessPermissions = $AMParams.UseWindowsAccessPermissions - } - catch { - $UseWindowsAccessPermissions= "" - } - switch ($AMParam.SearchScope ) { - 0 { $LDAPSearchScope= "Base" } - 1 { $LDAPSearchScope= "One Level" } - 2 { $LDAPSearchScope= "Subtree" } - Default {$LDAPSearchScope = "Unknown"} - } - switch ($AMParam.LDAPVersion) { - 2 { $LDAPVersion = "Version2" } - 3 { $LDAPVersion = "Version3" } - Default { $LDAPVersion= "Unknown"} - } - - try { $GSParams += new-object psobject -Property @{ Setting ="SiteName" ; Value = $siteName }} catch { } - try { $GSParams += new-object psobject -Property @{ Setting ="SiteAuthType" ; Value = $SiteAuthType }} catch { } - try { $GSParams += new-object psobject -Property @{ Setting ="RefreshIntervalMinutes" ; Value = $AMParam.RefreshIntervalMinutes }} catch { } - - try { $GSParams += new-object psobject -Property @{ Setting ="GSUserDatabasePath" ; Value = $AMParam.UserDatabasePath }} catch { } - - try { $ODBCParams += new-object psobject -Property @{ Setting ="SiteName" ; Value = $siteName }} catch { } - try { $ODBCParams += new-object psobject -Property @{ Setting ="SiteAuthType" ; Value = $SiteAuthType }} catch { } - try { $ODBCParams += new-object psobject -Property @{ Setting ="RefreshIntervalMinutes" ; Value = $AMParam.RefreshIntervalMinutes }} catch { } - try { $ODBCParams += new-object psobject -Property @{ Setting ="ODBCUserDatabaseConnectionString" ; Value = $AMParam.UserDatabaseConnectionString }} catch { } - - try { $ADParams += new-object psobject -Property @{ Setting ="SiteName" ; Value = $siteName }} catch { } - try { $ADParams += new-object psobject -Property @{ Setting ="SiteAuthType" ; Value = $SiteAuthType }} catch { } - try { $ADParams += new-object psobject -Property @{ Setting ="ADType" ; Value = $ADType }} catch { } - try { $ADParams += new-object psobject -Property @{ Setting ="ADDomain" ; Value = $AMParam.Domain }} catch { } - try { $ADParams += new-object psobject -Property @{ Setting ="ADGroup" ; Value = $AMParam.Group }} catch { } - try { $ADParams += new-object psobject -Property @{ Setting ="ADLogonAttribute" ; Value = $ADLogonAttribute }} catch { } - try { $ADParams += new-object psobject -Property @{ Setting ="ADCreateUsersOnlyByLogin" ; Value = $AMParams.CreateUsersOnlyByLogin }} catch { } - try { $ADParams += new-object psobject -Property @{ Setting ="ADAssignHomeFolderFromUserProfile" ; Value = $AMParam.AssignHomeFolderFromUserProfile }} catch { } - try { $ADParams += new-object psobject -Property @{ Setting ="ADKeepHomeFoldersInSync" ; Value = $AMParams.KeepHomeFoldersInSync }} catch { } - try { $ADParams += new-object psobject -Property @{ Setting ="ADSkipDomainPrefix" ; Value = $AMParam.SkipDomainPrefix }} catch { } - try { $ADParams += new-object psobject -Property @{ Setting ="ADUseWindowsAccessPermissions" ; Value = $UseWindowsAccessPermissions }} catch { } - - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPCreateUsersOnlyByLogin" ; Value = $AMParam.CreateUsersOnlyByLogin }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPServer" ; Value = $AMParam.Server }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPPort" ; Value = $AMParam.Port }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPBaseDN" ; Value = $AMParam.BaseDN }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPUserFilter" ; Value = $AMParam.UserFilter }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPSearchAttributes" ; Value = $AMParam.SearchAttributes }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPUseSSL" ; Value = $AMParam.UseSSL }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPServerUserName" ; Value = $AMParam.ServerUserName }} catch { } - #try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPServerPassword" ; Value = Value = $AMParam.ServerPassword }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPServerPassword" ; Value = "*****" }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPAdditionalUserSettingsPath" ; Value = $AMParam.AdditionalUserSettingsPath }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPTimeoutSeconds" ; Value = $AMParam.TimeoutSeconds }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPSearchScope" ; Value = $LDAPSearchScope }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPChaseReferrals" ; Value = $AMParam.ChaseReferrals }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPLDAPVersion" ; Value = $LDAPVersion }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPUsePageControl" ; Value = $AMParam.UsePageControl }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPPageSizeEntries" ; Value = $AMParam.PageSizeEntries }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPUseSearchAttributes" ; Value = $AMParam.UseSearchAttributes }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPSettingsTemplateAttributes" ; Value = $AMParams.SettingsTemplateAttributes }} catch { } - try { $LDAPParams += new-object psobject -Property @{ Setting ="LDAPAutoCreateSettingsTemplate" ; Value = $AMParams.AutoCreateSettingsTemplate }} catch { } - - $IsStarted = $script:EftSite.IsStarted - $AverageSpeed = $script:EftSite.AverageSpeed - $UsersDefined = $script:EftSite.UsersDefined - $WTCSessionsActive = $script:EftSite.WTCSessionsActive - $WTCSessionsRemaining = $script:EftSite.WTCSessionsRemaining - $Users = $script:EftSite.GetUsers() - $SettingsLevels = $script:EftSite.GetSettingsLevels() - - try { $statistics += new-object psobject -Property @{ Setting ="SiteName" ; Value = $siteName }} catch { } - try { $statistics += new-object psobject -Property @{ Setting ="IsStarted" ; Value = $IsStarted }} catch { } - try { $statistics += new-object psobject -Property @{ Setting ="AverageSpeed" ; Value = $AverageSpeed }} catch { } - try { $statistics += new-object psobject -Property @{ Setting ="UserCount" ; Value = $Users.Count }} catch { } - try { $statistics += new-object psobject -Property @{ Setting ="UsersDefined" ; Value = $UsersDefined }} catch { } - try { $statistics += new-object psobject -Property @{ Setting ="SettingsLevelsCount" ; Value = $SettingsLevels.Count }} catch { } - try { $statistics += new-object psobject -Property @{ Setting ="WTCSessionsRemaining" ; Value = $WTCSessionsRemaining }} catch { } - try { $statistics += new-object psobject -Property @{ Setting ="WTCSessionsActive" ; Value = $WTCSessionsActive }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SiteName" ; Value = $siteName }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SiteIPaddr" ; Value = $script:EftSite.GetIP() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="FTPAccess" ; Value = $script:EftSite.GetFTPAccess() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="FTPPort" ; Value = $script:EftSite.GetPort() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="FTPEncoding" ; Value = $script:EftSite.FTPEncoding }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="AllowFXP" ; Value = $script:EftSite.GetAllowFXP() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="AllowCOMB" ; Value = $script:EftSite.GetAllowCOMB() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="AllowXCRC" ; Value = $script:EftSite.GetAllowXCRC() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="FTPSExp" ; Value = $script:EftSite.GetSSLAuth() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="FTPSExplicitPort" ; Value = $script:EftSite.FTPSExplicitPort }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="FTPSImplicitPort" ; Value = $script:EftSite.FTPSImplicitPort }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SSLImp" ; Value = $script:EftSite.GetSSLImp() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="BlockAntiTimeOut" ; Value = $script:EftSite.BlockAntiTimeOut }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="PASVListenIP" ; Value = $script:EftSite.PASVListenIP }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="PASVPortMax" ; Value = $script:EftSite.PASVPortMax }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="PASVPortMin" ; Value = $script:EftSite.PASVPortMin }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="ConnectMessage" ; Value = $script:EftSite.ConnectMessage }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="ExitMessage" ; Value = $script:EftSite.ExitMessage }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="UserLimitMessage" ; Value = $script:EftSite.UserLimitMessage }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SFTPAccess" ; Value = $script:EftSite.GetSFTPAccess() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SFTPPort" ; Value = $script:EftSite.SFTPPort }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SFTPEncoding" ; Value = $script:EftSite.SFTPEncoding }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SFTPKeyFile" ; Value = $script:EftSite.SFTPKeyFile }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SFTPKeyPassphrase" ; Value = "*****" }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SFTPEncodingAlgorithms" ; Value = $script:EftSite.SFTPEncodingAlgorithms }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SFTPMacAlgorithms" ; Value = $script:EftSite.SFTPMacAlgorithms }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SFTPSoftwareVersion" ; Value = $script:EftSite.SFTPSoftwareVersion }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SFTPIdentificationComment" ; Value = $script:EftSite.SFTPIdentificationComment }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="HTTPAccess" ; Value = $script:EftSite.GetHTTPAccess() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="HTTPPort" ; Value = $script:EftSite.GetHTTPPort() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="HTTPSAccess" ; Value = $script:EftSite.GetHTTPSAccess() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="HTTPSPort" ; Value = $script:EftSite.GetHTTPSPort() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="HTTPDomain" ; Value = $script:EftSite.HTTPDomain }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="EnableWebServices" ; Value = $script:EftSite.EnableWebServices}} catch { } - try { $connections += new-object psobject -Property @{ Setting ="RedirectHTTPtoHTTPS" ; Value = $script:EftSite.RedirectHTTPtoHTTPS }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="EnableAccountManagementOverHTTPS" ; Value = $script:EftSite.EnableAccountManagementOverHTTPS }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="AccountManagementPath" ; Value = $script:EftSite.AccountManagementPath}} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SSLCertPath" ; Value = $script:EftSite.GetCertFilePath() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SSLKeyFilePath" ; Value = $script:EftSite.GetKeyFilePath() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SSLPassPhrase" ; Value = "*****" }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="SSLCheckClientCert" ; Value = $script:EftSite.GetHTTPAccess() }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="HasMaxSpeed" ; Value = $script:EftSite.HasMaxSpeed}} catch { } - try { $connections += new-object psobject -Property @{ Setting ="HasMaxUsers" ; Value = $script:EftSite.HasMaxUsers }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="HasMaxConcurrentLogins" ; Value = $script:EftSite.HasMaxConcurrentLogins}} catch { } - try { $connections += new-object psobject -Property @{ Setting ="HasMaxConnectionsPerAccount" ; Value = $script:EftSite.HasMaxConnectionsPerAccount }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="HasMaxIPPerAccount" ; Value = $script:EftSite.HasMaxIPPerAccount }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="MaxTransferSpeed" ; Value = $script:EftSite.MaxTransferSpeed }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="MaxConcurrentConnections" ; Value = $script:EftSite.MaxConcurrentConnections }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="MaxConcurrentLogins" ; Value = $script:EftSite.MaxConcurrentLogins }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="MaxConnectionsPerUser" ; Value = $script:EftSite.MaxConnectionsPerUser}} catch { } - try { $connections += new-object psobject -Property @{ Setting ="MaxConnectionsFromSameIP" ; Value = $script:EftSite.MaxConnectionsFromSameIP }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="IPAccessAllowedDefault" ; Value = $script:EftSite.IPAccessAllowedDefault }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="DisconnectOnDOS" ; Value = $script:EftSite.DisconnectOnDOS }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="DOSLimit" ; Value = $script:EftSite.DOSLimit }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="BanIPOnDOS" ; Value = $script:EftSite.BanIPOnDOS }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="AutobanSensitivity" ; Value = $script:EftSite.AutobanSensitivity }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="AutoBanIPsPermanently" ; Value = $script:EftSite.AutoBanIPsPermanently }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="EnableMTC" ; Value = $script:EftSite.EnableMTC }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="MTCAllowFileCaching" ; Value = $script:EftSite.MTCAllowFileCaching }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="MTCAllowFileOpening" ; Value = $script:EftSite.MTCAllowFileOpening }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="MTCAllowFileSharing" ; Value = $script:EftSite.MTCAllowFileSharing }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="MTCAllowSavingOffline" ; Value = $script:EftSite.MTCAllowSavingOffline }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="MTCAllowSavingPasswords" ; Value = $script:EftSite.MTCAllowSavingPasswords }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="DefaultSettingsLevel" ; Value = $script:EftSite.DefaultSettingsLevel }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="EnableWorkspaces" ; Value = $script:EftSite.EnableWorkspaces }} catch { } - try { $connections += new-object psobject -Property @{ Setting ="EnableWorkspacesExternalUsers" ; Value = $script:EftSite.EnableWorkspacesExternalUsers }} catch { } - - $complexPassword = $script:EftSite.GetComplexPasswordSettings() - try { $complexPasswordSettings += new-object psobject -Property @{ Setting ="SiteName" ; Value = $siteName }} catch { } - try { $complexPasswordSettings += new-object psobject -Property @{ Setting ="MaxRepeatingCharacters" ; Value = $complexPassword.MaxRepeatingCharacters }} catch { } - try { $complexPasswordSettings += new-object psobject -Property @{ Setting ="MaxUsernameCharactersInPassword" ; Value = $complexPassword.MaxUsernameCharactersInPassword }} catch { } - try { $complexPasswordSettings += new-object psobject -Property @{ Setting ="MinCharCategoriesInPassword" ; Value = $complexPassword.MinCharCategoriesInPassword }} catch { } - try { $complexPasswordSettings += new-object psobject -Property @{ Setting ="MinPasswordLength" ; Value = $complexPassword.MinPasswordLength }} catch { } - try { $complexPasswordSettings += new-object psobject -Property @{ Setting ="PasswordDictionaryPath" ; Value = $complexPassword.PasswordDictionaryPath }} catch { } - try { $complexPasswordSettings += new-object psobject -Property @{ Setting ="ProhibitDictionaryWordsInPassword" ; Value = $complexPassword.ProhibitDictionaryWordsInPassword }} catch { } - try { $complexPasswordSettings += new-object psobject -Property @{ Setting ="ProhibitReverseDictionaryWordsInPassword" ; Value = $complexPassword.ProhibitReverseDictionaryWordsInPassword }} catch { } - try { $complexPasswordSettings += new-object psobject -Property @{ Setting ="RequireDigitsInPassword" ; Value = $complexPassword.RequireDigitsInPassword }} catch { } - try { $complexPasswordSettings += new-object psobject -Property @{ Setting ="RequireLowerCaseInPassword" ; Value = $complexPassword.RequireLowerCaseInPassword }} catch { } - try { $complexPasswordSettings += new-object psobject -Property @{ Setting ="RequireNonAlphaNumericInPassword" ; Value = $complexPassword.RequireNonAlphaNumericInPassword }} catch { } - try { $complexPasswordSettings += new-object psobject -Property @{ Setting ="RequireUpperCaseInPassword" ; Value = $complexPassword.RequireUpperCaseInPassword }} catch { } - - $resetPassword = $script:EftSite.GetResetPasswordSettings() - try { $resetPasswordSettings += new-object psobject -Property @{ Setting ="SiteName" ; Value = $siteName }} catch { } - try { $resetPasswordSettings += new-object psobject -Property @{ Setting ="DaysPriorPasswordExpirationToRemindUser" ; Value = $resetPassword.DaysPriorPasswordExpirationToRemindUser }} catch { } - try { $resetPasswordSettings += new-object psobject -Property @{ Setting ="MaxPasswordAgeDays" ; Value = $resetPassword.MaxPasswordAgeDays }} catch { } - try { $resetPasswordSettings += new-object psobject -Property @{ Setting ="SendEMailBeforeExpiration" ; Value = $resetPassword.SendEMailBeforeExpiration }} catch { } - try { $resetPasswordSettings += new-object psobject -Property @{ Setting ="SendEMailUponExpiration" ; Value = $resetPassword.SendEMailUponExpiration }} catch { } - - try { $LoginInvalidSettings += new-object psobject -Property @{ Setting ="SiteName" ; Value = $siteName }} catch { } - try { $LoginInvalidSettings += new-object psobject -Property @{ Setting ="LimitLoginAttempts" ; Value = $script:EftSite.LimitLoginAttempts }} catch { } - try { $LoginInvalidSettings += new-object psobject -Property @{ Setting ="LockoutNotDisable" ; Value = $script:EftSite.LockoutNotDisable }} catch { } - try { $LoginInvalidSettings += new-object psobject -Property @{ Setting ="SendEMailBeforeExpiration" ; Value = $script:EftSite.SendEMailBeforeExpiration }} catch { } - try { $LoginInvalidSettings += new-object psobject -Property @{ Setting ="SendEMailUponExpiration" ; Value = $script:EftSite.SendEMailUponExpiration }} catch { } - - $site = New-Object psobject -Property @{ - SiteName = $siteName - SiteGeneralSettings = $general; - SiteGSAuthSettings = $GSParams; - SiteODBCAuthSettings = $ODBCParams; - SiteADAuthSettings = $ADParams; - SiteLDAPAuthSettings = $LDAPParams; - SiteStatistics = $statistics; - SiteConnections = $connections; - SiteSecurityComplexity = $complexPasswordSettings; - SiteSecurityResetPassword = $resetPasswordSettings; - SiteLoginInvalidSettings = $LoginInvalidSettings; - } - $sites += $site -} -$report.Sites = $sites - -#Add modified WTC Customized files - -#EFT Node Metadata -Write-Progress -Activity "EFT Node Metadata" -status " EFT Services" -$EftServicePath = Get-WmiObject win32_service | Where-Object { $_.name -Like "EFT*" } | Select-Object pathname -ExpandProperty pathname -$EftServicePath = $EftServicePath -replace """", "" -$EftServiceName = Get-WmiObject win32_service | Where-Object { $_.name -Like "EFT*" } | Select-Object name -ExpandProperty name -$EftServiceType = if ($EftserviceName -like "*Enterprise*") { "EFT Enterprise" } else { "SMB" } -$EftServiceIdentity = Get-WmiObject win32_service | Where-Object { $_.name -Like "EFT*" } | Select-Object startname -ExpandProperty startname -$EftFileVersion = Get-ItemProperty $EftServicePath -name "VersionInfo" | Select-Object VersionInfo -ExpandProperty VersionInfo - -$report.EFTService = new-object psobject -Property @{ EftServicePath = $EftServicePath -join "|"; EftServiceName = $EftServiceName -join "|"; EftServiceType = $EftServiceType; EftServiceIdentity = $EftServiceIdentity -join "|"; } -$report.EFTFileVersion = $EftFileVersion - -$report.EFTServices = Get-WmiObject win32_service | Where-Object { ($_.name -Like "EFT*" ) -or ($_.name -Like "MSMQ*" ) } - -Write-Progress -Activity "EFT Node Metadata" -status " SFTPCOMInterface COM API" -# EFT SFTPCOMInterface COM API -#[EFT SFTPCOMInterface Registered] -$EFTSFTPCOMInterfaceAppID = Get-ItemProperty -Path 'Registry::HKEY_CLASSES_ROOT\AppId\SFTPCOMInterface.dll' | Select-Object AppId -ExpandProperty AppId -$EFTSFTPCOMInterfacePath = Get-ItemProperty -Path 'Registry::HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{A59E7747-3284-435B-8947-4E004361A6AC}\InprocServer32' | Select-Object '(default)' -ExpandProperty '(default)' -$report.EFTSFTPCOMInterfaceFileVersion = Get-ItemProperty $EFTSFTPCOMInterfacePath -name "VersionInfo" | Select-Object VersionInfo -ExpandProperty VersionInfo -$report.EFTSFTPCOMInterfaceObject = new-object psobject -Property @{ EFTSFTPCOMInterfaceAppID = $EFTSFTPCOMInterfaceAppID; EFTSFTPCOMInterfacePath = $EFTSFTPCOMInterfacePath; } - -$RegItems = @() -Write-Progress -Activity "EFT Node Metadata" -status " EFT Registry Settings" -# EFT Registry Settings -$EFTServer30RegLoc = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\EFT Server 3.0' -$EFTServer40RegLoc = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\EFT Server 4.0' -$EFTServer70RegLoc = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\EFT Server 7.0' -$EFTServer71RegLoc = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\EFT Server 7.1' -$EFTServer73RegLoc = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\EFT Server 7.3' -$EFTServer74RegLoc = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\EFT Server 7.4' -$EFTServerEnterpriseRegLoc = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\EFT Server Enterprise' - -if (test-path -Path $EFTServer30RegLoc) { $RegItems += Get-ItemProperty -Path $EFTServer30RegLoc |Select-Object * -ExcludeProperty PSProvider, PSParentPath } -if (test-path -Path $EFTServer40RegLoc) { $RegItems += Get-ItemProperty -Path $EFTServer40RegLoc |Select-Object * -ExcludeProperty PSProvider, PSParentPath} -if (test-path -Path $EFTServer70RegLoc) { $RegItems += Get-ItemProperty -Path $EFTServer70RegLoc |Select-Object * -ExcludeProperty PSProvider, PSParentPath} -if (test-path -Path $EFTServer71RegLoc) { $RegItems += Get-ItemProperty -Path $EFTServer71RegLoc |Select-Object * -ExcludeProperty PSProvider, PSParentPath} -if (test-path -Path $EFTServer73RegLoc) { $RegItems += Get-ItemProperty -Path $EFTServer73RegLoc |Select-Object * -ExcludeProperty PSProvider, PSParentPath} -if (test-path -Path $EFTServer74RegLoc) { $RegItems += Get-ItemProperty -Path $EFTServer74RegLoc |Select-Object * -ExcludeProperty PSProvider, PSParentPath} -if (test-path -Path $EFTServerEnterpriseRegLoc) { $RegItems += Get-ItemProperty -Path $EFTServerEnterpriseRegLoc |Select-Object * -ExcludeProperty PSProvider, PSParentPath} - -$report.EFTRegistry = $RegItems - -Write-Progress -Activity "EFT Node Metadata" -status " Computer Info" -# Computer Info -$report.ServerInfo = Get-ComputerInfo - -Write-Progress -Activity "EFT Node Metadata" -status " HotFixes" -# HotFixes -$report.HotFixes = $report.ServerInfo | Select-Object -ExpandProperty OsHotFixes - -Write-Progress -Activity "EFT Node Metadata" -status " Disk(s) Info " -# Disk(s) Info -$report.DiskInfo = Get-WmiObject -Class Win32_logicaldisk | Select-Object -Property DeviceID, @{L = 'Drive Type'; E = { GetDiskType($_.DriveType) } } , VolumeName, @{L = 'FreeSpace GB'; E = { "{0:N2}" -f ($_.FreeSpace / 1GB) } }, @{L = "Capacity GB"; E = { "{0:N2}" -f ($_.Size / 1GB) } } - -Write-Progress -Activity "EFT Node Metadata" -status " Windows Services" -#Windows Services -$report.WindowsServices = Get-WmiObject win32_service - -# Report output -if (!$FormatToHTML) { - $report -} else { - - GenerateHTMLReport $report -} - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Report.Node.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Report.Node.ps1 deleted file mode 100644 index 7dd8367..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Report.Node.ps1 +++ /dev/null @@ -1,230 +0,0 @@ -## -## 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. - -<# - - .SYNOPSIS - This Script generates a useful configuration information used as report after a Globalscape Quick Start service is completed - .DESCRIPTION - This script will connect to you EFT Server using EFT SFTPCOMInterface API and extract configuration information and it will be output into a TXT file (-ReportFile) - Some cases depending on the EFT version some information won't be available by EFT SFPTCOMInterface API, in such case values will be apperead as ERROR. - .EXAMPLE - .\EFT.Report.ps1 | Tee-Object Executive_Config_Report.txt - .\EFT.Report.ps1 > report.txt - .NOTES - Globalscape Inc. - Version: 1.0 - Last Modified Date: 09/24/2017 - This script is intended to be run safetly without impacting or changing any EFT configuration, so you can use it any time as many times you would like. -#> -[CmdletBinding()] -Param( - [Parameter(Position = 0, Mandatory = $False, HelpMessage = "HTML Format")] - [switch] $FormatToHTML - -) -function GetDiskType ($value) { - switch ($value) { - 0 { return "$value Unknown" } - 1 { return "$value No Root Directory" } - 2 { return "$value Removable Disk" } - 3 { return "$value Local Drive" } - 4 { return "$value Network Drive" } - 5 { return "$value Compact Disc" } - 6 { return "$value RAM Disk" } - } -} -function GetSerials() { - $serials = @() - - $DMZGateway = "Registry::HKEY_CLASSES_ROOT\IOleVariance.Source2" - $EFTAS2 = "Registry::HKEY_CLASSES_ROOT\HIERCOJ\GREEN" - $AWE = "Registry::HKEY_CLASSES_ROOT\NL.wga.wGm.B2008" - $EFT6Baseline = "Registry::HKEY_CLASSES_ROOT\RDK" - $EFT7Baseline = "Registry::HKEY_CLASSES_ROOT\R2D2" - $EFT6Enterprise = "Registry::HKEY_CLASSES_ROOT\Win64.compat/wow64 " - $EFT7Enterprise = "Registry::HKEY_CLASSES_ROOT\SMB.cluster\availability" - $HighSecurity = "Registry::HKEY_CLASSES_ROOT\GRR\TRIAM" - $DMZ3SingleSite = "Registry::HKEY_CLASSES_ROOT\IOleVariance.Source3" - $DMZ3MultiSite = "Registry::HKEY_CLASSES_ROOT\IOleVariance.Source4" - $Workspaces = "Registry::HKEY_CLASSES_ROOT\IOleVariance.Source7" - $ARM = "Registry::HKEY_CLASSES_ROOT\ARM_RANdl.1" - $PGP = "Registry::HKEY_CLASSES_ROOT\SPLehP\dlog8" - $CIC = "Registry::HKEY_CLASSES_ROOT\HKEY_CLASSES_ROOT\IOleVariance.Source6" - $EFT73WTCCAL = "Registry::HKEY_CLASSES_ROOT\NNIF\NAMUH " - $EFT73WTCCAL = "Registry::HKEY_CLASSES_ROOT\DTI\EWB" - $EFT73SMBFileTransferClient = "Registry::HKEY_CLASSES_ROOT\SCL" - $EFT73SMBFolderMonitorEventRule = "Registry::HKEY_CLASSES_ROOT\SFM" - $EFT73SMBTimerEventModule = "Registry::HKEY_CLASSES_ROOT\STM" - - if (test-path -Path $DMZGateway) { $serials += new-object psobject -Property @{ Name = "DMZGateway" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $DMZGateway).1) } - } - if (test-path -Path $EFTAS2) { $serials += new-object psobject -Property @{ Name = "EFTAS2" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFTAS2).1) } - } - if (test-path -Path $AWE) { $serials += new-object psobject -Property @{ Name = "AWE" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $AWE).1) } - } - if (test-path -Path $EFT6Baseline) { $serials += new-object psobject -Property @{ Name = "EFT6Baseline" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT6Baseline).1) } - } - if (test-path -Path $EFT7Baseline) { $serials += new-object psobject -Property @{ Name = "EFT7Baseline" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT7Baseline).1) } - } - if (test-path -Path $EFT6Enterprise) { $serials += new-object psobject -Property @{ Name = "EFT6Enterprise" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT6Enterprise).1) } - } - if (test-path -Path $EFT7Enterprise) { $serials += new-object psobject -Property @{ Name = "EFT7Enterprise" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT7Enterprise).1) } - } - if (test-path -Path $HighSecurity) { $serials += new-object psobject -Property @{ Name = "HighSecurity" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $HighSecurity).1) } - } - if (test-path -Path $DMZ3SingleSite) { $serials += new-object psobject -Property @{ Name = "DMZ3SingleSite" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $DMZ3SingleSite).1) } - } - if (test-path -Path $DMZ3MultiSite) { $serials += new-object psobject -Property @{ Name = "DMZ3MultiSite" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $DMZ3MultiSite).1) } - } - if (test-path -Path $Workspaces) { $serials += new-object psobject -Property @{ Name = "Workspaces" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $Workspaces).1) } - } - if (test-path -Path $ARM) { $serials += new-object psobject -Property @{ Name = "ARM" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $ARM).1) } - } - if (test-path -Path $PGP) { $serials += new-object psobject -Property @{ Name = "PGP" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $PGP).1) } - } - if (test-path -Path $CIC) { $serials += new-object psobject -Property @{ Name = "CIC" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $CIC).1) } - } - if (test-path -Path $EFT73WTCCAL) { $serials += new-object psobject -Property @{ Name = "EFT73WTCCAL" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT73WTCCAL).1) } - } - if (test-path -Path $EFT73WTCCAL) { $serials += new-object psobject -Property @{ Name = "EFT73WTCCAL" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT73WTCCAL).1) } - } - if (test-path -Path $EFT73SMBFileTransferClient) { $serials += new-object psobject -Property @{ Name = "EFT73SMBFileTransferClient" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT73SMBFileTransferClient).1) } - } - if (test-path -Path $EFT73SMBFolderMonitorEventRule) { $serials += new-object psobject -Property @{ Name = "EFT73SMBFolderMonitorEventRule" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT73SMBFolderMonitorEventRule).1) } - } - if (test-path -Path $EFT73SMBTimerEventModule) { $serials += new-object psobject -Property @{ Name = "EFT73SMBTimerEventModule" ; Serial = [System.Text.Encoding]::ASCII.GetString((Get-ItemProperty -Path $EFT73SMBTimerEventModule).1) } - } - - return $serials -} - -function GenerateHTMLReport ($report){ - $Header = @" - EFT Configuration Report - $($env:computername) - -"@ - - $fragements = "

EFT Node Configuration Report

" - $fragements += "Creation Date : $($report.CreationDate)
" - $fragements += "Computer Name : $($report.ComputerName)
" - - $fragements += $report.SerialKeys | convertto-html -Fragment -PreContent "

Serial Keys

" - - $fragements += "

EFT Node Settings

" - - $fragements += $report.EFTFileVersion | convertto-html -Fragment -As List -PreContent "

EFT File Version

" - $fragements += $report.EFTServices |Select-Object Name, Displayname, StartMode, State, Status, Startname, Pathname | convertto-html -Fragment -PreContent "

EFT Services

" - $fragements += $report.EFTSFTPCOMInterfaceFileVersion | convertto-html -Fragment -As List -PreContent "

EFT SFTPCOMInterface File Version

" - $fragements += $report.EFTSFTPCOMInterfaceObject | convertto-html -Fragment -As List -PreContent "

EFT SFTPCOMInterface Object

" - - $fragements += $report.EFTRegistry | Select-Object -ExcludeProperty PSProvider, PSParentPath | convertto-html -Fragment -as list -PreContent "

EFT Registry

" - $fragements += $report.ServerInfo | convertto-html -Fragment -as list -PreContent "

EFT Server Info

" - $fragements += $report.HotFixes | convertto-html -Fragment -PreContent "

OS HotFixes

" - $fragements += $report.DiskInfo | convertto-html -Fragment -PreContent "

Disk Info

" - $fragements += $report.WindowsServices |Select-Object Name, Displayname, StartMode, State, Status, Startname, Pathname| convertto-html -Fragment -PreContent "

Windows Services

" - convertto-html -Head $Header -body $fragements | Out-File EFT.Report.Node.html ; invoke-item EFT.Report.Node.html -} - - -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' - -$report = new-object psobject -Property @{ - CreationDate = (Get-Date -f $df); - ComputerName = $env:computername; - SerialKeys = $null; - EFTService = $null; - EFTFileVersion = $null; - EFTServices = $null; - EFTSFTPCOMInterfaceFileVersion = $null; - EFTSFTPCOMInterfaceObject = $null; - EFTRegistry = $null; - ServerInfo = $null; - HotFixes = $null; - DiskInfo = $null; - WindowsServices = $null; -} -Write-Progress -Activity "EFT Config" -status "Server Settings" - -$report.SerialKeys = GetSerials - -#Add modified WTC Customized files - -#EFT Node Metadata -Write-Progress -Activity "EFT Node Metadata" -status " EFT Services" -$EftServicePath = Get-WmiObject win32_service | Where-Object { $_.name -Like "EFT*" } | Select-Object pathname -ExpandProperty pathname -$EftServicePath = $EftServicePath -replace """", "" -$EftServiceName = Get-WmiObject win32_service | Where-Object { $_.name -Like "EFT*" } | Select-Object name -ExpandProperty name -$EftServiceType = if ($EftserviceName -like "*Enterprise*") { "EFT Enterprise" } else { "SMB" } -$EftServiceIdentity = Get-WmiObject win32_service | Where-Object { $_.name -Like "EFT*" } | Select-Object startname -ExpandProperty startname -$EftFileVersion = Get-ItemProperty $EftServicePath -name "VersionInfo" | Select-Object VersionInfo -ExpandProperty VersionInfo - -$report.EFTService = new-object psobject -Property @{ EftServicePath = $EftServicePath -join "|"; EftServiceName = $EftServiceName -join "|"; EftServiceType = $EftServiceType; EftServiceIdentity = $EftServiceIdentity -join "|"; } -$report.EFTFileVersion = $EftFileVersion - -$report.EFTServices = Get-WmiObject win32_service | Where-Object { ($_.name -Like "EFT*" ) -or ($_.name -Like "MSMQ*" ) } - -Write-Progress -Activity "EFT Node Metadata" -status " SFTPCOMInterface COM API" -# EFT SFTPCOMInterface COM API -#[EFT SFTPCOMInterface Registered] -$EFTSFTPCOMInterfaceAppID = Get-ItemProperty -Path 'Registry::HKEY_CLASSES_ROOT\AppId\SFTPCOMInterface.dll' | Select-Object AppId -ExpandProperty AppId -$EFTSFTPCOMInterfacePath = Get-ItemProperty -Path 'Registry::HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{A59E7747-3284-435B-8947-4E004361A6AC}\InprocServer32' | Select-Object '(default)' -ExpandProperty '(default)' -$report.EFTSFTPCOMInterfaceFileVersion = Get-ItemProperty $EFTSFTPCOMInterfacePath -name "VersionInfo" | Select-Object VersionInfo -ExpandProperty VersionInfo -$report.EFTSFTPCOMInterfaceObject = new-object psobject -Property @{ EFTSFTPCOMInterfaceAppID = $EFTSFTPCOMInterfaceAppID; EFTSFTPCOMInterfacePath = $EFTSFTPCOMInterfacePath; } - -$RegItems = @() -Write-Progress -Activity "EFT Node Metadata" -status " EFT Registry Settings" -# EFT Registry Settings -$EFTServer30RegLoc = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\EFT Server 3.0' -$EFTServer40RegLoc = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\EFT Server 4.0' -$EFTServer70RegLoc = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\EFT Server 7.0' -$EFTServer71RegLoc = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\EFT Server 7.1' -$EFTServer73RegLoc = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\EFT Server 7.3' -$EFTServer74RegLoc = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\EFT Server 7.4' -$EFTServerEnterpriseRegLoc = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Globalscape Inc.\EFT Server Enterprise' - -if (test-path -Path $EFTServer30RegLoc) { $RegItems += Get-ItemProperty -Path $EFTServer30RegLoc |Select-Object * -ExcludeProperty PSProvider, PSParentPath } -if (test-path -Path $EFTServer40RegLoc) { $RegItems += Get-ItemProperty -Path $EFTServer40RegLoc |Select-Object * -ExcludeProperty PSProvider, PSParentPath} -if (test-path -Path $EFTServer70RegLoc) { $RegItems += Get-ItemProperty -Path $EFTServer70RegLoc |Select-Object * -ExcludeProperty PSProvider, PSParentPath} -if (test-path -Path $EFTServer71RegLoc) { $RegItems += Get-ItemProperty -Path $EFTServer71RegLoc |Select-Object * -ExcludeProperty PSProvider, PSParentPath} -if (test-path -Path $EFTServer73RegLoc) { $RegItems += Get-ItemProperty -Path $EFTServer73RegLoc |Select-Object * -ExcludeProperty PSProvider, PSParentPath} -if (test-path -Path $EFTServer74RegLoc) { $RegItems += Get-ItemProperty -Path $EFTServer74RegLoc |Select-Object * -ExcludeProperty PSProvider, PSParentPath} -if (test-path -Path $EFTServerEnterpriseRegLoc) { $RegItems += Get-ItemProperty -Path $EFTServerEnterpriseRegLoc |Select-Object * -ExcludeProperty PSProvider, PSParentPath} - -$report.EFTRegistry = $RegItems - -Write-Progress -Activity "EFT Node Metadata" -status " Computer Info" -# Computer Info -$report.ServerInfo = Get-ComputerInfo - -Write-Progress -Activity "EFT Node Metadata" -status " HotFixes" -# HotFixes -$report.HotFixes = $report.ServerInfo | Select-Object -ExpandProperty OsHotFixes - -Write-Progress -Activity "EFT Node Metadata" -status " Disk(s) Info " -# Disk(s) Info -$report.DiskInfo = Get-WmiObject -Class Win32_logicaldisk | Select-Object -Property DeviceID, @{L = 'Drive Type'; E = { GetDiskType($_.DriveType) } } , VolumeName, @{L = 'FreeSpace GB'; E = { "{0:N2}" -f ($_.FreeSpace / 1GB) } }, @{L = "Capacity GB"; E = { "{0:N2}" -f ($_.Size / 1GB) } } - -Write-Progress -Activity "EFT Node Metadata" -status " Windows Services" -#Windows Services -$report.WindowsServices = Get-WmiObject win32_service - -# Report output -if (!$FormatToHTML) { - $report -} else { - - GenerateHTMLReport $report -} - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.RestAPI.Invoke.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.RestAPI.Invoke.ps1 deleted file mode 100644 index 1c9f2b1..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.RestAPI.Invoke.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -$hostname = "localhost" -$port = 4450 -$username = "admin" -$password = "Super2003" -$AuthenticationUrl = "http://$($hostname):$port/admin/v1/authentication" -$ServerUrl = "http://$($hostname):$port/admin/v1/server" -$response = "" - -try { -$response = Invoke-WebRequest -Method POST -Uri $AuthenticationUrl -Body "{""userName"": ""$($username)"", ""password"": ""$($password)"", ""authType"": ""EFT""}" -} -catch { - Write-Error "[!!!] Connection to $($AuthenticationUrl) Failed! $($_.Exception.Message)" - Exit -} - -$AuthContent = $response.Content | ConvertFrom-Json - -Write-Host "Auth Token: $($AuthContent.AuthToken)" - -try { - $response = Invoke-WebRequest -Method GET -Uri $ServerUrl -Headers @{"Authorization" = "EFTAdminAuthToken $($AuthContent.AuthToken)"} - } - catch { - Write-Error "[!!!] Connection to $($ServerUrl) Failed! $($_.Exception.Message)" - Exit - } - Write-Host "Response " - Write-Host "$($response.Content)" \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SQLQuery.Export.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SQLQuery.Export.ps1 deleted file mode 100644 index ed4e9e0..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SQLQuery.Export.ps1 +++ /dev/null @@ -1,46 +0,0 @@ -[CmdletBinding()] -param( - [Parameter(Mandatory = $true, HelpMessage = "SQL Instance")] - [String]$dataSource ="GS", - [Parameter(Mandatory = $true, HelpMessage = "SQL Database")] - [String]$database, - [Parameter(Mandatory = $false, HelpMessage = "SQL Connection String (Optional connection string)")] - [String]$connectionString, - [Parameter(Mandatory = $false, HelpMessage = "SQL User Name (Optional)")] - [String]$userName, - [Parameter(Mandatory = $false, HelpMessage = "SQL Password (Optional)")] - [String]$password, - [Parameter(Mandatory = $true, HelpMessage = "SQL Query")] - [String]$query -) - -## Create connection string - -$cnxString = "Data Source=$dataSource; " + "Initial Catalog=$database" + "; Integrated Security=SSPI" - -if ($userName -ne $null -and $userName.Length -gt 0) { - $cnxString += "; User ID=$userName; Password=$password" -} - -if ($connectionString -ne $null -and $connectionString.Length -gt 0) { - $cnxString = $connectionString -} - -## Open connection to SQL. -$connection = new-object system.data.SqlClient.SQLConnection($cnxString) -$command = new-object system.data.sqlclient.sqlcommand($query, $connection) -$connection.Open() - -$reader = $command.ExecuteReader() - -$results = @() -while ($reader.Read()) { - $row = @{} - for ($i = 0; $i -lt $reader.FieldCount; $i++) { - $row[$reader.GetName($i)] = $reader.GetValue($i) - } - $results += new-object psobject -property $row -} -$connection.Close() - -$results \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Server.Backup.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Server.Backup.ps1 deleted file mode 100644 index ff0ec16..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Server.Backup.ps1 +++ /dev/null @@ -1,126 +0,0 @@ -## -## 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 = 0, Mandatory = $False, HelpMessage = "Enter the file where the EFT configuration will be backup")] - [String] $EFTBackupFile = "", - - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, 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 = 4, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 10, Mandatory = $False )] - [switch]$Quiet = $false -) -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path) - - -Write-host "******* EFT Backup SCRIPT 1.0 *************************************************" -ForegroundColor Yellow -if ($Quiet -eq $false) { - Write-host " WARNING NOTES:" -ForegroundColor Yellow - Write-host " EFT backup can be a several minutes or hours time to complete:" -ForegroundColor Yellow - Write-host " > Test by running this script first against to a non-production environment " -ForegroundColor Yellow - Write-host " > Inform other EFT Admins that a backup will be in progress and some perfromance on the UI can be degradate" -ForegroundColor Yellow - Write-host " > Communicate end users about the process" -ForegroundColor Yellow - Write-host "******************************************************************************" -ForegroundColor Yellow -} -$adminPrivileges = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") - -# Constants -$MAX_PAD = 100 -$PAD_CHR = "." -$EFTServer = $null -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' - -$MXE_BACKUP_NOT_FOUND = "MX Error: 66 (00000042)" -$MXE_BACKUP_INVALID_CREDENTIALS = "MX Error: 67 (00000043)" - - -$EFTServer = new-object -ComObject SFTPCOMInterface.CIServer - -$EftService = Get-Service "EFT *" -$CurrentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name -if ($EFTBackupAuthType -eq 1) { - $EFTBackupAdminUsername = $CurrentUserName -} -if ($EFTAdminAuthType -eq 1) { - $EFTAdminUsername = $CurrentUserName -} - -Write-Host "Current datetime : $(Get-Date -f $df)" -Write-Host "Current User : $CurrentUserName" -Write-Host "Admin Privileges : $adminPrivileges" -Write-host "EFT Server Service : " -NoNewline - -$OriginalEFTServiceState = $EftService.Status -if ($EftService.Status -eq "Running") {Write-host "$($OriginalEFTServiceState)" -ForegroundColor Green} else { - Write-host "$($OriginalEFTServiceState)" -ForegroundColor Red - exit -} -Write-host "" - -if ($Quiet -eq $false) { - $continue = Read-Host -Prompt "Have you read and understand the warning notes (y/n)?" - if ($continue.ToUpper() -ne "Y") { - exit - } -} - -if ($EFTBackupFile -eq "") { - $timestamp = $(Get-date -f 'yyyy_MM_dd-hh_mm_ss') - $EFTBackupFile = "$here\EFT_Backup_$timestamp.bak" -} -$EFTBackupFileName = Split-Path $EFTBackupFile -Leaf -$EFTBackupFilePath = Split-Path $EFTBackupFile -parent - -if ($EFTBackupFilePath -eq "") { - $EFTBackupFilePath = "$here" -} -$EFTBackupFullPath = Join-Path $here $EFTBackupFileName -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -try { - Write-host "Creating Backup '$EFTBackupFileName'".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $EFTServer.BackupServerConfiguration($EFTBackupFullPath) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - Write-host "Backup saved: $EFTBackupFullPath" -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_BACKUP_NOT_FOUND { Write-host "MXE_BACKUP_NOT_FOUND : $_ " -ForegroundColor Red } - $MXE_BACKUP_INVALID_CREDENTIALS { Write-host "MXE_BACKUP_INVALID_CREDENTIALS : $_ " -ForegroundColor Red } - Default { Write-host "Exception : $_" -ForegroundColor Red} - } - exit -} \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Server.Get-SiteStats.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Server.Get-SiteStats.ps1 deleted file mode 100644 index 97bd97a..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Server.Get-SiteStats.ps1 +++ /dev/null @@ -1,98 +0,0 @@ -## -## 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 = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False, HelpMessage = "Validate Physical Path ")] - [switch] $ValidatePath = $false -) -$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) - if ($script:EftSite.IsStarted) {$status = "Started"} else {$status = "Stopped"} - try {$siteguid = $script:EftSite.GUID} catch {} - $starttime = $script:EftSite.GetStartTime() - $ActiveSessions = $script:EftSite.GetConnectedCount(); - $UsersDefined = $script:EftSite.UsersDefined; - $ActiveUploads = $script:EftSite.GetUploadCount(); - $ActiveDownloads = $script:EftSite.GetDownloadCount(); - $AverageSpeed = $script:EftSite.AverageSpeed; - - try {$WTCSessionsRemaining = $script:EftSite.WTCSessionsRemaining } catch {} - try {$WTCSessionsActive = $script:EftSite.WTCSessionsActive } catch {} - try {$WSSeatsUsed = $script:EftSite.WSSeatsUsed } catch {} - try {$WSSeatsRemaining = $script:EftSite.WSSeatsRemaining } catch {} - - $results += new-object psobject -Property @{ - SiteName = $script:EftSite.Name; - ID = $script:EftSite.Id; - Guid = $siteguid; - StartedOn = $starttime; - Status = $status; - ActiveSessions = $ActiveSessions; - UsersDefined = $UsersDefined; - WTCSessionsRemaining = $WTCSessionsRemaining; - WTCSessionsActive = $WTCSessionsActive; - WSSeatsUsed = $WSSeatsUsed - WSSeatsRemaining = $WSSeatsRemaining - ActiveUploads = $ActiveUploads; - ActiveDownloads = $ActiveDownloads; - AverageSpeed = $AverageSpeed; - } -} -$results | Sort-Object SiteName, VirtualFolder - -$script:EftServer.close() - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Server.Restore.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Server.Restore.ps1 deleted file mode 100644 index 8f2861f..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Server.Restore.ps1 +++ /dev/null @@ -1,336 +0,0 @@ -## -## 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 = 0, Mandatory = $True, HelpMessage = "Enter the Backup file that will be restored")] - [String] $EFTBackupFile = "", - - [Parameter(Position = 1, Mandatory = $false, HelpMessage = "Enter the Backup paramaters Csv file to be use during the restore process")] - [string] $EFTBackupParamsCsvFile = "", - - [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 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False, HelpMessage = "Enter a Authentication Type for the EFT backup . 0: EFT Login, 1: Windows Login, 2: Network Logon")] - [int] [ValidateSet(0, 1, 2)] $EFTBackupAuthType = 1, - - [Parameter(Position = 8, Mandatory = $False, HelpMessage = "Enter login for the backup")] - [String] $EFTBackupAdminUsername = "", - - [Parameter(Position = 9, Mandatory = $False, HelpMessage = "Enter password for the backup")] - [String] $BackupPassword, - - [Parameter(Position = 10, Mandatory = $False )] - [switch]$Quiet = $false -) - -if ($EFTBackupParamsCsvFile -eq "") { - # Uncomment the following to enter paramters for each site - # Leaving empty values will cause to ignore the new values - # Properties: SiteName, RestoreSite, NewListenIPs, AuthManagerDataBase, RestoreVFS, RootFolder, DMZEnabled, DMZAddress, DMZPort - $EFTBackupParams = @( - # @{ SiteName = "MySite"; RootFolder = ""; } - # @{ SiteName = "MySite1"; RootFolder = ""; } - ) -} -else { - $EFTBackupParams = Import-Csv $EFTBackupParamsCsvFile - # SiteName, RestoreSite, NewListenIPs, AuthManagerDataBase, RestoreVFS, RootFolder, DMZEnabled, DMZAddress, DMZPort -} -function Get-FriendlySize { - param($Bytes) - $sizes = 'Bytes,KB,MB,GB,TB,PB,EB,ZB' -split ',' - for ($i = 0; ($Bytes -ge 1kb) -and - ($i -lt $sizes.Count); $i++) {$Bytes /= 1kb} - $N = 2; if ($i -eq 0) {$N = 0} - "{0:N$($N)} {1}" -f $Bytes, $sizes[$i] -} - -Write-host "******* EFT Restore SCRIPT 1.0 *************************************************" -ForegroundColor Yellow -if ($Quiet -eq $false) { - - Write-host " WARNING NOTES:" -ForegroundColor Yellow - Write-host " Restoring EFT from a backup will cause DOWNTIME of your EFT service, it is recommended:" -ForegroundColor Yellow - Write-host " > Test the backup file by running this script first against to a non-production environment " -ForegroundColor Yellow - Write-host " > Drain connections and file transfer to avoid possible user data integrity issues" -ForegroundColor Yellow - Write-host " > Communicate end users about the outage" -ForegroundColor Yellow - Write-host "******************************************************************************" -ForegroundColor Yellow -} - -$adminPrivileges = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") - -# Constants -$MAX_PAD = 100 -$PAD_CHR = "." -$EFTServer = $null -$archiveInfo = $null -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' - -$MXE_BACKUP_NOT_FOUND = "MX Error: 66 (00000042)" -$MXE_BACKUP_INVALID_CREDENTIALS = "MX Error: 67 (00000043)" -$MXE_SERVER_RESTORATION_FAILED = "MX Error: 74 (0000004A)" -$MXE_BACKUP_NOT_COMPATIBLE = "MX Error: 122 (0000007A)" - -$EFTBackupFileFullPath = Convert-Path $EFTBackupFile -$EFTBackupFileItem = Get-Item $EFTBackupFileFullPath - -# Check if the Service is Started -$EFTServer = new-object -ComObject SFTPCOMInterface.CIServer - -$EftService = Get-Service "EFT *" -$CurrentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name -if ($EFTBackupAuthType -eq 1) { - $EFTBackupAdminUsername = $CurrentUserName -} -if ($EFTAdminAuthType -eq 1) { - $EFTAdminUsername = $CurrentUserName -} - -$OriginalEFTServiceState = $EftService.Status - -if ($OriginalEFTServiceState -eq "Stopping") { - try { - $sw.Restart() - Write-host "Waiting EFT Service to be Stopped ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $EftService.WaitForStatus("Stopped", '00:00:30') - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - catch { - Write-host " TIMEOUT ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } -} - -Write-Host "Current datetime : $(Get-Date -f $df)" -Write-Host "Current User : $CurrentUserName" -Write-Host "Admin Privileges : $adminPrivileges" -Write-host "EFT Server Service : " -NoNewline - -$OriginalEFTServiceState = $EftService.Status -if ($EftService.Status -eq "Running") {Write-host "$($OriginalEFTServiceState)" -ForegroundColor Green} else {Write-host "$($OriginalEFTServiceState)" -ForegroundColor Red} -Write-host "Backup administrator type : $EFTBackupAuthType" -Write-host "Backup administrator login : $EFTBackupAdminUsername" -Write-host "Backup File Name : $EFTBackupFile" -Write-host "Backup File Size : $(Get-FriendlySize $EFTBackupFileItem.Length )" -Write-host "Backup File Created On : $($EFTBackupFileItem.CreationTime) " -Write-host "Backup File Modify On : $($EFTBackupFileItem.LastWriteTime)" -Write-host "EFT Backup Params Csv File : $EFTBackupParamsCsvFile" -Write-host "" - -if ($Quiet -eq $false) { - $continue = Read-Host -Prompt "Have you read and understand the warning notes (y/n)?" - if ($continue.ToUpper() -ne "Y") { - exit - } -} -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - - -$EFTLogPath = $EFTServer.LogPath -$EFTConfigurationFilePath = $EFTServer.ConfigurationFilePath -try { - Write-host "Loading backup archive. Please wait this might take several minutes".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $archiveInfo = $EFTServer.GetBackupArchiveInfo($EFTBackupFileFullPath, $EFTBackupAuthType, $EFTBackupAdminUsername, $BackupPassword) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_BACKUP_NOT_FOUND { Write-host "MXE_BACKUP_NOT_FOUND : $_ " -ForegroundColor Red } - $MXE_BACKUP_INVALID_CREDENTIALS { Write-host "MXE_BACKUP_INVALID_CREDENTIALS : $_ " -ForegroundColor Red } - Default { Write-host "Exception : $_" -ForegroundColor Red} - } - exit -} - - -Write-host "" -Write-host "EFT Server Backup Details" -Write-host "BackupArchivePath : $($archiveInfo.BackupArchivePath)" -Write-host "Date Created : $($archiveInfo.CreationTime)" -Write-host "Created By : $($archiveInfo.CreatedBy)" -Write-host "Backup Type : $($archiveInfo.type)" -Write-host "Total Sites : $($archiveInfo.SitesCount)" - - -$siteCount = $archiveInfo.SitesCount -$SiteInfo = @() - -for ($i = 0 ; $i -lt $siteCount ; $i++) { - $siteBackupInfo = $archiveInfo.GetSiteBackupInfo($i) - $EFTBackupParam = $null - $backupParamFound = $false - for ($j = 0; $j -le $EFTBackupParams.Count - 1; $j++) { - $EFTBackupParam = $EFTBackupParams[$j] - if ($siteBackupInfo.SiteName -eq $EFTBackupParam.SiteName ) { - $backupParamFound = $true - break - } - } - # Assigning New paramaters to the BackupInfo - if ($backupParamFound) { - if ([string]::IsNullOrEmpty($EFTBackupParam["NewListenIPs"]) -ne $true) {$siteBackupInfo.NewListenIPs = $EFTBackupParam["NewListenIPs"]} - if ([string]::IsNullOrEmpty($EFTBackupParam["RestoreSite"]) -ne $true) {$siteBackupInfo.RestoreSite = $EFTBackupParam["RestoreSite"]} - if ([string]::IsNullOrEmpty($EFTBackupParam["AuthManagerDataBase"]) -ne $true) {$siteBackupInfo.AuthManagerDataBase = $EFTBackupParam["AuthManagerDataBase"]} - if ([string]::IsNullOrEmpty($EFTBackupParam["RestoreVFS"]) -ne $true) {$siteBackupInfo.RestoreVFS = $EFTBackupParam["RestoreVFS"]} - if ([string]::IsNullOrEmpty($EFTBackupParam["RootFolder"]) -ne $true) {$siteBackupInfo.RootFolder = $EFTBackupParam["RootFolder"]} - if ([string]::IsNullOrEmpty($EFTBackupParam["DMZEnabled"]) -ne $true) {$siteBackupInfo.DMZEnabled = $EFTBackupParam["DMZEnabled"]} - if ([string]::IsNullOrEmpty($EFTBackupParam["DMZAddress"]) -ne $true) {$siteBackupInfo.DMZAddress = $EFTBackupParam["DMZAddress"]} - if ([string]::IsNullOrEmpty($EFTBackupParam["DMZPort"]) -ne $true) { $siteBackupInfo.DMZPort = $EFTBackupParam["DMZPort"]} - } - - $SiteInfo += new-object psobject -Property @{ - SiteName = $siteBackupInfo.SiteName; - RestoreSite = $siteBackupInfo.RestoreSite; - ListenIPs = $siteBackupInfo.ListenIPs; - NewListenIPs = $siteBackupInfo.NewListenIPs; - AuthManagerDataBase = $siteBackupInfo.AuthManagerDataBase; - AuthManagerID = $siteBackupInfo.AuthManagerID; - RestoreVFS = $siteBackupInfo.RestoreVFS; - RootFolder = $siteBackupInfo.RootFolder; - DMZEnabled = $siteBackupInfo.DMZEnabled; - DMZAddress = $siteBackupInfo.DMZAddress; - DMZPort = $siteBackupInfo.DMZPort; - } - $archiveInfo.SetSiteBackupInfo($siteBackupInfo) -} -$SiteInfo | Format-Table RestoreSite, SiteName, ListenIPs, NewListenIPs -$SiteInfo | Format-Table SiteName, AuthManagerID, AuthManagerDataBase -$SiteInfo | Format-Table SiteName, RestoreVFS, RootFolder -$SiteInfo | Format-Table SiteName, DMZEnabled, DMZAddress, DMZPort - -Write-host "EnableARM : $($archiveInfo.EnableARM)" -Write-host "ARMServerName : $($archiveInfo.ARMServerName)" -Write-host "ARMUserName : $($archiveInfo.ARMUserName)" -Write-host "ARMAuthenticationType : $($archiveInfo.ARMAuthenticationType)" -Write-host "ARMDatabaseName : $($archiveInfo.ARMDatabaseName)" -Write-host "ARMDatabaseType : $($archiveInfo.ARMDatabaseType)" -Write-host "ARMFailureAuditFolder : $($archiveInfo.ARMFailureAuditFolder)" -Write-host "ARMFailureEmailList : $($archiveInfo.ARMFailureEmailList)" -Write-host "ARMHealConnection : $($archiveInfo.ARMHealConnection)" -Write-host "ARMNotifyOnDisconnect : $($archiveInfo.ARMNotifyOnDisconnect)" -Write-host "ARMNotifyOnReconnect : $($archiveInfo.ARMNotifyOnReconnect)" -#Write-host "ARMPassword : $($archiveInfo.ARMPassword)" -Write-host "ARMReconnectPeriod : $($archiveInfo.ARMReconnectPeriod)" -Write-host "ARMStopAuditingOnError : $($archiveInfo.ARMStopAuditingOnError)" - - -#SiteName, AuthManagerDataBase, DMZAddress, DMZEnabled, DMZPort, ListenIPs, NewListenIPs, RestoreSite, RestoreVFS, RootFolder -#SetSiteBackupInfo : $EFTBackupArchiveInfo.SetSiteBackupInfo -Write-host "" - -if ($Quiet -eq $false) { - Write-host "The script is ready to perform the restore process. " -ForegroundColor Yellow - Write-host "The restore process will cause the EFT Service to be stopped and start causing *DONWTIME*" -ForegroundColor Yellow - $continue = Read-Host -Prompt "Are you sure you want to continue wtih the Restore (y/n)?" - if ($continue.ToUpper() -ne "Y") { - exit - } -} -try { - Write-host "Restoring $EFTBackupFile".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $EFTServer.RestoreServerConfigurationEx($archiveInfo) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_SERVER_RESTORATION_FAILED { Write-host "MXE_SERVER_RESTORATION_FAILED : $_ " -ForegroundColor Red } - $MXE_BACKUP_NOT_COMPATIBLE { Write-host "MXE_BACKUP_NOT_COMPATIBLE : $_ " -ForegroundColor Red} - Default { Write-host "Exception : $_" -ForegroundColor Red} - } - exit -} - -## Start Service if is not Started -if ($adminPrivileges) { - $EftService = get-service "EFT*" - if ($EftService.Status -eq "Running") { - Write-host "Stopping EFT Service ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $EftService.Stop() - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - - $EftService = get-service "EFT*" - if ($EftService.Status -eq "StopPending") { - try { - $sw.Restart() - Write-host "Waiting EFT Service to be Stopped ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $EftService.WaitForStatus("Stopped", '00:00:30') - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - catch { - Write-host " TIMEOUT ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - Exit - } - } - $EftService = get-service "EFT*" - Write-host "Starting EFT Service ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $EftService.Start() - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - $EftService = get-service "EFT*" - if ($EftService.Status -eq "StartPending") { - try { - $sw.Restart() - Write-host "Waiting EFT Service to be Started ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $EftService.WaitForStatus("Running", '00:00:30') - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - catch { - Write-host " TIMEOUT ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - } -} -Write-host "" -Write-host "Restore Process Completed" -Write-host "EFT Server Service : " -NoNewline -$EftService = get-service "EFT*" -if ($EftService.Status -eq "Running") {Write-host "$($EftService.Status)" -ForegroundColor Green} else {Write-host "$($EftService.Status)" -ForegroundColor Red} - -$TimeStamp = $(Get-Date -f "yyyy.MM.dd_hh.mm.ss") -$RestorationLog = "logs\Restoration_$TimeStamp.log" -$EFTLog = "logs\EFT_$TimeStamp.log" - -$scriptlogPath = "logs" -If ( (Test-Path $scriptlogPath) -eq $false) { - Write-Verbose "Creating $scriptlogPath" - new-item $scriptlogPath -ItemType directory -} -Copy-Item -Path "$($EFTLogPath)last_restoration.log" -Destination $RestorationLog -Copy-Item -Path "$($EFTConfigurationFilePath)\EFT.log" -Destination $EFTLog - -Write-host "EFT Restore Log Path : $($RestorationLog)" -Write-host "EFT Log Path : $($EFTLog)" diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Server.Start-Site.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Server.Start-Site.ps1 deleted file mode 100644 index 7122480..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Server.Start-Site.ps1 +++ /dev/null @@ -1,122 +0,0 @@ -## -## 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 = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 10, Mandatory = $False )] - [switch]$Quiet = $false -) - -Write-host "******* EFT Start Sites SCRIPT 1.0 *************************************************" -ForegroundColor Yellow -if ($Quiet -eq $false) { - Write-host " WARNING NOTES:" -ForegroundColor Yellow - Write-host " > Starting an EFT site will cause EFT server to:" -ForegroundColor Yellow - Write-host " > Start listening on IP Inerfaces for protocols on inbound connections" -ForegroundColor Yellow - Write-host " > Trigger Event rules, process automation (if any) and perform outbound file transfers " -ForegroundColor Yellow - Write-host " > Test by running this script first against to a non-production environment " -ForegroundColor Yellow - Write-host " > Inform other EFT Admins that a site will be started " -ForegroundColor Yellow - Write-host "******************************************************************************" -ForegroundColor Yellow -} -$adminPrivileges = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") - -# Constants -$MAX_PAD = 100 -$PAD_CHR = "." -$EFTServer = $null -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' - -$EFTServer = new-object -ComObject SFTPCOMInterface.CIServer - -$EftService = Get-Service "EFT *" -$CurrentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name - -if ($EFTAdminAuthType -eq 1) { - $EFTAdminUsername = $CurrentUserName -} - -Write-Host "Current datetime : $(Get-Date -f $df)" -Write-Host "Current User : $CurrentUserName" -Write-Host "Admin Privileges : $adminPrivileges" -Write-host "EFT Server Service : " -NoNewline - -$OriginalEFTServiceState = $EftService.Status -if ($EftService.Status -eq "Running") {Write-host "$($OriginalEFTServiceState)" -ForegroundColor Green} else { - Write-host "$($OriginalEFTServiceState)" -ForegroundColor Red - exit -} -Write-host "" - -if ($Quiet -eq $false) { - $continue = Read-Host -Prompt "Have you read and understand the warning notes (y/n)?" - if ($continue.ToUpper() -ne "Y") { - exit - } -} - -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() - -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 - } - } - - try { - if ($script:EftSite.IsStarted) { $currentState = "Started"; $color = "Green" } else {$currentState = "Stopped" ; $color = "Red"} - Write-host "$SiteName ".PadRight(25," ") -NoNewline - Write-host "$currentState" -ForegroundColor $color -NoNewline - $sw.Restart() - if ($script:EftSite.IsStarted -eq $false) { - Write-host " Starting site... " -NoNewline - $script:EftSite.Start() - Write-host "Started" -ForegroundColor Green -NoNewline - } - Write-host " ($($sw.ElapsedMilliseconds)ms)" - } - catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit - } -} diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Server.Stop-Site.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Server.Stop-Site.ps1 deleted file mode 100644 index 2fdc25d..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Server.Stop-Site.ps1 +++ /dev/null @@ -1,123 +0,0 @@ -## -## 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 = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 10, Mandatory = $False )] - [switch]$Quiet = $false -) - -Write-host "******* EFT Stop Sites SCRIPT 1.0 *************************************************" -ForegroundColor Yellow -if ($Quiet -eq $false) { - Write-host " WARNING NOTES:" -ForegroundColor Yellow - Write-host " > Stopping an EFT site will cause EFT server site to:" -ForegroundColor Yellow - Write-host " > Stop listening on IP Inerfaces for protocols on inbound connections" -ForegroundColor Yellow - Write-host " > Stop Event rules to trigger or process Automation and outbound transfers " -ForegroundColor Yellow - Write-host " > Test by running this script first against to a non-production environment " -ForegroundColor Yellow - Write-host " > Inform other EFT Admins that a site will be stopped or started " -ForegroundColor Yellow - Write-host " > Communicate end users about the process" -ForegroundColor Yellow - Write-host "******************************************************************************" -ForegroundColor Yellow -} -$adminPrivileges = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") - -# Constants -$MAX_PAD = 100 -$PAD_CHR = "." -$EFTServer = $null -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' - -$EFTServer = new-object -ComObject SFTPCOMInterface.CIServer - -$EftService = Get-Service "EFT *" -$CurrentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name - -if ($EFTAdminAuthType -eq 1) { - $EFTAdminUsername = $CurrentUserName -} - -Write-Host "Current datetime : $(Get-Date -f $df)" -Write-Host "Current User : $CurrentUserName" -Write-Host "Admin Privileges : $adminPrivileges" -Write-host "EFT Server Service : " -NoNewline - -$OriginalEFTServiceState = $EftService.Status -if ($EftService.Status -eq "Running") {Write-host "$($OriginalEFTServiceState)" -ForegroundColor Green} else { - Write-host "$($OriginalEFTServiceState)" -ForegroundColor Red - exit -} -Write-host "" - -if ($Quiet -eq $false) { - $continue = Read-Host -Prompt "Have you read and understand the warning notes (y/n)?" - if ($continue.ToUpper() -ne "Y") { - exit - } -} - -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() - -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 - } - } - - try { - if ($script:EftSite.IsStarted) { $currentState = "Started"; $color = "Green" } else {$currentState = "Stopped" ; $color = "Red"} - Write-host "$SiteName ".PadRight(25," ") -NoNewline - Write-host "$currentState" -ForegroundColor $color -NoNewline - $sw.Restart() - if ($script:EftSite.IsStarted -eq $true) { - Write-host " Stopping site... " -NoNewline - $script:EftSite.Stop() - Write-host "Stopped" -ForegroundColor red -NoNewline - } - Write-host " ($($sw.ElapsedMilliseconds)ms)" - } - catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit - } -} diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SettingsTemplates.BulkAdd.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SettingsTemplates.BulkAdd.ps1 deleted file mode 100644 index fdc816d..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SettingsTemplates.BulkAdd.ps1 +++ /dev/null @@ -1,86 +0,0 @@ -## -## 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 = 1, Mandatory = $true, HelpMessage = "Enter login")] - [int] $NumTemplates = 10, - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [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 -) - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null -$sw = [Diagnostics.Stopwatch]::StartNew() - -$script:EftServer = new-object -ComObject "SFTPCOMInterface.CIServer" - -try { - $script:EftServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) -} -catch [System.Runtime.InteropServices.COMException] { - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() -$siteFound = $false -for ($j = 0; $j -le $sitesCount - 1; $j++ ) { - $script:EftSite = $script:EftSites.Item($j) - if ($EFTSiteName -eq $script:EftSite.Name) { - $siteFound = $true - break - } -} - -if (!$siteFound){ - write-host "Site $EFTSiteName Not found" - exit -} -try { - $sw.Restart() - $script:EftServer.AutoSave = $false -} -catch [System.Runtime.InteropServices.COMException] { - Write-Host "ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor red - Write-host "Exception : $_" -ForegroundColor Red -} - -for ($i= 0 ; $i -le $NumTemplates;$i++ ) { - try{ - $settingsTemplateName = "test_$i" - Write-Host "Adding '$settingsTemplateName' ... " -NoNewline - $sw.Restart() - $script:EftSite.CreateSettingsLevel($settingsTemplateName,"test",$false) - Write-Host "OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor green - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor red - Write-host "Exception : $_" -ForegroundColor Red - } -} diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SettingsTemplates.BulkRemove.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SettingsTemplates.BulkRemove.ps1 deleted file mode 100644 index c708884..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SettingsTemplates.BulkRemove.ps1 +++ /dev/null @@ -1,76 +0,0 @@ -## -## 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 = 1, Mandatory = $true, HelpMessage = "Enter login")] - [String] $SiteName = "", - - [Parameter(Position = 2, Mandatory = $true, HelpMessage = "Enter login")] - [int] $NumTemplates = 10, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 4, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [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 -) - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null -$sw = [Diagnostics.Stopwatch]::StartNew() - -$script:EftServer = new-object -ComObject "SFTPCOMInterface.CIServer" - -try { - $script:EftServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) -} -catch [System.Runtime.InteropServices.COMException] { - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() -$siteFound = $false -for ($j = 0; $j -le $sitesCount - 1; $j++ ) { - $script:EftSite = $script:EftSites.Item($j) - if ($Sitename -eq $script:EftSite.Name) { - $siteFound = $true - break - } -} - -if (!$siteFound){ - write-host "Site $Sitename Not found" - exit -} - -for ($i= 0 ; $i -le $NumTemplates;$i++ ) { - try{ - $settingsTemplateName = "test_$i" - Write-Host "Removing '$settingsTemplateName' ... " -NoNewline - $sw.Restart() - $script:EftSite.RemoveSettingsLevel($settingsTemplateName) - Write-Host "OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor green - } - catch [System.Runtime.InteropServices.COMException] { - Write-Host "ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor red - Write-host "Exception : $_" -ForegroundColor Red - } -} diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Site.ChangeStorageWizard.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Site.ChangeStorageWizard.ps1 deleted file mode 100644 index f476289..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Site.ChangeStorageWizard.ps1 +++ /dev/null @@ -1,342 +0,0 @@ -## -## 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 = 0, Mandatory = $true, HelpMessage = "Enter the name of the Site")] - [String] $EFTSiteName = "", - - [Parameter(Position = 1, Mandatory = $true, HelpMessage = "Enter the new site root path")] - [String] $NewSiteRoot = "", - - [Parameter(Position = 2, Mandatory = $true, HelpMessage = "Enter the folder permissions CSV file")] - [String] $FolderPermissionsCsv = "", - - [Parameter(Position = 3, Mandatory = $true, HelpMessage = "Enter the virtual folder CSV file")] - [String] $VirtualFolderCsv = "", - - [Parameter(Position = 4, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 6, 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 = 7, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 8, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 9, Mandatory = $False )] - [switch]$Quiet = $false -) -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path) - -Write-host "******* EFT Change storage Wizard 1.0 *************************************************" -ForegroundColor Yellow -Write-host " > This wizard will guide you to perform operations that will change a new EFT site root folder" -ForegroundColor Yellow -Write-host " > This script can also copy your files to the new site root" -ForegroundColor Yellow -Write-host " > It is recommend you test this script in a non-production environment before " -ForegroundColor Yellow -Write-host " using in production to validate its functionality" -ForegroundColor Yellow -Write-host "******************************************************************************" -ForegroundColor Yellow - -$CurrentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name -if ($EFTAdminAuthType -eq 1) { - $EFTAdminUsername = $CurrentUserName -} -$EftService = Get-Service "EFT *" -$adminPrivileges = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' -$transactionId = [guid]::NewGuid() -Replace "-", "" -#Output parameters -Write-Host "Current datetime : $(Get-Date -f $df)" -Write-Host "Current User : $CurrentUserName" -Write-Host "Admin Privileges : $adminPrivileges" -Write-host "EFT Server Service : " -NoNewline -$OriginalEFTServiceState = $EftService.Status -if ($EftService.Status -eq "Running") {Write-host "$($OriginalEFTServiceState)" -ForegroundColor Green} else {Write-host "$($OriginalEFTServiceState)" -ForegroundColor Red} -Write-host "TransactionId : $transactionId" -Write-host "New Site Root : $NewSiteRoot" -Write-host "Folder Permissions CSV File : $FolderPermissionsCsv" -Write-host "Virtual Folders CSV file : $VirtualFolderCsv" -Write-host "EFT Admin Hostname : $EFTAdminHostname" -Write-host "EFT Admin Port : $EFTAdminPort" -Write-host "EFT Site Name : $EFTSiteName" -Write-host "EFT Admin Auth Type : $EFTAdminAuthType" -Write-host "EFT Admin Username : $EFTAdminUsername" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path) - -if ($Quiet -eq $false) { - $continue = Read-Host -Prompt "Have you read and understand the notes (y/n)?" - if ($continue.ToUpper() -ne "Y") { - exit - } -} - -# Constants -$MAX_PAD = 100 -$PAD_CHR = "." -$EFTServer = $null -$EFTSites = $null -$EFTSite = $null - -# Validations -if ($OutputFolder -notmatch '.+?\\$') { - $OutputFolder += '\' -} - -$transactionFolder = Join-Path $here $transactionId -New-Item -ItemType "directory" -path "$transactionFolder" |Out-Null -Write-host "Transaction folder : $transactionFolder" - -$OutputFolder = Convert-Path $OutputFolder -Write-host "Pre-Validations:" -$FolderPermissionsImportScript = ".\EFT.FolderPermissions.Import.ps1" -$VirtualFoldersRemapScript = ".\EFT.VirtualFolders.Remap.ps1" -$StartSiteScript = ".\EFT.Server.Start-Site.ps1" -$StopSiteScript = ".\EFT.Server.Stop-Site.ps1" -$UtilsRoboCopyScript = ".\Utils.RoboCopy.ps1" - -write-host "Checking $FolderPermissionsImportScript".PadRight($MAX_PAD, $PAD_CHR) -NoNewline -if (!(test-path $FolderPermissionsImportScript)) { write-host " FAILED" -ForegroundColor red; exit } else {write-host " PASSED" -ForegroundColor green} - -write-host "Checking $VirtualFoldersRemapScript".PadRight($MAX_PAD, $PAD_CHR) -NoNewline -if (!(test-path $VirtualFoldersRemapScript)) { write-host " FAILED" -ForegroundColor red; exit } else {write-host " PASSED" -ForegroundColor green} - -write-host "Checking $StartSiteScript".PadRight($MAX_PAD, $PAD_CHR) -NoNewline -if (!(test-path $StartSiteScript)) { write-host " FAILED" -ForegroundColor red; exit } else {write-host " PASSED" -ForegroundColor green} - -write-host "Checking $StopSiteScript".PadRight($MAX_PAD, $PAD_CHR) -NoNewline -if (!(test-path $StopSiteScript)) { write-host " FAILED" -ForegroundColor red; exit } else {write-host " PASSED" -ForegroundColor green} - -write-host "Checking $UtilsRoboCopyScript".PadRight($MAX_PAD, $PAD_CHR) -NoNewline -if (!(test-path $UtilsRoboCopyScript)) { write-host " FAILED" -ForegroundColor red; exit } else {write-host " PASSED" -ForegroundColor green} - -write-host "Checking $FolderPermissionsCsv".PadRight($MAX_PAD, $PAD_CHR) -NoNewline -if (!(test-path $FolderPermissionsCsv)) { write-host " FAILED" -ForegroundColor red; exit } else {write-host " PASSED" -ForegroundColor green} - -write-host "Checking $VirtualFolderCsv".PadRight($MAX_PAD, $PAD_CHR) -NoNewline -if (!(test-path $VirtualFolderCsv)) { write-host " FAILED" -ForegroundColor red; exit } else {write-host " PASSED" -ForegroundColor green} - - - -$EFTServer = new-object -ComObject "SFTPCOMInterface.CIServer" - -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() - -for ($j = 0; $j -le $sitesCount - 1; $j++ ) { - - $script:EftSite = $script:EftSites.Item($j) - $SiteGuid = $null - $siteName = $script:EftSite.Name - try { - $SiteGuid = $script:EftSite.GUID - } - catch [System.Runtime.InteropServices.COMException] { - Write-Verbose "Can't get GUID for Site $siteName" - } - - if ($EFTSiteName -ne "") { - if ( $EFTSiteName -ne $siteName) { - continue - } - } - $originalSiteRoot = $script:EftSite.GetRootFolder() - Write-host " " - Write-host " $siteName [$SiteGuid] ".PadRight(65, "*").Padleft(100, "*") - Write-host "Current Site Root: $originalSiteRoot" - - - Write-host "" - $createBackup = Read-Host -Prompt "Do you want to perform a EFT configuration backup (y/n)?" - if ($createBackup.ToUpper() -eq "Y") { - try { - $EFTBackupFileFullPath = "$transactionFolder\EFT_Server_Backup.bak" - Write-host "" - Write-host "Backing up EFT configuration:" - $sw.Restart() - .\EFT.Server.Backup.ps1 -EFTBackupFile $EFTBackupFileFullPath -Quiet -EFTAdminHostname $EFTAdminHostname -EFTAdminPort $EFTAdminPort -EFTAdminAuthType $EFTAdminAuthType -EFTAdminUsername $EFTAdminUsername -Password $Password - Write-host "Backup " -NoNewline - Write-host " Completed ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - catch { - Write-host "Backup "-NoNewline - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - } - } - Write-host "" - # Stop Site - $continue = Read-Host -Prompt "[1] Stop EFT site, do you want to stop $siteName site (y/n)?" - if ($continue.ToUpper() -eq "Y") { - try { - Write-Host "" - Write-host "Stopping $siteName site:" - $sw.Restart() - .\EFT.Server.Stop-Site.ps1 -EFTSiteName $siteName -Quiet -EFTAdminHostname $EFTAdminHostname -EFTAdminPort $EFTAdminPort -EFTAdminAuthType $EFTAdminAuthType -EFTAdminUsername $EFTAdminUsername -Password $Password - Write-host "Site Stop " -NoNewline - Write-host " Completed ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - catch { - Write-host "Site Stop " -NoNewline - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - } - } - Write-host "" - $continue = Read-Host -Prompt "[2] Robocopy data files, do you want to robocopy site root (y/n)?" - if ($continue.ToUpper() -eq "Y") { - try { - $robocopyLogFile = "$transactionFolder\Robocopy_Site.log" - Write-Host "" - Write-host "RoboCopy $originalSiteRoot to $NewSiteRoot :" - $sw.Restart() - .\Utils.RoboCopy.ps1 -sourcePath $originalSiteRoot -destinationPath $NewSiteRoot -Logfile $robocopyLogFile - Write-host "RoboCopy " -NoNewline - Write-host " Completed ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - catch { - Write-host "RoboCopy " -NoNewline - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - } - } - Write-host "" - $continue = Read-Host -Prompt "[3] Robocopy data files from virtual folders, do you want to robocopy virtual folders (y/n)?" - if ($continue.ToUpper() -eq "Y") { - try { - $EFTVirtualFolders = Import-Csv $VirtualFolderCsv - foreach ($EFTVirtualFolder in $EFTVirtualFolders) { - if($EFTVirtualFolder.SiteName -ne $sitename){ - continue - } - try { - $virtualFolder = $EFTVirtualFolder.VirtualFolder - $originalPhysicalPath = $script:EftSite.GetPhysicalPath($virtualFolder) - $newPhysicalPath = $EFTVirtualFolder.PhysicalPath - - $robocopyLogFile = "$transactionFolder\Robocopy_VirtualFolders.log" - Write-Host "" - Write-host "RoboCopy $originalPhysicalPath to $newPhysicalPath :" - $sw.Restart() - .\Utils.RoboCopy.ps1 -sourcePath $originalPhysicalPath -destinationPath $newPhysicalPath -Logfile $robocopyLogFile - Write-host "RoboCopy " -NoNewline - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - catch [System.Runtime.InteropServices.COMException] { - Write-host "RoboCopy " -NoNewline - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_FOLDER_NOT_FOUND { Write-host "MXE_FOLDER_NOT_FOUND : $_ " -ForegroundColor Red } - $MXE_INVALID_FOLDER_NAME { Write-host "MXE_INVALID_FOLDER_NAME : $_ " -ForegroundColor Red } - $MXE_FOLDER_NOT_EMPTY { Write-host "MXE_FOLDER_NOT_EMPTY : $_ " -ForegroundColor Red } - Default { Write-host "Exception : $_" -ForegroundColor Red} - } - continue - } - } - } - catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - } - } - Write-host "" - $continue = Read-Host -Prompt "[4] Change Site root, do you want to continue (y/n)?" - if ($continue.ToUpper() -ne "Y") { - exit - } - try { - Write-Host "" - Write-host "Changing site root".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $script:EftSite.SetRootFolder($NewSiteRoot) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit - } - Write-host "" - $continue = Read-Host -Prompt "[5] Import/remap virtual folders, do you want to continue (y/n)?" - if ($continue.ToUpper() -eq "Y") { - try { - Write-host "" - Write-host "Importing/Ramap virtual folders $VirtualFolderCsv" - $sw.Restart() - .\EFT.VirtualFolders.Remap.ps1 -VirtualFolderCsvFile $VirtualFolderCsv -Quiet -EFTAdminHostname $EFTAdminHostname -EFTAdminPort $EFTAdminPort -EFTAdminAuthType $EFTAdminAuthType -EFTAdminUsername $EFTAdminUsername -Password $Password - Write-host "Import/Ramap virtual folders" -NoNewline - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - catch { - Write-host "Import/Ramap virtual folders" -NoNewline - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit - } - } - - Write-host "" - $continue = Read-Host -Prompt "[6] Import folder permissions, do you want to continue (y/n)?" - if ($continue.ToUpper() -eq "Y") { - try { - Write-Host "" - Write-host "Importing EFT folder permissions $FolderPermissionsCsv" - $sw.Restart() - .\EFT.FolderPermissions.Import.ps1 -PermissionsCsvFile $FolderPermissionsCsv -Quiet -EFTAdminHostname $EFTAdminHostname -EFTAdminPort $EFTAdminPort -EFTAdminAuthType $EFTAdminAuthType -EFTAdminUsername $EFTAdminUsername -Password $Password - Write-host "Import EFT folder permissions" -NoNewline - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - catch { - Write-host "Import EFT folder permissions" -NoNewline - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit - } - } - - # Stop Site - Write-host "" - $continue = Read-Host -Prompt "[7] Start EFT site, do you want to start $siteName site (y/n)?" - if ($continue.ToUpper() -eq "Y") { - try { - Write-Host "" - Write-host "Stopping $siteName site: " - $sw.Restart() - .\EFT.Server.Start-Site.ps1 -EFTSiteName $siteName -Quiet -EFTAdminHostname $EFTAdminHostname -EFTAdminPort $EFTAdminPort -EFTAdminAuthType $EFTAdminAuthType -EFTAdminUsername $EFTAdminUsername -Password $Password - Write-host "Stop site" -NoNewline - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - } - catch { - Write-host "Start site" -NoNewline - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - } - } - - -} \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Site.Get-SiteID.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Site.Get-SiteID.ps1 deleted file mode 100644 index 8bfcb42..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Site.Get-SiteID.ps1 +++ /dev/null @@ -1,108 +0,0 @@ -## -## 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, - - [Parameter(Position = 7, Mandatory = $False, HelpMessage = "Validate Physical Path exists ")] - [switch] $Validate = $false -) -## .\EFT.Site.Get-Sites.ps1 -Validate -## Find SiteGuid for EFT site names : -## .\EFT.Site.Get-SiteID.ps1 | select-object SiteGuid, SiteName - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null -$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) - $SiteGuid = $null - $siteName = $script:EftSite.Name - try { - $SiteGuid = $script:EftSite.GUID - } - catch [System.Runtime.InteropServices.COMException] { - } - if ($EFTSiteName -ne "") { - if ( $EFTSiteName -ne $siteName) { - continue - } - } - Write-Progress -Activity "Processing Sites" -status "Site '$SiteName' $j/$sitesCount" -percentComplete ($j / $sitesCount * 100) - - try { - $SiteRootFolder = $script:EftSite.GetRootFolder() - if ($Validate) { - if (Test-Path $SiteRootFolder) { $ValidSiteRoot = "OK"} else {$ValidSiteRoot = "FOLDER_NOT_FOUND: $value" } - } - } - catch { - $ValidSiteRoot = "ERROR: $_" - } - try { - $AMParams = $script:EftSite.GetAMParams() - $UserDatabasePath = $AMParams.UserDatabasePath - - if ($Validate -and $null -ne $UserDatabasePath) { - if (Test-Path $UserDatabasePath) { $ValidSiteRoot = "OK"} else {$ValidSiteRoot = "FOLDER_NOT_FOUND: $value" } - } - } - catch { - $UserDatabasePath = "ERROR: $_" - } - - $results += new-object PSObject -Property @{ - SiteName = $script:EftSite.Name; - SiteGuid = $SiteGuid; - SiteRootFolder = $SiteRootFolder; - ValidSiteRoot = $ValidSiteRoot; - DBFile = $UserDatabasePath - } - - -} -$results | Sort-Object SiteName - -$script:EftServer.close() - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SiteSettingsPaths.Export.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SiteSettingsPaths.Export.ps1 deleted file mode 100644 index efdf763..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SiteSettingsPaths.Export.ps1 +++ /dev/null @@ -1,246 +0,0 @@ -## -## 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, - - [Parameter(Position = 7, Mandatory = $False, HelpMessage = "Validate Physical Path exists and Client (user or group exists) ")] - [switch] $Validate = $false -) -## To Export to CSV use: -## .\EFT.SiteSettingsPaths.Export.ps1 |Format-Table -## .\EFT.FolderPermissions.Export.ps1 | Export-csv permissions.csv -NoTypeInformation -## .\EFT.FolderPermissions.Export.ps1 -EFTSiteName "MySite" -## .\EFT.FolderPermissions.Export.ps1 -FolderFilter "/usr/*" -## .\EFT.FolderPermissions.Export.ps1 -FolderFilter "/usr/*" -client "Guest" -## .\EFT.FolderPermissions.Export.ps1 -EFTSiteName "MySite" | Where-Object {$_.Permissions -gt 1152} | format-table - - -$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) - $SiteGuid = $null - $siteName = $script:EftSite.Name - try { - $SiteGuid = $script:EftSite.GUID - } - catch [System.Runtime.InteropServices.COMException] { - } - if ($EFTSiteName -ne "") { - if ( $EFTSiteName -ne $siteName) { - continue - } - } - Write-Progress -Activity "Processing Sites" -status "Site '$SiteName' $j/$sitesCount" -percentComplete ($j / $sitesCount * 100) - - # Retrieve all the paths - $setting = "SiteRootFolder" - $value = "" - $ValidPath = "" - try { - $value = $script:EftSite.GetRootFolder() - if ($Validate) { - if (Test-Path $value) { $ValidPath = "OK"} else {$ValidPath = "FOLDER_NOT_FOUND: $value" } - } - } - catch { - $value = "ERROR: $_" - } - $results += new-object PSObject -Property @{ SiteName = $script:EftSite.Name; Setting = $setting; Path = $value; ValidPath = $ValidPath; } - - # Retrieve all the paths - $setting = "SiteAudFilePath" - $value = "" - $ValidPath = "" - try { - $AMParam = $script:EftSite.GetAMParams() - $value = $AMParam.UserDatabasePath - if ($Validate) { - if (Test-Path $value) { $ValidPath = "OK"} else {$ValidPath = "FILE_NOT_FOUND: $value" } - } - } - catch { - $value = "ERROR: $_" - } - $results += new-object PSObject -Property @{ SiteName = $script:EftSite.Name; Setting = $setting; Path = $value; ValidPath = $ValidPath; } - - if ($null -ne $SiteGuid) { - $setting = "SiteDBFilePath" - $value = "" - $ValidPath = "" - $HAConfigurationFilePath = $null - $ConfigurationFilePath = $null - try {$HAConfigurationFilePath = $script:EftServer.HAConfigurationFilePath } catch{} - try {$ConfigurationFilePath = $script:EftServer.ConfigurationFilePath } catch{} - - try { - if ($null -ne $HAConfigurationFilePath){ - $value = Join-Path $HAConfigurationFilePath "$SiteGuid.Clients.db" - } - else { - $value = Join-Path $ConfigurationFilePath "$SiteGuid.Clients.db" - } - if ($Validate) { - if (Test-Path $value) { $ValidPath = "OK"} else {$ValidPath = "FILE_NOT_FOUND: $value" } - } - } - catch { - $value = "ERROR: $_" - } - $results += new-object PSObject -Property @{ SiteName = $script:EftSite.Name; Setting = $setting; Path = $value; ValidPath = $ValidPath; } - } - - $setting = "RSAConfigurationPath" - $value = "" - $ValidPath = "" - try { - $value = $script:EftSite.RSAConfigurationPath - if ($Validate -and [string]::IsNullOrEmpty($value) -ne $true) { - if (Test-Path $value -PathType Leaf) { $ValidPath = "OK"} else {$ValidPath = "FILE_NOT_FOUND: $value" } - } - } - catch { - $value = "ERROR: $_" - } - $results += new-object PSObject -Property @{ SiteName = $script:EftSite.Name; Setting = $setting; Path = $value; ValidPath = $ValidPath; } - - $setting = "WebSSOIdpPublicKeyPath" - $value = "" - $ValidPath = "" - try { - $value = $script:EftSite.WebSSOIdpPublicKeyPath - if ($Validate -and [string]::IsNullOrEmpty($value) -ne $true) { - if (Test-Path $value -PathType Leaf) { $ValidPath = "OK"} else {$ValidPath = "FILE_NOT_FOUND: $value" } - } - } - catch { - $value = "ERROR: $_" - } - $results += new-object PSObject -Property @{ SiteName = $script:EftSite.Name; Setting = $setting; Path = $value; ValidPath = $ValidPath; } - - $setting = "SFTPKeyFile" - $value = "" - $ValidPath = "" - try { - $value = $script:EftSite.SFTPKeyFile - if ($Validate -and [string]::IsNullOrEmpty($value) -ne $true) { - if (Test-Path $value -PathType Leaf) { $ValidPath = "OK"} else {$ValidPath = "FILE_NOT_FOUND: $value" } - - if ($ValidPath -eq "OK") { - if ($script:EftSite.SFTPPublicKeyBlob -eq "") { - $ValidPath = "INVALID_KEY" - } - } - } - } - catch { - $value = "ERROR: $_" - } - $results += new-object PSObject -Property @{ SiteName = $script:EftSite.Name; Setting = $setting; Path = $value; ValidPath = $ValidPath; } - - $setting = "AS2Certificate" - $value = "" - $ValidPath = "" - try { - $value = $script:EftSite.AS2Certificate - if ($Validate -and [string]::IsNullOrEmpty($value) -ne $true) { - if (Test-Path $value -PathType Leaf) { $ValidPath = "OK"} else {$ValidPath = "FILE_NOT_FOUND: $value" } - } - } - catch { - $value = "ERROR: $_" - } - $results += new-object PSObject -Property @{ SiteName = $script:EftSite.Name; Setting = $setting; Path = $value; ValidPath = $ValidPath; } - - $setting = "AS2PrivateKey" - $value = "" - $ValidPath = "" - try { - $value = $script:EftSite.AS2PrivateKey - if ($Validate -and [string]::IsNullOrEmpty($value) -ne $true) { - if (Test-Path $value -PathType Leaf) { $ValidPath = "OK"} else {$ValidPath = "FILE_NOT_FOUND: $value" } - } - } - catch { - $value = "ERROR: $_" - } - $results += new-object PSObject -Property @{ SiteName = $script:EftSite.Name; Setting = $setting; Path = $value; ValidPath = $ValidPath; } - - $setting = "SSLCertPath" - $value = "" - $ValidPath = "" - try { - $value = $script:EftSite.GetCertFilePath() - if ($Validate -and [string]::IsNullOrEmpty($value) -ne $true) { - if (Test-Path $value -PathType Leaf) { $ValidPath = "OK"} else {$ValidPath = "FILE_NOT_FOUND: $value" } - } - } - catch { - $value = "ERROR: $_" - } - $results += new-object PSObject -Property @{ SiteName = $script:EftSite.Name; Setting = $setting; Path = $value; ValidPath = $ValidPath; } - - $setting = "SSLKeyFilePath" - $value = "" - $ValidPath = "" - try { - $value = $script:EftSite.GetKeyFilePath() - if ($Validate -and [string]::IsNullOrEmpty($value) -ne $true) { - if (Test-Path $value -PathType Leaf) { $ValidPath = "OK"} else {$ValidPath = "FILE_NOT_FOUND: $value" } - } - } - catch { - $value = "ERROR: $_" - } - $results += new-object PSObject -Property @{ SiteName = $script:EftSite.Name; Setting = $setting; Path = $value; ValidPath = $ValidPath; } - -} -$results | Sort-Object SiteName - -$script:EftServer.close() - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Sqlite.Invoke-NoQuery.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Sqlite.Invoke-NoQuery.ps1 deleted file mode 100644 index 6be70c5..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Sqlite.Invoke-NoQuery.ps1 +++ /dev/null @@ -1,34 +0,0 @@ -[CmdletBinding()] -Param( - [Parameter(Position = 1, Mandatory = $true, HelpMessage = "Enter a workspace db file")] - [String] $WorkspacesDbFile = "Workspaces.db", - - [Parameter(Position = 1, Mandatory = $true, HelpMessage = "Enter a table name")] - [String] $query = "select * from Site", - - [Parameter(Position = 1, Mandatory = $false, HelpMessage = "Enter a table name")] - [hashtable] $params = $null - -) -# Get all Ids to Text - - -#.\EFT.Sqlite.Invoke-NoQuery.ps1 -query "insert into site (id, ws_enabled, ws_allowSharingToExistingUsersOnly) Values (@id, 1,0)" -params @{"@id" = [guid]::new("edbda119-46e7-4ad5-b143-a1806955d7d5") ;} -Add-Type -Path "System.Data.SQLite.dll" -$DbFile = Resolve-Path $DbFile -$conn = New-Object -TypeName System.Data.SQLite.SQLiteConnection -$conn.ConnectionString = "Data Source=$DbFile" -$conn.Open() -$command = $conn.CreateCommand() -$command.CommandText = $query - -if ($null -ne $params) { - foreach ($key in $params.keys ){ - Write-Verbose "$($key) = $($params[$key])" - $null = $command.Parameters.AddWithValue($key, $params[$key]); - } -} - -[Int32]$command.ExecuteNonQuery() - -$conn.Close() \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Sqlite.Invoke-Query.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Sqlite.Invoke-Query.ps1 deleted file mode 100644 index 112a922..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Sqlite.Invoke-Query.ps1 +++ /dev/null @@ -1,39 +0,0 @@ -[CmdletBinding()] -Param( - [Parameter(Position = 1, Mandatory = $true, HelpMessage = "Enter a workspace db file")] - [String] $DBFile = "Workspaces.db", - - [Parameter(Position = 1, Mandatory = $true, HelpMessage = "Enter a table name")] - [String] $Query = "select * from Site", - - [Parameter(Position = 1, Mandatory = $false, HelpMessage = "Enter a table name")] - [hashtable] $params = $null - -) -# Get all Ids to Text -#.\EFT.Sqlite.Invoke-Query.ps1 -query "select id from Site" -dbfile workspaces.db | foreach {[guid]::new( ($_.id|ForEach-Object ToString X2) -join '')} -#.\EFT.Sqlite.Invoke-Query.ps1 -query "select hex(id) from Site" -dbfile workspaces.db -#.\EFT.Sqlite.Invoke-Query.ps1 -query "select id from Site where lower(hex(id))=@id" -params @{"@id" = [guid]::new("e9dac990-1c04-4663-9394-307bcfe014e7").toString('N'); "@Name" = "myname"} -#.\EFT.Sqlite.Invoke-Query.ps1 -query "select * from Workspace where lower(hex(site)) = @id" -params @{"@id" = [guid]::new("e9dac990-1c04-4663-9394-307bcfe014e7").toString('N')} - -Add-Type -Path "System.Data.SQLite.dll" -$DbFile = Resolve-Path $DbFile -$conn = New-Object -TypeName System.Data.SQLite.SQLiteConnection -$conn.ConnectionString = "Data Source=$DbFile" -$conn.Open() -$command = $conn.CreateCommand() -$command.CommandText = $query - -if ($null -ne $params) { - foreach ($key in $params.keys ){ - Write-Verbose "$($key) = $($params[$key])" - $null = $command.Parameters.AddWithValue($key, $params[$key]); - } -} -$adapter = New-Object -TypeName System.Data.SQLite.SQLiteDataAdapter $command -$dataset = New-Object System.Data.DataSet -[void]$adapter.Fill($dataset) -$dataset.Tables[0] -$conn.Close() -$conn.Dispose() -$command.Dispose() diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SyncTool.ConfigGenerator.docx b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SyncTool.ConfigGenerator.docx deleted file mode 100644 index 6c3cd3f..0000000 Binary files a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SyncTool.ConfigGenerator.docx and /dev/null differ diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SyncTool.ConfigGenerator.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SyncTool.ConfigGenerator.ps1 deleted file mode 100644 index e69de29..0000000 diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SyncTool.ConfigGenerator.vbs b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SyncTool.ConfigGenerator.vbs deleted file mode 100644 index c90e3ef..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.SyncTool.ConfigGenerator.vbs +++ /dev/null @@ -1,226 +0,0 @@ -Dim objFSO, sFile, siteCount -Dim vbsExport, vbsImport -Dim synctExport, synctImport, AuthType -Set objFSO = CreateObject("Scripting.FileSystemObject") -Set sFile = objFSO.OpenTextFile( "Site.TXT", 8, true, 0 ) -Set vbsExport = objFSO.OpenTextFile( "Export_Perm-VFS.bat", 8, true, 0 ) -Set vbsImport = objFSO.OpenTextFile( "Import_Perm-VFS.bat", 8, true, 0 ) -Set synctExport = objFSO.OpenTextFile( "Export_synctool.bat", 8, true, 0 ) -Set synctImport = objFSO.OpenTextFile( "Import_synctool.bat", 8, true, 0 ) -Set SFTPServer = WScript.CreateObject("SFTPCOMInterface.CIServer") - -CRLF = (Chr(13)& Chr(10)) -txtServer = "localhost" -txtPort = "1100" -txtAdminUserName = "eftadmin" -txtPassword = "!@#$T3st" - -If Not Connect(txtServer, txtPort, txtAdminUserName, txtPassword) Then - msgbox Connect - WScript.Quit(0) -End If - -Dim chkeftSiteName, eftSiteName - -'siteName = "MySite" -set siteToRemove = Nothing -set sites = SFTPServer.Sites() -siteCount = 0 -For i = 0 To sites.Count -1 - set site = sites.Item(i) - - siteCount = siteCount + 1 - - chkeftSiteName = site.Name - - spaces = Ubound(Split(chkeftSiteName, " ")) - - if (spaces = 0) then - eftSiteName = site.Name - else - eftSiteName = chr(34) & site.Name & chr(34) - end If - - - - - - If site.GetAuthManagerID() = 0 Then - AuthType = "GS_Site" - ElseIf site.GetAuthManagerID() = 1 Then - AuthType = "AD_Site" - ElseIf site.GetAuthManagerID() = 2 Then - AuthType = "ODBC_Site" - ElseIf site.GetAuthManagerID() = 3 Then - AuthType = "LDAP_Site" - End If - - 'WScript.Echo eftSiteName & " " & AuthType - - - If AuthType = "AD_Site" Then - - If siteCount > 1 Then - ' WScript.Echo siteCount - - sFile.Write(site.Name & " : " & site.GUID & vbCrLf) - vbsExport.Write("cscript.exe 1ExportPermissions.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & chr(34) & site.Name & "_Permissions.txt" & chr(34) & vbCrLf & "cscript.exe 2ExportVirtualFolders.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & chr(34) & site.Name & "_vFolders.txt" & chr(34) & vbCrLf & vbCrLf) - vbsImport.Write("cscript.exe 3ImportVirtualFolders.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & chr(34) & site.Name & "__vFolders.txt" & chr(34) & vbCrLf & "cscript.exe 4ImportPermissions.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & chr(34) & site.Name & "_Permissions.txt" & chr(34) & vbCrLf & vbCrLf) - - 'synctExport.Write("REN EFTUtils.exe.config EFTUtils.exe.config_Orig.txt" & vbCrLf) - synctExport.Write("REN " & Chr(34) & "EFTUtils.exe.config_" & site.Name & ".txt" & Chr(34) & " EFTUtils.exe.config" & vbCrLf) - synctExport.Write("eftutils.exe export " & chr(34) & "CONNECTIONPROFILES,ADVANCEDWORKFLOWS,COMMANDS,SITESETTINGS,SITEIPACCESSRESTRICTIONS,SITESECURITYSETTINGS,LOGSETTINGS,DMZGATEWAY,USERTEMPLATES,USERSTATS,USERTEMPLATEMEMBERSHIP,GROUPS,USERSIPACCESSRESTRICTIONS,USERTEMPLATESIPACCESSRESTRICTIONS,EVENTS,VIRTUALFOLDERS" & chr(34) & " " & eftSiteName & " /xml" & vbCrLf) - synctExport.Write("REN EFTUtils.exe.config " & Chr(34) & "EFTUtils.exe.config_" & site.Name & "_DONE.TXT" & Chr(34) & vbCrLf & vbCrLF) - - 'synctImport.Write("REN EFTUtils.exe.config EFTUtils.exe.config_Orig.txt" & vbCrLf) - synctImport.Write("REN " & Chr(34) & "EFTUtils.exe.config_" & site.Name & ".txt" & Chr(34) & " EFTUtils.exe.config" & vbCrLf) - synctImport.Write("eftutils.exe import " & chr(34) & "CONNECTIONPROFILES,ADVANCEDWORKFLOWS,COMMANDS,SITESETTINGS,SITEIPACCESSRESTRICTIONS,SITESECURITYSETTINGS,LOGSETTINGS,DMZGATEWAY,USERTEMPLATES,USERSTATS,USERTEMPLATEMEMBERSHIP,GROUPS,USERSIPACCESSRESTRICTIONS,USERTEMPLATESIPACCESSRESTRICTIONS,EVENTS,VIRTUALFOLDERS" & chr(34) & " " & eftSiteName & " /xml" & vbCrLf) - synctImport.Write("REN EFTUtils.exe.config " & Chr(34) & "EFTUtils.exe.config_" & site.Name & "_DONE.TXT" & Chr(34) & vbCrLf & vbCrLF) - Else - - sFile.Write(site.Name & " : " & site.GUID & vbCrLf) - vbsExport.Write("cscript.exe 1ExportPermissions.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & site.Name & "_Permissions.txt" & vbCrLf & "cscript.exe 2ExportVirtualFolders.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & site.Name & "_vFolders.txt" & vbCrLf & vbCrLf) - vbsImport.Write("cscript.exe 3ImportVirtualFolders.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & site.Name & "__vFolders.txt" & vbCrLf & "cscript.exe 4ImportPermissions.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & site.Name & "_Permissions.txt" & vbCrLf & vbCrLf) - - synctExport.Write("REN " & Chr(34) & "EFTUtils.exe.config_" & site.Name & ".txt" & Chr(34) & " EFTUtils.exe.config" & vbCrLf) - synctExport.Write("eftutils.exe export " & chr(34) & "SSHKEYRING,PGPKEYRING,SSLTRUSTEDCERTIFICATES,CONNECTIONPROFILES,ADVANCEDWORKFLOWS,COMMANDS,SITESETTINGS,SITEIPACCESSRESTRICTIONS,SITESECURITYSETTINGS,LOGSETTINGS,DMZGATEWAY,USERTEMPLATES,USERSTATS,USERTEMPLATEMEMBERSHIP,GROUPS,USERSIPACCESSRESTRICTIONS,USERTEMPLATESIPACCESSRESTRICTIONS,EVENTS,VIRTUALFOLDERS" & chr(34) & " " & eftSiteName & " /xml" & vbCrLf) - synctExport.Write("REN EFTUtils.exe.config " & Chr(34) & "EFTUtils.exe.config_" & site.Name & "_DONE.TXT" & Chr(34) & vbCrLf & vbCrLF) - - synctImport.Write("REN " & Chr(34) & "EFTUtils.exe.config_" & site.Name & ".txt" & Chr(34) & " EFTUtils.exe.config" & vbCrLf) - synctImport.Write("eftutils.exe import " & chr(34) & "SSHKEYRING,PGPKEYRING,SSLTRUSTEDCERTIFICATES,CONNECTIONPROFILES,ADVANCEDWORKFLOWS,COMMANDS,SITESETTINGS,SITEIPACCESSRESTRICTIONS,SITESECURITYSETTINGS,LOGSETTINGS,DMZGATEWAY,USERTEMPLATES,USERSTATS,USERTEMPLATEMEMBERSHIP,GROUPS,USERSIPACCESSRESTRICTIONS,USERTEMPLATESIPACCESSRESTRICTIONS,EVENTS,VIRTUALFOLDERS" & chr(34) & " " & eftSiteName & " /xml" & vbCrLf) - synctImport.Write("REN EFTUtils.exe.config " & Chr(34) & "EFTUtils.exe.config_" & site.Name & "_DONE.TXT" & Chr(34) & vbCrLf & vbCrLF) - End If - - End If - - - If AuthType = "GS_Site" Then - - 'WScript.Echo "Other" - - If siteCount > 1 Then - ' WScript.Echo siteCount - - sFile.Write(site.Name & " : " & site.GUID & vbCrLf) - vbsExport.Write("cscript.exe 1ExportPermissions.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & chr(34) & site.Name & "_Permissions.txt" & chr(34) & vbCrLf & "cscript.exe 2ExportVirtualFolders.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & chr(34) & site.Name & "_vFolders.txt" & chr(34) & vbCrLf & vbCrLf) - vbsImport.Write("cscript.exe 3ImportVirtualFolders.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & chr(34) & site.Name & "__vFolders.txt" & chr(34) & vbCrLf & "cscript.exe 4ImportPermissions.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & chr(34) & site.Name & "_Permissions.txt" & chr(34) & vbCrLf & vbCrLf) - - 'synctExport.Write("REN EFTUtils.exe.config EFTUtils.exe.config_Orig.txt" & vbCrLf) - synctExport.Write("REN " & Chr(34) & "EFTUtils.exe.config_" & site.Name & ".txt" & Chr(34) & " EFTUtils.exe.config" & vbCrLf) - synctExport.Write("eftutils.exe export " & chr(34) & "CONNECTIONPROFILES,ADVANCEDWORKFLOWS,COMMANDS,SITESETTINGS,SITEIPACCESSRESTRICTIONS,SITESECURITYSETTINGS,LOGSETTINGS,DMZGATEWAY,USERTEMPLATES,USERS,USERSTATS,USERTEMPLATEMEMBERSHIP,GROUPS,USERSIPACCESSRESTRICTIONS,USERTEMPLATESIPACCESSRESTRICTIONS,EVENTS,VIRTUALFOLDERS" & chr(34) & " " & eftSiteName & " /xml" & vbCrLf) - synctExport.Write("REN EFTUtils.exe.config " & Chr(34) & "EFTUtils.exe.config_" & site.Name & "_DONE.TXT" & Chr(34) & vbCrLf & vbCrLF) - - 'synctImport.Write("REN EFTUtils.exe.config EFTUtils.exe.config_Orig.txt" & vbCrLf) - synctImport.Write("REN " & Chr(34) & "EFTUtils.exe.config_" & site.Name & ".txt" & Chr(34) & " EFTUtils.exe.config" & vbCrLf) - synctImport.Write("eftutils.exe import " & chr(34) & "CONNECTIONPROFILES,ADVANCEDWORKFLOWS,COMMANDS,SITESETTINGS,SITEIPACCESSRESTRICTIONS,SITESECURITYSETTINGS,LOGSETTINGS,DMZGATEWAY,USERTEMPLATES,USERS,USERSTATS,USERTEMPLATEMEMBERSHIP,GROUPS,USERSIPACCESSRESTRICTIONS,USERTEMPLATESIPACCESSRESTRICTIONS,EVENTS,VIRTUALFOLDERS" & chr(34) & " " & eftSiteName & " /xml" & vbCrLf) - synctImport.Write("REN EFTUtils.exe.config " & Chr(34) & "EFTUtils.exe.config_" & site.Name & "_DONE.TXT" & Chr(34) & vbCrLf & vbCrLF) - Else - - sFile.Write(site.Name & " : " & site.GUID & vbCrLf) - vbsExport.Write("cscript.exe 1ExportPermissions.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & chr(34) & site.Name & "_Permissions.txt" & chr(34) & vbCrLf & "cscript.exe 2ExportVirtualFolders.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & chr(34) & site.Name & "_vFolders.txt" & chr(34) & vbCrLf & vbCrLf) - vbsImport.Write("cscript.exe 3ImportVirtualFolders.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & chr(34) & site.Name & "__vFolders.txt" & chr(34) & vbCrLf & "cscript.exe 4ImportPermissions.vbs -s " & txtServer & " -port " & txtPort & " -u " & txtAdminUserName & " -p " & txtPassword & " -site " & eftSiteName & " -f " & chr(34) & site.Name & "_Permissions.txt" & chr(34) & vbCrLf & vbCrLf) - - synctExport.Write("REN " & Chr(34) & "EFTUtils.exe.config_" & site.Name & ".txt" & Chr(34) & " EFTUtils.exe.config" & vbCrLf) - synctExport.Write("eftutils.exe export " & chr(34) & "SSHKEYRING,PGPKEYRING,SSLTRUSTEDCERTIFICATES,CONNECTIONPROFILES,ADVANCEDWORKFLOWS,COMMANDS,SITESETTINGS,SITEIPACCESSRESTRICTIONS,SITESECURITYSETTINGS,LOGSETTINGS,DMZGATEWAY,USERTEMPLATES,USERS,USERSTATS,USERTEMPLATEMEMBERSHIP,GROUPS,USERSIPACCESSRESTRICTIONS,USERTEMPLATESIPACCESSRESTRICTIONS,EVENTS,VIRTUALFOLDERS" & chr(34) & " " & eftSiteName & " /xml" & vbCrLf) - synctExport.Write("REN EFTUtils.exe.config " & Chr(34) & "EFTUtils.exe.config_" & site.Name & "_DONE.TXT" & Chr(34) & vbCrLf & vbCrLF) - - - synctImport.Write("REN " & Chr(34) & "EFTUtils.exe.config_" & site.Name & ".txt" & Chr(34) & " EFTUtils.exe.config" & vbCrLf) - synctImport.Write("eftutils.exe import " & chr(34) & "SSHKEYRING,PGPKEYRING,SSLTRUSTEDCERTIFICATES,CONNECTIONPROFILES,ADVANCEDWORKFLOWS,COMMANDS,SITESETTINGS,SITEIPACCESSRESTRICTIONS,SITESECURITYSETTINGS,LOGSETTINGS,DMZGATEWAY,USERTEMPLATES,USERS,USERSTATS,USERTEMPLATEMEMBERSHIP,GROUPS,USERSIPACCESSRESTRICTIONS,USERTEMPLATESIPACCESSRESTRICTIONS,EVENTS,VIRTUALFOLDERS" & chr(34) & " " & eftSiteName & " /xml" & vbCrLf) - synctImport.Write("REN EFTUtils.exe.config " & Chr(34) & "EFTUtils.exe.config_" & site.Name & "_DONE.TXT" & Chr(34) & vbCrLf & vbCrLF) - - End If - - End If -Next - -Function Connect (serverOrIpAddress, port, username, password) - - On Error Resume Next - Err.Clear - - SFTPServer.Connect serverOrIpAddress, port, username, password - - If Err.Number <> 0 Then - WScript.Echo "Error connecting to '" & serverOrIpAddress & ":" & port & "' -- " & err.Description & " [" & CStr(err.Number) & "]", vbInformation, "Error" - Connect = False - Exit Function - End If - - Connect = True -End Function - - -Const ForReading = 1 - -Const ForWriting = 2 - - -'Set objFSO = CreateObject("Scripting.FileSystemObject") - -Dim strSITEName, strGUID, strConfigFile -Set objShell = CreateObject("WScript.Shell") -currDir = objShell.CurrentDirectory - - - -'Read Site.TXT file -Const strInFile = "SITE.TXT" -Set objInFile = objFSO.OpenTextFile(strInFile, ForReading) - -Do Until objInFile.AtEndOfStream - strLine = objInFile.Readline - arrField = Split(strLine, " : ") - -strSITEName = arrField(0) -strGUID = arrField(1) & ".Client.db" - -'WScript.Echo "SiteName= " & strSITEName & " GUID= " & strGUID - -Set objFile = objFSO.OpenTextFile("EFTUtils.exe.config_Template.txt", ForReading) - - -strText = objFile.ReadAll - -objFile.Close - - -strNewText1 = Replace(strText, "GUIDSTRING.Clients.db", strGUID) ' GUID change -strNewText2 = Replace(strNewText1, "chgadmin", txtAdminUserName) ' admin change -strNewText3 = Replace(strNewText2, "chgP@$$", txtPassword) ' Password chg -strNewText4 = Replace(strNewText3, "chgToCurrDir", currDir) ' SiteDir Change - -strConfigFile = "EFTUtils.exe.config_" & strSITEName & ".txt" - -Set objFile = objFSO.CreateTextFile(strConfigFile, ForWriting) - -objFile.WriteLine strNewText4 - -objFile.Close - -Loop - -objFSO.MoveFile "EFTUtils.exe.config", "EFTUtils.exe.config_orig_keep.txt" -wscript.echo "Done!" - - - - - - - - - - - - - - - - - - - - - - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.User.SetEnable.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.User.SetEnable.ps1 deleted file mode 100644 index 84012b3..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.User.SetEnable.ps1 +++ /dev/null @@ -1,144 +0,0 @@ -## -## 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(SupportsShouldProcess)] -Param( - [Parameter(Position = 0, Mandatory = $false, HelpMessage = "Enter the user list CSV file ")] - [string] $UserCsvlist = "userlist.csv", - - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False )] - [switch]$Quiet = $false -) - -if ($UserCsvlist -eq "") { - #Uncomment the following to enter paramters for each site - # $EFTPermissions = @( - # @{ SiteName = "MySite"; SettingsTemplate= ""; IsEnabled=""; Username = "\"; } - # @{ SiteName = "MySite"; SettingsTemplate= ""; IsEnabled=""; Username = "\"; } - #) -} -else { - $EFTUsers = Import-Csv $UserCsvlist - # "SiteName","SettingsTemplate", "IsEnabled","Username" -} - - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' -$MXE_FOLDER_NOT_FOUND = "MX Error: 82 (00000052)" -$MXE_INVALID_FOLDER_NAME = "MX Error: 97 (00000061)" -$MXE_FOLDER_NOT_EMPTY = "MX Error: 117 (00000075)" - -$MAX_PAD = 100 -$PAD_CHR = "." - -$EFTServer = new-object -ComObject "SFTPCOMInterface.CIServer" - -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $script:EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() - -$SiteList = @{} -for ($j = 0; $j -le $sitesCount - 1; $j++ ) { - $script:EftSite = $script:EftSites.Item($j) - $SiteList.Add($script:EftSite.Name, $script:EftSite.ID) -} - - -Write-host "Updating Users:" -$Imported = 0 -$errorCount = 0 -foreach ($EFTUser in $EFTUsers) { - try { - - $script:EftSite = $script:EftSites.SiteByID($SiteList[$EFTUser.SiteName]) - } - catch { - Write-Host "Failed adding user '$($EFTUser.Username)'" -ForegroundColor Red - Write-Host "Exception : $($_.Exception.Message)" -ForegroundColor Red - continue - } - try { - Write-Verbose "User '$($EFTUser.Username)' already exists." - $detail = $script:EftSite.GetUserSettings($EFTUser.Username) - } - catch { - Write-Host "Failed setting '$($EFTUser.Username)' user enabled state" -ForegroundColor Red - Write-Host "Exception : $($_.Exception.Message)" -ForegroundColor Red - $errorCount++ - continue - } - try { - $userSettings = $script:EftSite.GetUserSettings($EFTUser.Username); - - if (-not [string]::IsNullOrEmpty($EFTUser.IsEnabled)) { - Write-Host "Update: [$($EFTUser.SiteName)] [$($EFTUser.Username)] $IsEnable-> $($EFTUser.IsEnabled)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - - if ($PSCmdlet.ShouldProcess($EFTUser.Username, "IsEnable=$($EFTUser.IsEnabled)")) { - $userSettings.SetEnableAccount($EFTUser.IsEnabled) - } - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green - $Updated++ - } - } - catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_FOLDER_NOT_FOUND { Write-host "MXE_FOLDER_NOT_FOUND : $_ " -ForegroundColor Red } - $MXE_INVALID_FOLDER_NAME { Write-host "MXE_INVALID_FOLDER_NAME : $_ " -ForegroundColor Red } - $MXE_FOLDER_NOT_EMPTY { Write-host "MXE_FOLDER_NOT_EMPTY : $_ " -ForegroundColor Red } - Default { Write-host "Exception : $_" -ForegroundColor Red} - } - $errorCount++ - continue - } - -} -$script:EftServer.close() - -Write-host " Updated: " -NoNewline -Write-host "$Updated " -NoNewline -ForegroundColor green -Write-host "Errors: "-NoNewline -Write-host "$errorCount " -ForegroundColor red -Write-host " " - - - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.UserSettings.Export.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.UserSettings.Export.ps1 deleted file mode 100644 index 8992030..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.UserSettings.Export.ps1 +++ /dev/null @@ -1,262 +0,0 @@ -## -## 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 = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password -) -## To Export to CSV use: -## .\EFT.UserSettings.ps1 |Export-csv foo.csv -NoTypeInformation -## .\EFT.UserSettings.ps1 |Where-Object {$_.Username -eq "rguzman"} | format-table -## .\EFT.UserSettings.ps1 | where-object {$_.Username -eq "rguzman" } |export-csv foo.csv -NoTypeInformation -## .\EFT.UserSettings.Export.ps1 -EFTSiteName MySite | Select-object ExpirationDate, username, IsInactivityPeriodLimited, InactivityPeriodLimited, IsPasswordAgeLimited, PasswordAgeLimited -function Get-AdvancedBool($value, $inherited) { - if ($inherited ) { - #abInherited - return -2 - } - else { - if($value) { - return 1 - } - else { - return 0 - } - } -} - - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - -$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) - - $SiteGuid = $null - try { - $SiteGuid = $script:EftSite.GUID - } - catch [System.Runtime.InteropServices.COMException] { - - } - $users = $script:EftSite.GetUsers() - - for ($i = 0; $i -lt $users.length; $i++ ) { - Write-Progress -Activity "Processing Sites" -status "Site '$SiteName' User '$($users[$i])' $i/$($users.length)" -percentComplete ($i / $users.length * 100) - $detail = $script:EftSite.GetUserSettings($users[$i]) - - # Check creation time to as LastConnectTime is not set to a value (defaults to - # 11/30/1999) until user accessed site. - #$LastConnectTimeSpan = [System.DateTime]::Now - [datetime]$detail.LastConnectionTime; - $o = "" - $inherited = $null - #Get-AdvancedBool $value $inherited - - $inherited = $null; $IsUserExpired = Get-AdvancedBool $($detail.GetExpirationDate( [ref] $inherited )) $inherited - $ExpirationDate = $inherited - - $inherited = $null; $IsEnabled = Get-AdvancedBool $($detail.GetEnableAccount( [ref] $inherited )) $inherited - $inherited = $null; $Homefolder = Get-AdvancedBool $($detail.GetHomeDir( [ref] $inherited )) $inherited - $inherited = $null; $HomefolderIsRoot = Get-AdvancedBool $($detail.GetHomeDirIsRoot( [ref] $inherited )) $inherited - - $inherited = $null; $EnableDiskQuota = Get-AdvancedBool $($detail.GetEnableDiskQuota( [ref] $inherited )) $inherited - $inherited = $null; $MaxSpace = Get-AdvancedBool $($detail.GetMaxSpace( [ref] $inherited )) $inherited - $inherited = $null; $TwoFactorAuthentication = Get-AdvancedBool $($detail.GetTwoFactorAuthentication( [ref] $inherited )) $inherited - - $inherited = $null; $FTP = Get-AdvancedBool $($detail.GetClearFTP( [ref] $inherited )) $inherited - $inherited = $null; $FTPS = Get-AdvancedBool $($detail.GetFTPS( [ref] $inherited )) $inherited - $inherited = $null; $AllowFXP = Get-AdvancedBool $($detail.GetAllowFXP( [ref] $inherited )) $inherited - $inherited = $null; $AllowNoop = Get-AdvancedBool $($detail.GetAllowNoop( [ref] $inherited )) $inherited - $inherited = $null; $AllowCOMB = Get-AdvancedBool $($detail.GetAllowCOMB( [ref] $inherited )) $inherited - $inherited = $null; $AllowXCRC = Get-AdvancedBool $($detail.GetAllowXCRC( [ref] $inherited )) $inherited - $inherited = $null; $AllowMODEZ = Get-AdvancedBool $($detail.GetAllowMODEZ( [ref] $inherited )) $inherited - #$inherited = $null; $LoginMsg = Get-AdvancedBool $($detail.GetLoginMsg( [ref] $inherited )) $inherited - $inherited = $null; $SSLAuthenticationType = Get-AdvancedBool $($detail.GetSSLAuthenticationType( [ref] $inherited )) $inherited - $inherited = $null; $SFTP = Get-AdvancedBool $($detail.GetSFTP( [ref] $inherited )) $inherited - $inherited = $null; $ClearHTTP = Get-AdvancedBool $($detail.GetClearHTTP( [ref] $inherited )) $inherited - $inherited = $null; $HTTPS = Get-AdvancedBool $($detail.GetHTTPS( [ref] $inherited )) $inherited - $inherited = $null; $AppletEnabled = Get-AdvancedBool $($detail.GetAppletEnabled( [ref] $inherited )) $inherited - $inherited = $null; $AS2Inbound = Get-AdvancedBool $($detail.GetAS2Inbound( [ref] $inherited )) $inherited - $inherited = $null; $AS2Outbound = Get-AdvancedBool $($detail.GetAS2Outbound( [ref] $inherited )) $inherited - $inherited = $null; $HasMaxSpeed = Get-AdvancedBool $($detail.GetHasMaxSpeed( [ref] $inherited )) $inherited - $inherited = $null; $EnableTimeOut = Get-AdvancedBool $($detail.GetEnableTimeOut( [ref] $inherited )) $inherited - $inherited = $null; $HasMaxUsers = Get-AdvancedBool $($detail.GetHasMaxUsers( [ref] $inherited )) $inherited - $inherited = $null; $HasMaxIPs = Get-AdvancedBool $($detail.GetHasMaxIPs( [ref] $inherited )) $inherited - $inherited = $null; $MaxSpeed = Get-AdvancedBool $($detail.GetMaxSpeed( [ref] $inherited )) $inherited - $inherited = $null; $TimeOut = Get-AdvancedBool $($detail.GetTimeOut( [ref] $inherited )) $inherited - $inherited = $null; $MaxUsers = Get-AdvancedBool $($detail.GetMaxUsers( [ref] $inherited )) $inherited - #$inherited = $null; $MaxIPs = Get-AdvancedBool $($detail.GetMaxIPs( [ref] $inherited )) $inherited - $inherited = $null; $HasUploadsPerSession = Get-AdvancedBool $($detail.GetHasUploadsPerSession( [ref] $inherited )) $inherited - $inherited = $null; $HasDownloadsPerSession = Get-AdvancedBool $($detail.GetHasDownloadsPerSession( [ref] $inherited )) $inherited - $inherited = $null; $HasMaxUploadSize = Get-AdvancedBool $($detail.GetHasMaxUploadSize( [ref] $inherited )) $inherited - $inherited = $null; $HasMaxDownloadSize = Get-AdvancedBool $($detail.GetHasMaxDownloadSize( [ref] $inherited )) $inherited - $inherited = $null; $UploadsPerSession = Get-AdvancedBool $($detail.GetUploadsPerSession( [ref] $inherited )) $inherited - $inherited = $null; $DownloadsPerSession = Get-AdvancedBool $($detail.GetDownloadsPerSession( [ref] $inherited )) $inherited - $inherited = $null; $MaxUploadSize = Get-AdvancedBool $($detail.GetMaxUploadSize( [ref] $inherited )) $inherited - $inherited = $null; $MaxDownloadSize = Get-AdvancedBool $($detail.GetMaxDownloadSize( [ref] $inherited )) $inherited - #$inherited = $null; $IPAccessAllowedDefault = Get-AdvancedBool $($detail.IPAccessAllowedDefault( [ref] $inherited )) $inherited - $inherited = $null; $LimitAccessByIP = Get-AdvancedBool $($detail.GetLimitAccessByIP( [ref] $inherited )) $inherited - - $inherited = $null; $SftpAuthenticationType = Get-AdvancedBool $($detail.GetSftpAuthenticationType( [ref] $inherited )) $inherited - - $inherited = $null; $IsInactivityPeriodLimited = Get-AdvancedBool $($detail.IsInactivityPeriodLimited( [ref] $inherited )) $inherited - $InactivityPeriodLimited = $inherited -try { - $inherited = $null; $AllowWorkspaces = Get-AdvancedBool $($detail.GetAllowWorkspaces( [ref] $inherited )) $inherited - $inherited = $null; $AllowWorkspacesOAI = Get-AdvancedBool $($detail.GetAllowWorkspacesOAI( [ref] $inherited )) $inherited -} -catch { - -} - $inherited = $null; $IsPasswordAgeLimited = Get-AdvancedBool $($detail.IsPasswordAgeLimited( [ref] $inherited )) $inherited - $PasswordAgeLimited = $inherited - - $id = $detail.id - #IsInactivityPeriodLimited - #IsPasswordAgeLimited - #properties that ends with '_n' won't be used for checksum - $results += new-object psobject -Property @{ - id = $id; - SiteName = $script:EftSite.Name; - SiteGuid = $SiteGuid; - SettingsTemplate = [String]$script:EftSite.GetUserSettingsLevel($users[$i]); - IsEnabled = $IsEnabled; - Username = $users[$i]; - Email = $detail.Email; - IsUserExpired = $IsUserExpired - ExpirationDate = $ExpirationDate; - IsInactivityPeriodLimited = $IsInactivityPeriodLimited; - InactivityPeriodLimited = $InactivityPeriodLimited; - IsPasswordAgeLimited = $IsPasswordAgeLimited; - PasswordAgeLimited = $PasswordAgeLimited; - HomefolderPath = $detail.GetHomeDirString(); - HomefolderIsRoot = $HomefolderIsRoot; - Homefolder = $Homefolder; - Description = $detail.Description; - FullName = $detail.FullName; - Phone = $detail.Phone; - Fax = $detail.Fax; - Pager = $detail.Pager; - Custom1 = $detail.Custom1; - Custom2 = $detail.Custom2; - Custom3 = $detail.Custom3; - Comments = $detail.Comments; - EnableDiskQuota = $EnableDiskQuota; - MaxSpace = $MaxSpace; - TwoFactorAuthentication = $TwoFactorAuthentication; - IsLocked = $detail.IsLocked ; - - #Connection Settings - FTP = $FTP; - FTPS = $FTPS; - AllowFXP = $AllowFXP; - SftpAuthenticationType = $SftpAuthenticationType; - AllowNoop = $AllowNoop - AllowCOMB = $AllowCOMB ; - AllowXCRC = $AllowXCRC ; - AllowMODEZ = $AllowMODEZ; - LoginMsg = $detail.GetLoginMsg() ; - SSLAuthenticationType = $SSLAuthenticationType; - SFTP = $SFTP ; - ClearHTTP = $ClearHTTP ; - HTTPS = $HTTPS; - AppletEnabled = $AppletEnabled; - AS2Inbound = $AS2Inbound ; - AS2Outbound = $AS2Outbound; - HasMaxSpeed = $HasMaxSpeed; - EnableTimeOut = $EnableTimeOut ; - HasMaxUsers = $HasMaxUsers; - HasMaxIPs = $HasMaxIPs ; - MaxSpeed = $MaxSpeed ; - TimeOut = $TimeOut ; - MaxUsers = $MaxUsers; - MaxIPs = $MaxIPs ; - HasUploadsPerSession = $HasUploadsPerSession; - HasDownloadsPerSession = $HasDownloadsPerSession; - HasMaxUploadSize = $HasMaxUploadSize; - HasMaxDownloadSize = $HasMaxDownloadSize ; - UploadsPerSession = $UploadsPerSession ; - DownloadsPerSession = $DownloadsPerSession ; - MaxUploadSize = $MaxUploadSize ; - MaxDownloadSize = $MaxDownloadSize ; - IPAccessAllowedDefault = $IPAccessAllowedDefault ; - LimitAccessByIP = $LimitAccessByIP ; - - LoginMsgString = $detail.GetLoginMsgString(); - - IsConnected = $details.IsConnected; - UsedSpace = $detail.GetUsedSpace(); - PhysicalHomefolder = [String]$script:EftSite.GetPhysicalPath([String]$detail.GetHomeDirString()); - LastTimeConnected = $detail.LastConnectionTime; - CreationDate = $detail.AccountCreationTime; - LastModification = $detail.LastModificationTime; - AllowWorkspaces = $AllowWorkspaces; - AllowWorkspacesOAI = $AllowWorkspacesOAI; - CheckSum = "" - } - } - - # $results |Sort-Object Username | Format-Table CheckSum, IsUserEnabled, Username, Email, LastTimeConnected, CreationDate, ExpirationDate, LastModification, Homefolder, PhysicalHomefolder -} -try -{ - for ($i = 0 ; $i -le $results.count - 1; $i++) { - $u = $results[$i] - #Concatenate all columns except the mentioned in the ExcludedProperty - $userHash = -join ( $u | Select-Object * -ExcludeProperty SiteName, IsConnected, UsedSpace, PhysicalHomefolder, LastTimeConnected, CreationDate , LastModification, CheckSum) - $userHash = get-filehash -Algorithm SHA1 -InputStream ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($userHash))) | Select-Object -ExpandProperty Hash - $results[$i].CheckSum = $userHash - } -} -catch { - $results[$i].CheckSum = "NA" -} -$results | Sort-Object Username -$script:EftServer.close() - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Users.Get-ODBCPassword.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Users.Get-ODBCPassword.ps1 deleted file mode 100644 index 1397f8d..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Users.Get-ODBCPassword.ps1 +++ /dev/null @@ -1,99 +0,0 @@ -## -## 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 = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "ODBCSite", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password - -) - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null -$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) - - $SiteParameters = $script:EftSite.GetAMParams() - $UserDatabaseConnectionString = $SiteParameters.UserDatabaseConnectionString - if ($UserDatabaseConnectionString -eq "" ) { - continue - } - - $conn = New-Object System.Data.Odbc.OdbcConnection - $conn.ConnectionString = $UserDatabaseConnectionString - $conn.Open() - - $sql = 'SELECT [ID] ,[NAME] ,[PASSWORD] ,[DESCRIPTION] ,[TYPE],[PASSWORD_TYPE] ,[MD_ITER],[OTP_SEED] ,[ANONYMOUS],[ANONYMOUS_EMAIL],[FULLNAME],[EMAIL],[PHONE],[PAGER],[FAX],[COMMENTS],[ENABLED],[HOMEDIRECTORY],[SETTINGSLEVEL] FROM [FTPSERVER_USERS]' - $cmd = New-Object System.Data.Odbc.OdbcCommand($sql, $conn) - - $reader = $cmd.ExecuteReader() - while ($reader.Read()) { - $results += new-object psobject -Property @{ - SiteName = $siteName; - Name = $reader[1]; - Password = $reader[2]; - Description = $reader[3]; - type = $reader[4]; - Password_Type = $reader[5]; - FullName = $reader[10]; - Email = $reader[11]; - Phone = $reader[12]; - Pager = $reader[13]; - Fax = $reader[14]; - Comments = $reader[15]; - Enabled = $reader[16]; - } - } - $reader.Close() - $conn.Close() -} - -$script:EftServer.close() - -$results - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Users.StorageStats.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Users.StorageStats.ps1 deleted file mode 100644 index f0dec45..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Users.StorageStats.ps1 +++ /dev/null @@ -1,201 +0,0 @@ -## -## 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 = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password - -) -function Get-FriendlySize { - param($Bytes) - $sizes = 'Bytes,KB,MB,GB,TB,PB,EB,ZB' -split ',' - for ($i = 0; ($Bytes -ge 1kb) -and - ($i -lt $sizes.Count); $i++) {$Bytes /= 1kb} - $N = 2; if ($i -eq 0) {$N = 0} - "{0:N$($N)} {1}" -f $Bytes, $sizes[$i] -} -function Get-CountFiles { - param( - [Parameter(Mandatory = $true, HelpMessage = "Enter a path")] [string]$path, - [Parameter(Mandatory = $false, HelpMessage = "Search Options: (AllDirectories (default), TopDirectoryOnly)")] [ValidateSet("AllDirectories", "TopDirectoryOnly")] [string]$searchOptions = 'AllDirectories' - ) - $foldersize = 0 - $filecount = 0 - $LastException = "" - - if ((Test-Path $path) -eq $false) { - $LastException = "'$path' not found" - return $foldersize, $filecount, $LastException - } - $directory = Get-item $path -Force - - Write-Progress -Activity "Calculating Stats" -Status "Reading '$($directory.FullName)'" - - $files = $directory | Get-ChildItem -Force -Recurse:$recurse | Where-Object { -not $_.PSIsContainer } - if ( $files ) { - Write-Progress -Activity "Calculating Stats" -Status "Calculating '$($directory.FullName)'" - $output = $files | Measure-Object -Sum -Property Length | Select-Object ` - @{Name = "Path"; Expression = {$directory.FullName}}, - @{Name = "Files"; Expression = {$_.Count; $script:totalcount += $_.Count}}, - @{Name = "Size"; Expression = {$_.Sum; $script:totalbytes += $_.Sum}} - } - else { - $output = "" | Select-Object ` - @{Name = "Path"; Expression = {$directory.FullName}}, - @{Name = "Files"; Expression = {0}}, - @{Name = "Size"; Expression = {0}} - } - return $output.Size, $output.Files, $LastException -} - -$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 "Exception : $_" -ForegroundColor Red - exit -} - -$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) - - $users = $script:EftSite.GetUsers() - $virtualFolders = $script:EftSite.GetVirtualFolderList("") -split "`r`n" - #Removing empty and root path - $virtualFolders = $virtualFolders | Where-Object {$_ -ne "" -and $_ -ne "/"} - - for ($i = 0; $i -lt $users.length; $i++ ) { - Write-Progress -Activity "Processing Users" -status "User '$($users[$i])' $i/$($users.length)" -percentComplete ($i / $users.length * 100) - $FolderSize = 0 - $FileCount = 0 - $virtualFoldersPerUser = 0 - $LastException = "" - $InvalidvirtualFoldersPerUser = 0 - - $detail = $script:EftSite.GetUserSettings($users[$i]) - $expirationDate = New-Object DateTime - $inherited = $null - $detail.GetExpirationDate($expirationDate) | Out-Null - - if ($expirationDate -eq $(New-Object DateTime)) { - $expirationDate = "" - } - $homeFolder = [String]$detail.GetHomeDirString() - $SettingsTemplate = [String]$script:EftSite.GetUserSettingsLevel($users[$i]) - $Email = $detail.Email - $fullName = $detail.FullName - $inherited = $null - $IsUserEnabled = [bool]$detail.GetEnableAccount([ref] $inherited) - $LastConnectionTime = $detail.LastConnectionTime - $physicalHomefolder = "" - - try { - $physicalHomefolder = [String]$script:EftSite.GetPhysicalPath($homeFolder) - } - catch [System.Runtime.InteropServices.COMException] { - switch ($_) { - $MXE_FOLDER_NOT_FOUND { $LastException = "MXE_FOLDER_NOT_FOUND : $_ " } - $MXE_INVALID_FOLDER_NAME { $LastException = "MXE_INVALID_FOLDER_NAME : $_ "} - Default { $LastException = "Exception** : $_"} - } - } - - - $countResults = Get-CountFiles $physicalHomefolder - - if ($null -ne $countResults) { - $FolderSizeFormated = $(Get-FriendlySize $countResults[0] ) - $FolderSize = $countResults[0] - $FileCount = $countResults[1] - if ($countResults[2] -ne "") { - $LastException = "PhysicalHomefolder:" + $countResults[2] + ";" - } - } - - $subFoldersVirtual = $virtualFolders | Where-Object {$_ -like "$($homeFolder)*"} - foreach ($virtualFolder in $subFoldersVirtual ) { - $virtualFoldersPerUser++ - try { - $physicalHomefolder = [String]$script:EftSite.GetPhysicalPath($virtualFolder) - } - catch [System.Runtime.InteropServices.COMException] { - $InvalidvirtualFoldersPerUser++ - switch ($_) { - $MXE_FOLDER_NOT_FOUND { $LastException = $LastException + "MXE_FOLDER_NOT_FOUND : $_ " } - $MXE_INVALID_FOLDER_NAME { $LastException = $LastException + "MXE_INVALID_FOLDER_NAME : $_ "} - Default { $LastException = $LastException + "Exception : $_"} - } - } - $countResultVirtual = Get-CountFiles $physicalHomefolder - if ($null -ne $countResults -and $null -ne $countResultVirtual) { - $FolderSize = $FolderSize + $countResultVirtual[0] - $FolderSizeFormated = $(Get-FriendlySize $FolderSize ) - $FileCount = $FileCount + $countResultVirtual[1] - if ($countResultVirtual[2] -ne "") { - $LastException = $LastException + "Virtual Folder:" + $countResultVirtual[2] + ";" - $InvalidvirtualFoldersPerUser++ - } - } - } - $obj = new-object PSObject - - $obj | add-member -membertype NoteProperty -name "SiteName" -value $SiteName - $obj | add-member -membertype NoteProperty -name "SettingsTemplate" -value $SettingsTemplate - $obj | add-member -membertype NoteProperty -name "Username" -value $users[$i] - $obj | add-member -membertype NoteProperty -name "Email" -value $Email - $obj | add-member -membertype NoteProperty -name "IsEnabled" -value $IsUserEnabled - $obj | add-member -membertype NoteProperty -name "ExpirationDate" -value $ExpirationDate - $obj | add-member -membertype NoteProperty -name "FullName" -value $fullName - $obj | add-member -membertype NoteProperty -name "Homefolder" -value $homefolder - $obj | add-member -membertype NoteProperty -name "LastConnectionTime" -value $LastConnectionTime - $obj | add-member -membertype NoteProperty -name "PhysicalHomefolder" -value $physicalHomefolder - $obj | add-member -membertype NoteProperty -name "Size" -value $FolderSize - $obj | add-member -membertype NoteProperty -name "SizeFormated" -value $FolderSizeFormated - $obj | add-member -membertype NoteProperty -name "Files" -value $FileCount - $obj | add-member -membertype NoteProperty -name "VirtualFolders" -value $virtualFoldersPerUser - $obj | add-member -membertype NoteProperty -name "InvalidVirtualFolders" -value $InvalidvirtualFoldersPerUser - $obj | add-member -membertype NoteProperty -name "Errors" -value $LastException - $results += $obj - } -} -$results diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.VirtualFolders.Export.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.VirtualFolders.Export.ps1 deleted file mode 100644 index 3ccaff6..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.VirtualFolders.Export.ps1 +++ /dev/null @@ -1,119 +0,0 @@ -## -## 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 = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False, HelpMessage = "Validate Physical Path ")] - [switch] $ValidatePath = $false -) -## To Export to CSV use: -## .\EFT.VirtualFolders.Export.ps1 | Export-csv foo.csv -NoTypeInformation -## .\EFT.VirtualFolders.Export.ps1 | Where-Object {$_.Username -eq "rguzman"} | format-table -## .\EFT.VirtualFolders.Export.ps1 | where-object {$_.Username -eq "rguzman" } | export-csv foo.csv -NoTypeInformation - -$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) - $virtualFolders = $script:EftSite.GetVirtualFolderList("") -split "`r`n" - #Removing empty and root path - $virtualFolders = $virtualFolders #| Where-Object {$_ -ne "" -and $_ -ne "/"} - - for ($i = 0; $i -lt $virtualFolders.length; $i++ ) { - if ($virtualFolders[$i] -ne "" -and $virtualFolders[$i] -ne "/") { - - - Write-Progress -Activity "Processing Virtual Folders" -status "Virtual folder $i/$($virtualFolders.length)" -percentComplete ($i / $virtualFolders.length * 100) - $Validpath = "" - try { - $physicalPath = $script:EftSite.GetPhysicalPath($virtualFolders[$i]) - } - 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++ - continue - } - - if ($ValidatePath) { - try { - if (Test-Path $physicalPath) { - $Validpath = "OK" - } - else { - $Validpath = "FOLDER_NOT_FOUND" - } - } - catch { - $Validpath = "ERROR: $_" - } - } - #properties that ends with '_n' won't be used for checksum - $results += new-object psobject -Property @{ - SiteName = $script:EftSite.Name; - VirtualFolder = $virtualFolders[$i]; - PhysicalPath = $physicalPath; - ValidPath = $Validpath; - } - } - } -} -$results | Sort-Object SiteName, VirtualFolder - -$script:EftServer.close() - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.VirtualFolders.Remap.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.VirtualFolders.Remap.ps1 deleted file mode 100644 index f75555a..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.VirtualFolders.Remap.ps1 +++ /dev/null @@ -1,122 +0,0 @@ -## -## 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(SupportsShouldProcess)] -Param( - [Parameter(Position = 0, Mandatory = $false, HelpMessage = "Enter the virtual folder CSV file ")] - [string] $VirtualFolderCsvFile = "VirtualFolders.csv", - - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False )] - [switch]$Quiet = $false -) -if ($VirtualFolderCsvFile -eq "") { - #Uncomment the following to enter paramters for each site - $EFTVirtualFolders = @( - # @{ SiteName = "MySite"; VirtualFolder = "\"; PhysicalPath = "" } - # @{ SiteName = "MySite1"; VirtualFolder = "\"; PhysicalPath = ""} - ) -} -else { - $EFTVirtualFolders = Import-Csv $VirtualFolderCsvFile - # "SiteName","VirtualFolder", "PhysicalPath" -} - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' -$MXE_FOLDER_NOT_FOUND = "MX Error: 82 (00000052)" -$MXE_INVALID_FOLDER_NAME = "MX Error: 97 (00000061)" -$MXE_FOLDER_NOT_EMPTY = "MX Error: 117 (00000075)" - -$MAX_PAD = 100 -$PAD_CHR = "." - -$EFTServer = new-object -ComObject "SFTPCOMInterface.CIServer" - -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $script:EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() - -$SiteList = @{} -for ($j = 0; $j -le $sitesCount - 1; $j++ ) { - $script:EftSite = $script:EftSites.Item($j) - $SiteList.Add($script:EftSite.Name, $script:EftSite.ID) -} - -Write-host "Remapping Virtual Folders:" -$RemapCount = 0 -$errorCount = 0 -foreach ($EFTVirtualFolder in $EFTVirtualFolders) { - try { - $script:EftSite = $script:EftSites.SiteByID($SiteList[$EFTVirtualFolder.SiteName]) - Write-host "Update: [$($EFTVirtualFolder.SiteName)] $($EFTVirtualFolder.VirtualFolder) -> $($EFTVirtualFolder.PhysicalPath)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - - $sw.Restart() - if ($PSCmdlet.ShouldProcess($EFTVirtualFolder.VirtualFolder, 'Remap')) { - $script:EftSite.RemapVirtualFolder($EFTVirtualFolder.VirtualFolder, $EFTVirtualFolder.PhysicalPath) - } - write-Verbose "[$(Get-Date -f $df)] ICISites.RemapVirtualFolder() $($sw.ElapsedMilliseconds )ms" - - $RemapCount++ - Write-host " OK $($sw.ElapsedMilliseconds )ms" -ForegroundColor Green - } - catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_FOLDER_NOT_FOUND { Write-host "MXE_FOLDER_NOT_FOUND : $_ " -ForegroundColor Red } - $MXE_INVALID_FOLDER_NAME { Write-host "MXE_INVALID_FOLDER_NAME : $_ " -ForegroundColor Red } - $MXE_FOLDER_NOT_EMPTY { Write-host "MXE_FOLDER_NOT_EMPTY : $_ " -ForegroundColor Red } - Default { Write-host "Exception : $_" -ForegroundColor Red} - } - $errorCount++ - continue - } -} -$script:EftServer.close() - -Write-host " Updated: " -NoNewline -Write-host "$RemapCount " -NoNewline -ForegroundColor green -Write-host "Errors: "-NoNewline -Write-host "$errorCount " -ForegroundColor red -Write-host " " - - - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.VirtualFolders.Remove.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.VirtualFolders.Remove.ps1 deleted file mode 100644 index 954937e..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.VirtualFolders.Remove.ps1 +++ /dev/null @@ -1,126 +0,0 @@ -## -## 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(SupportsShouldProcess)] -Param( - [Parameter(Position = 0, Mandatory = $false, HelpMessage = "Enter the virtual folder CSV file ")] - [string] $VirtualFolderCsvFile = "VirtualFolders.csv", - - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False )] - [switch]$Quiet = $false -) -if ($VirtualFolderCsvFile -eq "") { - #Uncomment the following to enter paramters for each site - $EFTVirtualFolders = @( - # @{ SiteName = "MySite"; VirtualFolder = "\"; PhysicalPath = "" } - # @{ SiteName = "MySite1"; VirtualFolder = "\"; PhysicalPath = ""} - ) -} -else { - $EFTVirtualFolders = Import-Csv $VirtualFolderCsvFile - # "CheckSum", "SiteName",PhysicalPath", "VirtualFolder", "NewVirtualFolder" -} - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' -$MXE_FOLDER_NOT_FOUND = "MX Error: 82 (00000052)" -$MXE_INVALID_FOLDER_NAME = "MX Error: 97 (00000061)" -$MXE_FOLDER_NOT_EMPTY = "MX Error: 117 (00000075)" - -$MAX_PAD = 100 -$PAD_CHR = "." - -$script:EftServer = new-object -ComObject "SFTPCOMInterface.CIServer" -Write-host "Connecting EFT Server TCP://$EFTAdminUsername@$EFTAdminHostname : $EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline -try { - $script:EftServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) -} -catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} -Write-host " OK" -ForegroundColor Green - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() -$SiteList = @{} -for ($j = 0; $j -le $sitesCount - 1; $j++ ) { - $script:EftSite = $script:EftSites.Item($j) - $SiteList.Add($script:EftSite.Name, $script:EftSite.ID) -} - -Write-host "Update Virtual Folders:" -$RemoveCount = 0 -$errorCount = 0 - -foreach ($EFTVirtualFolder in $EFTVirtualFolders) { - try { - $script:EftSite = $script:EftSites.SiteByID($SiteList[$EFTVirtualFolder.SiteName]) - if ([string]::IsNullOrEmpty($EFTVirtualFolder.VirtualFolder) -eq $false) { - # Rename and Remap - Write-host "Remove: [$($EFTVirtualFolder.SiteName)] $($EFTVirtualFolder.VirtualFolder) ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - - $sw.Restart() - if ($PSCmdlet.ShouldProcess($EFTVirtualFolder.VirtualFolder, 'RemoveFolder')) { - $script:EftSite.RemoveFolder($EFTVirtualFolder.VirtualFolder) - } - write-Verbose "[$(Get-Date -f $df)] ICISites.RemoveFolder() $($swv.ElapsedMilliseconds )ms" - - $RemoveCount++ - Write-host " OK $($sw.ElapsedMilliseconds )ms" -ForegroundColor Green - } - else { - #Ignore - Write-host "Ignore: $($EFTVirtualFolder.VirtualFolder)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - Write-host " OK $($sw.ElapsedMilliseconds )ms" -ForegroundColor Green - } - } - catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_FOLDER_NOT_FOUND { Write-host "MXE_FOLDER_NOT_FOUND : $_ " -ForegroundColor Red } - $MXE_INVALID_FOLDER_NAME { Write-host "MXE_INVALID_FOLDER_NAME : $_ " -ForegroundColor Red } - $MXE_FOLDER_NOT_EMPTY { Write-host "MXE_FOLDER_NOT_EMPTY : $_ " -ForegroundColor Red } - Default { Write-host "Exception : $_" -ForegroundColor Red} - } - $errorCount++ - continue - } -} -Write-host " Removed: " -NoNewline -Write-host "$RemoveCount " -NoNewline -ForegroundColor green -Write-host "Errors: "-NoNewline -Write-host "$errorCount " -ForegroundColor red -Write-host " " - -$script:EftServer.close() - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.VirtualFolders.Rename.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.VirtualFolders.Rename.ps1 deleted file mode 100644 index 47d82f8..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.VirtualFolders.Rename.ps1 +++ /dev/null @@ -1,135 +0,0 @@ -## -## 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(SupportsShouldProcess)] -Param( - [Parameter(Position = 0, Mandatory = $false, HelpMessage = "Enter the virtual folder CSV file ")] - [string] $VirtualFolderCsvFile = "VirtualFolders.csv", - - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False )] - [switch]$Quiet = $false -) -if ($VirtualFolderCsvFile -eq "") { - #Uncomment the following to enter paramters for each site - $EFTVirtualFolders = @( - # @{ SiteName = "MySite"; VirtualFolder = "\"; PhysicalPath = "" } - # @{ SiteName = "MySite1"; VirtualFolder = "\"; PhysicalPath = ""} - ) -} -else { - $EFTVirtualFolders = Import-Csv $VirtualFolderCsvFile - # "CheckSum", "SiteName",PhysicalPath", "VirtualFolder", "NewVirtualFolder" -} - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - -$sw = [Diagnostics.Stopwatch]::StartNew() -$swv = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' -$MXE_FOLDER_NOT_FOUND = "MX Error: 82 (00000052)" -$MXE_INVALID_FOLDER_NAME = "MX Error: 97 (00000061)" -$MXE_FOLDER_NOT_EMPTY = "MX Error: 117 (00000075)" - -$MAX_PAD = 100 -$PAD_CHR = "." - -$script:EftServer = new-object -ComObject "SFTPCOMInterface.CIServer" -Write-host "Connecting EFT Server TCP://$EFTAdminUsername@$EFTAdminHostname : $EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline -try { - $script:EftServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) -} -catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} -Write-host " OK" -ForegroundColor Green - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() -$SiteList = @{} -for ($j = 0; $j -le $sitesCount - 1; $j++ ) { - $script:EftSite = $script:EftSites.Item($j) - $SiteList.Add($script:EftSite.Name, $script:EftSite.ID) -} - -Write-host "Update Virtual Folders:" -$RenameCount = 0 -$errorCount = 0 - -foreach ($EFTVirtualFolder in $EFTVirtualFolders) { - try { - $script:EftSite = $script:EftSites.SiteByID($SiteList[$EFTVirtualFolder.SiteName]) - if ([string]::IsNullOrEmpty($EFTVirtualFolder.NewVirtualFolder) -eq $false -and [string]::IsNullOrEmpty($EFTVirtualFolder.PhysicalPath) -eq $false) { - # Rename and Remap - Write-host "Rename: [$($EFTVirtualFolder.SiteName)] $($EFTVirtualFolder.VirtualFolder) -> $($EFTVirtualFolder.NewVirtualFolder)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - - $sw.Restart() - - $swv.Restart() - if ($PSCmdlet.ShouldProcess($EFTVirtualFolder.VirtualFolder, 'RemoveFolder')) { - $script:EftSite.RemoveFolder($EFTVirtualFolder.VirtualFolder) - } - write-Verbose "[$(Get-Date -f $df)] ICISites.RemoveFolder() $($swv.ElapsedMilliseconds )ms" - - $swv.Restart() - if ($PSCmdlet.ShouldProcess($EFTVirtualFolder.VirtualFolder, 'RemapVirtualFolder')) { - $script:EftSite.RemapVirtualFolder($EFTVirtualFolder.NewVirtualFolder, $EFTVirtualFolder.PhysicalPath) - } - write-Verbose "[$(Get-Date -f $df)] ICISites.RemoveFolder() $($swv.ElapsedMilliseconds )ms" - - $RenameCount++ - Write-host " OK $($sw.ElapsedMilliseconds )ms" -ForegroundColor Green - } - else { - #Ignore - Write-host "Ignore: $($EFTVirtualFolder.VirtualFolder)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - Write-host " OK $($sw.ElapsedMilliseconds )ms" -ForegroundColor Green - } - } - catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_FOLDER_NOT_FOUND { Write-host "MXE_FOLDER_NOT_FOUND : $_ " -ForegroundColor Red } - $MXE_INVALID_FOLDER_NAME { Write-host "MXE_INVALID_FOLDER_NAME : $_ " -ForegroundColor Red } - $MXE_FOLDER_NOT_EMPTY { Write-host "MXE_FOLDER_NOT_EMPTY : $_ " -ForegroundColor Red } - Default { Write-host "Exception : $_" -ForegroundColor Red} - } - $errorCount++ - continue - } -} -Write-host " Renamed: " -NoNewline -Write-host "$RenameCount " -NoNewline -ForegroundColor green -Write-host "Errors: "-NoNewline -Write-host "$errorCount " -ForegroundColor red -Write-host " " - -$script:EftServer.close() - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.VirtualFolders.Test-Benchmark.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.VirtualFolders.Test-Benchmark.ps1 deleted file mode 100644 index c9760e2..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.VirtualFolders.Test-Benchmark.ps1 +++ /dev/null @@ -1,72 +0,0 @@ -$EFTAdminHostname = "localhost" -$EFTAdminPort = 1100 -$EFTAdminAuthType = 0 # 0: EFT Login, 1: Windows Login, 2: Network Logon -$EFTAdminUsername = "admin" -$Password = "Super2003" -$EFTSiteName = "MySite" -$VirtualPath = "/*" # Use * as wild card - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null -$script:EftServer = new-object -ComObject "SFTPCOMInterface.CIServer" -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' - -try { - Write-host "Connecting to EFT" - $script:EftServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " Connected " -ForegroundColor Green -} -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() - -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 - } - } - $sw.Restart() - Write-host "[$(Get-Date -f $df)] Calling ICISites.GetVirtualFolderList() $($sw.ElapsedMilliseconds )ms" -ForegroundColor Yellow - $virtualFolders = $script:EftSite.GetVirtualFolderList("") -split "`r`n" - Write-host "[$(Get-Date -f $df)] ICISites.GetVirtualFolderList() $($sw.ElapsedMilliseconds )ms" -ForegroundColor Yellow - Write-host " $($virtualFolders.length) virtual folders found." -ForegroundColor Green - - #Removing empty and root path - $virtualFolders = $virtualFolders #| Where-Object {$_ -ne "" -and $_ -ne "/"} - - $sw.Restart() - $count = 0 - Write-host "[$(Get-Date -f $df)] Calling ICISites.GetPhysicalPath() $($sw.ElapsedMilliseconds )ms" -ForegroundColor Yellow - for ($i = 0; $i -lt $virtualFolders.length; $i++ ) { - if ($virtualFolders[$i] -ne "" -and $virtualFolders[$i] -ne "/") { - if ($virtualFolders[$i] -like $VirtualPath){ - $count += 1 - try { - $physicalPath = $script:EftSite.GetPhysicalPath($virtualFolders[$i]) - } - catch [System.Runtime.InteropServices.COMException] { - continue - } - } - } - } - $sw.Restart() - Write-host "[$(Get-Date -f $df)] ICISites.GetPhysicalPath() $($sw.ElapsedMilliseconds )ms" -ForegroundColor Yellow - Write-host " called GetPhysicalPath() for $count virtual folders under '$VirtualPath' ." -ForegroundColor Green -} - -$script:EftServer.close() - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.Step1_CreateFolder_and_Files.vbs b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.Step1_CreateFolder_and_Files.vbs deleted file mode 100644 index 2ac9aba..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.Step1_CreateFolder_and_Files.vbs +++ /dev/null @@ -1,29 +0,0 @@ -Dim WshShell, currDir, oFSO -Set WshShell = WScript.CreateObject("WScript.Shell") -'WScript.Echo WshShell.CurrentDirectory -currDir = WshShell.CurrentDirectory - -Set oFSO = CreateObject("Scripting.FileSystemObject") -' Create a new folders -oFSO.CreateFolder currDir & "\EFTClient" -oFSO.CreateFolder currDir & "\EFTClient\Account" -oFSO.CreateFolder currDir & "\EFTClient\Shared" -oFSO.CreateFolder currDir & "\EFTClient\Shared\images" -oFSO.CreateFolder currDir & "\EFTClient\jument" -oFSO.CreateFolder currDir & "\EFTClient\jument\ng-views" -oFSO.CreateFolder currDir & "\EFTClient\jument\images" -oFSO.CreateFolder currDir & "\EFTClient\jument\styles" -oFSO.CreateFolder currDir & "\EFTClient\jument\styles\defaults" -oFSO.CreateFolder currDir & "\EFTClient\jument\styles\defaults\styles" - - - -' Copy a file into the new folder -' Note that the destination folder path must end with a path separator (\) -oFSO.CopyFile currDir & "\public\EFTClient\Account\Log*n.htm", currDir & "\EFTClient\Account" -oFSO.CopyFile currDir & "\public\EFTClient\jument\styles\*.css", currDir & "\EFTClient\jument\styles" -oFSO.CopyFile currDir & "\public\EFTClient\jument\styles\defaults\styles\*.css", currDir & "\EFTClient\jument\styles\defaults\styles" -oFSO.CopyFile currDir & "\public\EFTClient\jument\ng-views\v.head*.html", currDir & "\EFTClient\jument\ng-views" -oFSO.CopyFile currDir & "\public\EFTClient\Shared\*.css", currDir & "\EFTClient\Shared" - -wscript.echo "Script Completed" \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.Step2_ReplaceWTC_Colors.vbs b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.Step2_ReplaceWTC_Colors.vbs deleted file mode 100644 index 09427df..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.Step2_ReplaceWTC_Colors.vbs +++ /dev/null @@ -1,29 +0,0 @@ -Dim varPSCmd, varPSAct, varPS -Dim strOldValue, strNewValue, exclude -Dim currDir, dirEFTClient -Set objShell = CreateObject("WScript.Shell") -currDir = objShell.CurrentDirectory -dirEFTClient = currDir & "\EFTClient" - -'MsgBox dirEFTClient - -' WTC Option Default Main Three colors -'--------------------------------------- -'WTC Main Layout: #00A8D4 -'On click Button: #0B76BB -'Gray button: #485156 - -' Use URL to verify HTML colors https://html-color-codes.info - - -'Find and Replace Values -strOldValue = "#0B76BB" -strNewValue = "#0DA308" - -'Vbscript is using Powershell's engine to search and replace multiple files -varPSCmd = "powershell -noexit -command" -varPSAct = "Get-ChildItem " & dirEFTClient & "\*.* -Recurse | ForEach {(Get-Content $_ | ForEach { $_ -replace '" & strOldValue & "', '" & strNewValue& "' }) | Set-Content $_}" -varPS = varPSCmd & " " & varPSAct -objShell.run(varPS) - -wscript.echo "Script Completed" \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.Step3_(Optional)_Clear_byGlobalscapeLogo.vbs b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.Step3_(Optional)_Clear_byGlobalscapeLogo.vbs deleted file mode 100644 index cd0e213..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.Step3_(Optional)_Clear_byGlobalscapeLogo.vbs +++ /dev/null @@ -1,32 +0,0 @@ -Const ForReading = 1 - -Const ForWriting = 2 - -Dim WshShell, objFSO, objFile -Dim strText, strNewText - -Set WshShell = WScript.CreateObject("WScript.Shell") -WScript.Echo WshShell.CurrentDirectory -currDir = WshShell.CurrentDirectory - -Set objFSO = CreateObject("Scripting.FileSystemObject") - -Set objFile = objFSO.OpenTextFile(currDir & "\EFTClient\jument\styles\theme_override.css", ForReading) - - -strText = objFile.ReadAll - -objFile.Close - -strNewText = Replace(strText, "../images/GSB-Logo.png", "") - - -Set objFile = objFSO.OpenTextFile(currDir & "\EFTClient\jument\styles\theme_override.css", ForWriting) - -objFile.WriteLine strNewText - -msgbox "Done!" - -objFile.Close - - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.Step4_(Optional)_ClearLinks_Forgot_UsrnPwd_ChgPwd.vbs b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.Step4_(Optional)_ClearLinks_Forgot_UsrnPwd_ChgPwd.vbs deleted file mode 100644 index cbcd538..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.Step4_(Optional)_ClearLinks_Forgot_UsrnPwd_ChgPwd.vbs +++ /dev/null @@ -1,61 +0,0 @@ -Const ForReading = 1 - -Const ForWriting = 2 - -Dim WshShell, objFSO, objFile -Dim strText, strNewText, objFile2 - -Set WshShell = WScript.CreateObject("WScript.Shell") - -currDir = WshShell.CurrentDirectory - -Set objFSO = CreateObject("Scripting.FileSystemObject") - -Set objFile = objFSO.OpenTextFile(currDir & "\EFTClient\Account\Login.htm", ForReading) - -strText = objFile.ReadAll - -objFile.Close - -Dim strFind -strFindA1 = "" - -strFindB2 = "Forgot Password" -strReplaceB2 = strFindB2 & "-->" - -strNewText1 = Replace(strText, strFindA1, strReplaceA1) -strNewText2 = Replace(strNewText1, strFindB1, strReplaceB1) -strNewText3 = Replace(strNewText2, strFindB2, strReplaceB2) - -Set objFile = objFSO.OpenTextFile(currDir & "\EFTClient\Account\Login.htm", ForWriting) - -objFile.WriteLine strNewText3 -objFile.Close - -'----------------------------------------------------------------------------------------------------- - -Dim strTextP, strNewText4 - -set objFile = objFSO.OpenTextFile(currDir & "\EFTClient\jument\ng-views\v.header.html", ForReading) - -strTextP = objFile.ReadAll - -objFile.Close - -Dim strFindP, strReplaceP -strFindP = "
  • " - -strNewText4 = Replace(strTextP, strFindP,"") - -Set objFile = objFSO.OpenTextFile(currDir & "\EFTClient\jument\ng-views\v.header.html", ForWriting) - -objFile.WriteLine strNewText4 - -msgbox "Done!" - -objFile.Close \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.docx b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.docx deleted file mode 100644 index 14e5a00..0000000 Binary files a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.docx and /dev/null differ diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WTC.ReBrandingTool.ps1 deleted file mode 100644 index e69de29..0000000 diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WebAdminAPI.TestAuthentication.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WebAdminAPI.TestAuthentication.ps1 deleted file mode 100644 index 2d5baad..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.WebAdminAPI.TestAuthentication.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -[CmdletBinding()] -Param( - [Parameter(Position = 1, Mandatory = $false, HelpMessage = "Enter a host name or IP address")] - [String] $EFTHost = "https://localhost:4450", - - [Parameter(Position = 2, Mandatory = $false, HelpMessage = "Enter login")] - [String] $EFTAdminUsername = "admin", - - [Parameter(Position = 3, Mandatory = $false, HelpMessage = "Enter password")] - [String] $Password = "Super2003" -) -$url = "$EFTHost/admin/v1/authentication" -$webclient = New-Object "System.Net.WebClient" -$payload = "{""userName"":""$($EFTAdminUsername)"", ""password"":""$($Password)"",""authType"":""EFT""}" -$webclient.Headers.Add("Accept", "application/json"); -write-host "POST $url" -write-host "BODY:" -$payload -[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true } -try { - $output = $webclient.Uploadstring($url,$payload) - [System.Net.ServicePointManager]::ServerCertificateValidationCallback = $null -} -catch { - Write-Error "Error Calling EFT Web Service $_" -} -write-host "Result: " -$output \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Workspaces.Export.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Workspaces.Export.ps1 deleted file mode 100644 index 13b07a6..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Workspaces.Export.ps1 +++ /dev/null @@ -1,153 +0,0 @@ -## -## 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 = 0, Mandatory = $False, HelpMessage = "Enter a Folder Path")] - [String] $Path = "/", - - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter the name of the Site, leave empty to process all sites")] - [String] $EFTSiteName = "", - - [Parameter(Position = 4, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False, HelpMessage = "Validate Physical Path ")] - [switch] $ValidatePath = $false -) -## To Export to CSV use: -## .\EFT.Workspaces.Export.ps1 | Export-csv foo.csv -NoTypeInformation -## .\EFT.Workspaces.Export.ps1 | Where-Object {$_.Username -eq "rguzman"} | format-table -## .\EFT.Workspaces.Export.ps1 | where-object {$_.Username -eq "rguzman" } | export-csv foo.csv -NoTypeInformation -Function PermissionsToInt($permission) { - - $permissionAsInt = 0 - - if ($null -ne $permission) { - if ($permission.DownloadFile -eq $true) { $permissionAsInt += 1 } - if ($permission.UploadFile -eq $true) { $permissionAsInt += 2 } - if ($permission.DeleteFile -eq $true) { $permissionAsInt += 4 } - if ($permission.RenameFileFolder -eq $true) { $permissionAsInt += 8 } - if ($permission.CreateFolder -eq $true) { $permissionAsInt += 16 } - if ($permission.DeleteFolder -eq $true) { $permissionAsInt += 32 } - } - return $permissionAsInt -} - -function GetWorkspace ($path){ - $results = @() - Write-Progress -Activity "Scanning virtual folders for Workspaces" -status " $path " - $paths = $script:EftSite.GetFolderList($path) - $folderList = $paths.Split([string[]]"`r`n", "RemoveEmptyEntries") - foreach ($subFolder in $folderList) { - $results += GetWorkspace "$path$subFolder/" - } - - $TimeCreated = "" - $Owner = "" - $Name = "" - $ExpireTime = "" - $isTransactional = $false - $isPrivate = $false - - $Participants = @() - try { - - $WorkspaceGUID = $script:EftSite.GetWorkspaceGUID($path) - $Workspace = $script:EftSite.GetWorkspace($WorkspaceGUID) - - foreach ($participant in $Workspace.ParticipantList ) { - - $permision = $Workspace.GetParticipantPermissions($participant) - $permisionValue = PermissionsToInt $permision - #$perm = [PSCustomObject] @{ - # Participant = $participant; - # PermisionValue = $permisionValue - #} - - $Participants += "$participant=$permisionValue" - } - $TimeCreated = $Workspace.TimeCreated - $Owner = $Workspace.Owner - $Name = $Workspace.Name - $IsTransactional = $Workspace.isTransactional - $IsPrivate = $Workspace.isPrivate - $ExpireTime = $Workspace.ExpireTime - $ParticipantList = ($Participants -join ";") - return New-Object psobject -Property @{ - SiteName = $script:EftSite.Name; - WorkspaceGUID = $WorkspaceGUID; - Path = $path; - ExpireTime = $ExpireTime; - IsPrivate = $IsPrivate ; - IsTransactional = $IsTransactional ; - Name = $Name ; - Owner = $Owner ; - ParticipantList = $ParticipantList; - TimeCreated = $TimeCreated ; - } - } - catch [System.Runtime.InteropServices.COMException] { - Write-Verbose "Exception: $_" - } - return $results - -} -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - -$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) - - - $results += GetWorkspace $Path - -} -$results | Sort-Object SiteName, Path - -$script:EftServer.close() - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Workspaces.Import.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Workspaces.Import.ps1 deleted file mode 100644 index 84aaddf..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Workspaces.Import.ps1 +++ /dev/null @@ -1,152 +0,0 @@ -## -## 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(SupportsShouldProcess)] -Param( - [Parameter(Position = 0, Mandatory = $false, HelpMessage = "Enter the workspaces CSV file ")] - [string] $WorkspacesCsvFile = "ws.csv", - - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTAdminHostname = "localhost", - - [Parameter(Position = 2, Mandatory = $False, HelpMessage = "Enter a port where EFT Server is listening for admin connections")] - [int] [ValidateRange(0, 65535)] $EFTAdminPort = 1100, - - [Parameter(Position = 3, 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 = 5, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTAdminUsername, - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password, - - [Parameter(Position = 7, Mandatory = $False )] - [switch]$Quiet = $false -) -Function IntToPermissions($permissionAsInt, $permission) { - - if ($null -ne $permission ) { - $permission.DownloadFile = [bool](($permissionAsInt -band 1) -eq 1) - $permission.UploadFile = [bool](($permissionAsInt -band 2) -eq 2) - $permission.DeleteFile = [bool](($permissionAsInt -band 4) -eq 4) - $permission.RenameFileFolder = [bool](($permissionAsInt -band 8) -eq 8) - $permission.CreateFolder = [bool](($permissionAsInt -band 16) -eq 16) - $permission.DeleteFolder = [bool](($permissionAsInt -band 32) -eq 32) - } - return $permission -} - -if ($WorkspacesCsvFile -eq "") { - #Uncomment the following to enter paramters for each site - # $EFTWorkspaces = @( - # @{ SiteName = "MySite"; Path = "\"; Client= "" IsInherited = "" ; InheritedFrom =""; Permissions = "" } - # @{ SiteName = "MySite"; Path = "\"; Client= "" IsInherited = "" ; InheritedFrom =""; Permissions = "" } - #) -} -else { - $EFTWorkspaces = Import-Csv $WorkspacesCsvFile - # "SiteName","Path", "Client","Permissions",IsInherited","InheritedFrom" -} - -$script:EftServer = $null -$script:EftSites = $null -$script:EftSite = $null - -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' -$MXE_FOLDER_NOT_FOUND = "MX Error: 82 (00000052)" -$MXE_INVALID_FOLDER_NAME = "MX Error: 97 (00000061)" -$MXE_FOLDER_NOT_EMPTY = "MX Error: 117 (00000075)" - -$MAX_PAD = 100 -$PAD_CHR = "." - -$EFTServer = new-object -ComObject "SFTPCOMInterface.CIServer" - -try { - Write-host "Connecting EFT Server : $EFTAdminUsername@$($EFTAdminHostname):$EFTAdminPort ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $script:EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $Password) - Write-host " OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Green -} -catch { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - Write-host "Exception : $_" -ForegroundColor Red - exit -} - -$script:EftSites = $script:EftServer.Sites() -$sitesCount = $script:EftSites.Count() - -$SiteList = @{} -for ($j = 0; $j -le $sitesCount - 1; $j++ ) { - $script:EftSite = $script:EftSites.Item($j) - $SiteList.Add($script:EftSite.Name, $script:EftSite.ID) -} - -Write-host "Importing Workspaces:" -$Imported = 0 -$errorCount = 0 -foreach ($EFTWorkspace in $EFTWorkspaces) { - try { - $script:EftSite = $script:EftSites.SiteByID($SiteList[$EFTWorkspace.SiteName]) - $workspace = New-Object -ComObject "SFTPCOMInterface.CIWorkspace" - - $ParticipantList = $EFTWorkspace.ParticipantList -split ";" - - $workspace.SetWorkspace - - foreach ($Participant in $ParticipantList) { - $participantRow = $Participant -split "=" - $workspace.AddParticipant($participantRow[0]) - - $permission = New-Object -ComObject "SFTPCOMInterface.CIWorkspacePermissions" - IntToPermissions $permission $participantRow[1] - $workspace.SetParticipantPermissions($participantRow[0], $permission ) - } - - - - $folderPath = $EFTWorkspace.Path - $permissionsInherited = [bool]::Parse($EFTWorkspace.IsInherited) - if (!$permissionsInherited) { - Write-host "Importing: [$($EFTWorkspace.Name)] $($EFTWorkspace.Path) on $folderPath ->$requestedPermissionsAsInt".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - $permission = IntToPermissions $requestedPermissionsAsInt $script:EftSite.GetBlankPermission($folderPath, $EFTWorkspace.Client) - $script:EftSite.SetPermission($permission, $false) - $Imported++ - Write-host " OK $($sw.ElapsedMilliseconds )ms" -ForegroundColor Green - } - } - catch [System.Runtime.InteropServices.COMException] { - Write-host " ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor Red - switch ($_) { - $MXE_FOLDER_NOT_FOUND { Write-host "MXE_FOLDER_NOT_FOUND : $_ " -ForegroundColor Red } - $MXE_INVALID_FOLDER_NAME { Write-host "MXE_INVALID_FOLDER_NAME : $_ " -ForegroundColor Red } - $MXE_FOLDER_NOT_EMPTY { Write-host "MXE_FOLDER_NOT_EMPTY : $_ " -ForegroundColor Red } - Default { Write-host "Exception : $_" -ForegroundColor Red} - } - $errorCount++ - continue - } -} -$script:EftServer.close() - -Write-host " Imported: " -NoNewline -Write-host "$Imported " -NoNewline -ForegroundColor green -Write-host "Errors: "-NoNewline -Write-host "$errorCount " -ForegroundColor red -Write-host " " - - - -$script:EftSite = $null -$script:EftSites = $null -$script:EftServer = $null - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Workspaces.Set-SiteID.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Workspaces.Set-SiteID.ps1 deleted file mode 100644 index 4abe5e1..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFT.Workspaces.Set-SiteID.ps1 +++ /dev/null @@ -1,153 +0,0 @@ -## -## 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. -## Must be run as PowerShell 32 bits -[CmdletBinding()] -Param( - [Parameter(Position = 1, Mandatory = $true, HelpMessage = "Enter a workspace db file")] - [String] $WorkspacesDbFile = "Workspaces.db", - - [Parameter(Position = 8, Mandatory = $true, HelpMessage = "Old Site GUID")] - [String] $OldSiteGUID = "47c4205a-2c8a-4b85-b7ee-b3979c89ffcd", - - [Parameter(Position = 9, Mandatory = $true, HelpMessage = "New Site GUID")] - [String] $NewSiteGUID = "2f28c3ea-5875-4ebc-af9a-83ba4c0c9b6c" -) - -Write-Host "******* EFT EFT.Workspaces.Set-SiteID.ps1 SCRIPT 1.0 *************************************************" -ForegroundColor Yellow -if ($Quiet -eq $false) { - - Write-Host " WARNING NOTES:" -ForegroundColor Yellow - Write-Host " Patch Workspaces.db script will update all site Id references from workspaces.db to the new site Id" -ForegroundColor Yellow - Write-Host " this process MUST be used with a offline copy of Workspaces.db, DON'T patch an online Workspaces.db used by EFT. EFT mantains a lock on the db file" -ForegroundColor Yellow - Write-Host " NOTES:" -ForegroundColor Yellow - Write-Host " > Test this process first against to a non-production environment or a copy of Workspaces.db " -ForegroundColor Yellow - Write-Host " > Backup your EFT Server configuration and original Workspaces DB files " -ForegroundColor Yellow - Write-Host " > Stop and Start EFT before and after replacing Workspaces.db file" -ForegroundColor Yellow - Write-Host " > Communicate end users about the outage" -ForegroundColor Yellow - Write-Host "******************************************************************************" -ForegroundColor Yellow -} -# OldSiteGUID: 47c4205a-2c8a-4b85-b7ee-b3979c89ffcd -# NewSiteGUID: 2f28c3ea-5875-4ebc-af9a-83ba4c0c9b6c - - -# .\EFT.Workspaces.Set-SiteID.ps1 -WorkspacesDbFile .\workspaces.db -OldSiteGUID 'e9dac990-1c04-4663-9394-307bcfe014e7' -NewSiteGUID '3f3381a9-a6bb-4f8c-94c6-8fd3e705e1aa' -Add-Type -Path "System.Data.SQLite.dll" -$WorkspacesDbFile = Resolve-Path $WorkspacesDbFile - -$tempdbFile = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetTempFileName()) -$tempdbFile = "$tempdbFile.db" - -if ((Test-Path -Path $tempdbFile )) { - Remove-Item $tempdbFile | Out-Null -} - -try { - Copy-Item $WorkspacesDbFile $tempdbFile | Out-Null -} -catch { - Write-Host "ERROR: $_" -ForegroundColor red - exit -} -$tempdbFile = Resolve-Path $tempdbFile -$conn = New-Object -TypeName System.Data.SQLite.SQLiteConnection -$conn.ConnectionString = "Data Source=$tempdbFile" -$conn.Open() -$command = $conn.CreateCommand() -$command.Parameters.Clear() -$NewSiteGUIDLiteral = [guid]::new($NewSiteGUID).ToString('N').ToUpper() -$OldSiteGUIDLiteral = [guid]::new($OldSiteGUID).ToString('N').ToUpper() -try { - Write-Host "Validating:" - #Make sure new site guid doesn't exist already - $command.CommandText = "Select count(*) from site where hex(id) = @id" - $command.Parameters.Clear() - $null = $command.Parameters.AddWithValue("@id", $NewSiteGUIDLiteral); - $Count = [Int32]$command.ExecuteScalar() - if ($Count -ne 0 ) { - Write-Host " Error new site id '$OldSiteGUID' was found already in '$WorkspacesDbFile. perhaps patch has been already applied." -ForegroundColor red - Exit - } - Write-Host " > $NewSiteGUID not found in site table" - - #Make sure old site guid exist - $command.CommandText = "Select count(*) from site where hex(id) = @id" - $command.Parameters.Clear() - $null = $command.Parameters.AddWithValue("@id", $OldSiteGUIDLiteral); - $Count = [Int32]$command.ExecuteScalar() - if ($Count -ne 1 ) { - Write-Host " Error old site id '$OldSiteGUID' not found in '$WorkspacesDbFile." -ForegroundColor red - Exit - } - Write-Host " > $OldSiteGUID found in site table" - - Write-Host "Clonning old site id to new site id:" - $command.CommandText = "CREATE TABLE site_temp AS SELECT * FROM site" - $command.Parameters.Clear() - $Count = [Int32]$command.ExecuteNonQuery() - Write-Host " > site_Temp created from site table " - - $command.CommandText = "DELETE FROM site_temp where hex(id) <> @id" - $command.Parameters.Clear() - $null = $command.Parameters.AddWithValue("@id", $OldSiteGUIDLiteral) - $Count = [Int32]$command.ExecuteNonQuery() - Write-Host " > $Count rows deleted from site_temp " - - $command.CommandText = "UPDATE site_temp set id = x'$NewSiteGUIDLiteral'" - $command.Parameters.Clear() - $Count = [Int32]$command.ExecuteNonQuery() - Write-Host " > $Count rows updated from site_temp " - - $command.CommandText = "INSERT INTO site SELECT * FROM site_temp" - $command.Parameters.Clear() - $Count = [Int32]$command.ExecuteNonQuery() - Write-Host " > $Count rows inserted from site_temp " - - $command.CommandText = "DROP TABLE site_temp" - $command.Parameters.Clear() - $Count = [Int32]$command.ExecuteNonQuery() - Write-Host " > site_temp table removed" - - Write-Host "Site id '$OldSiteGUID' clonned to '$NewSiteGUID' successfuly." - - - Write-Host "Updating tables references to site id to new site id:" - # Updating Emails table to the new site id - $command.CommandText = "Update Email Set site = x'$NewSiteGUIDLiteral' where hex(site) = @OldSiteGuid" - $command.Parameters.Clear() - $null = $command.Parameters.AddWithValue("@OldSiteGuid", $OldSiteGUIDLiteral) - $Count = [Int32]$command.ExecuteNonQuery() - Write-Host " > Email: '$count' rows has been updated " - - #Updating Workspace table to the new site id - $command.CommandText = "Update Workspace Set site = x'$NewSiteGUIDLiteral' where hex(site) = @OldSiteGuid" - $command.Parameters.Clear() - $null = $command.Parameters.AddWithValue("@OldSiteGuid", $OldSiteGUIDLiteral); - $Count = [Int32]$command.ExecuteNonQuery() - Write-Host " > Workspaces: '$count' rows has been updated" - - Write-Host "Removing old site id:" - $command.CommandText = "delete from site where hex(id) = @id" - $command.Parameters.Clear() - $null = $command.Parameters.AddWithValue("@id",$OldSiteGUIDLiteral); - $Count = [Int32]$command.ExecuteNonQuery() - Write-Host " > Site: '$count' rows has been deleted" - -} -catch { - Write-Host "ERROR: $_" -ForegroundColor red -} -finally { - # Release all objects used by sqlite, so the file is closed propertly and deleted - $conn.Close() - $conn.Dispose() - $command.Dispose() - mv $tempdbFile $WorkspacesDbFile -Force -} - - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFTBestPractices.md b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFTBestPractices.md deleted file mode 100644 index 2a54fa9..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFTBestPractices.md +++ /dev/null @@ -1,8 +0,0 @@ -## Folders Paths in event rules -easy to migrate storage: -* use relative Paths or virtual paths instead Phisycal paths -* Don't use local drive use FQD instead -* don't hard code physical paths in the parameters on custom commands. - -* Warning, limit the root access to accounts, use "Treat home folder as user's default root folder" -n diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFTHandoff_Reports.md b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFTHandoff_Reports.md deleted file mode 100644 index fab1ff2..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFTHandoff_Reports.md +++ /dev/null @@ -1,30 +0,0 @@ -Run the following reports for hand off to customers after migrations, health checks or Assestments: - -``` powershell -.\EFT.ConnectionProfiles.Export.ps1 | Export-Csv Connection_Profiles.csv -.\EFT.EventRules.Export-ConnectionProfilesInActions.ps1 | Export-Csv Connection_Profiles_EventRules.csv -.\EFT.EventRules.Export-HostNamesInActions.ps1 | Export-Csv EventRules_HostnameInActions.csv -.\EFT.EventRules.Export-Params.ps1 -ValidatePath | Export-csv EventRules.csv -.\EFT.EventRules.Export-PathsInActions.ps1 -ValidatePath | Export-csv -.\EFT.EventRules.Export-PGPKeysUsed.ps1 | Export-csv EventRules_PGPUsed.csv -.\EFT.FolderPermissions.Export-OrphanPaths.ps1 | Export-csv FolderPermissions_OrphanPaths.csv -.\EFT.Report.ps1 > EFT_Report.txt -.\EFT.SiteSettingsPaths.Export.ps1 -Validate | Export-csv SiteSettings_Paths.csv -.\EFT.Users.StorageStats.ps1 | Export-csv UsersStats.csv -.\EFT.VirtualFolders.Export.ps1 -ValidatePath | Export-csv VirtualFolders.csv -.\EFT.Build.ps1 -Quiet -BuildFolder eftconfig | .\Utils.ScanPaths.ps1 eftconfig -ValidatePath | Export-csv AutomationPaths.csv -.\Utils.PathLength.ps1 -SourcePath 'C:\Inetpub\EFTRoot\' | export-csv SiteRootFolders.csv -``` - -| script | Description | -|------------------------------------|-----------------------------------------------------| -| EFT.ConnectionProfiles.Export.ps1 | Connection Profile report: This report will output all settings from connection profiles. Execute after migrations and health checks to review all connections settings are migrated correctly and validate hostnames are reachables and accessible.| -|EFT.EventRules.Export-ConnectionProfilesInActions.ps1|Connection profiles used in Event Rules: This report output all the connection profiles used in actions from event rules, showing their dependancy. | -|EFT.EventRules.Export-HostNamesInActions.ps1| Host names used in event rules actions: Outputs all the hostnames used inside of all Event rules actions. -| EFT.EventRules.Export-Params.ps1 | Event Rules Parameters: Output all event rules parameters. Idetify all paths being monitored by folder monitor, including subfolders, help to identify overlap and avoid duplication. Identify schedule event rules and its schedule. -|EFT.EventRules.Export-PathsInActions.ps1 | Folder paths used in event rules in actions: Output all folder paths used in event rules, using the ValidatePath paramter the script will verify that the paths exist and the service account have access (read) to them (make sure you run the script as the EFT service account)| -|EFT.EventRules.Export-PGPKeysUsed.ps1 | paths used in PGP actions in event rules | -|EFT.SiteSettingsPaths.Export.ps1 | Display all Paths associated to Site Settings. HA installations should have all paths to the share. Validate before and after migrations paths are migrated correctly.| -| EFT.Users.StorageStats.ps1 | | -| EFT.VirtualFolders.Export.ps1 | | -| EFT.Build.ps1 | | diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFTUtils.exe.config_Template.txt b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFTUtils.exe.config_Template.txt deleted file mode 100644 index 4057247..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/EFTUtils.exe.config_Template.txt +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - -
    - - -
    - - - - - - - - - - - - - AutoGenerate - - - Ch4ng3M3! - - - EqualsIgnoreCase - - - Merge - - - Standard - - - False - - - False - - - False - - - False - - - - - - - - - xml/diff.xml - - - chgToCurrDir\Sites\ - - - GUIDSTRING.Clients.db - - - GUIDSTRING.Clients.db - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Embeded WTC.html b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Embeded WTC.html deleted file mode 100644 index 5b08ee6..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Embeded WTC.html +++ /dev/null @@ -1,8 +0,0 @@ - -
    - WTC embeded exmaple -
    - -

    is an example on how to include WTC

    - - -[CmdletBinding()] -param ( - [Parameter(HelpMessage="The EFT admin hostname that EFT accepts administrative connections.")] - [string]$EFTAdminHostname = $(Read-Host "Enter EFTAdminHostname (Default ""Localhost"")"), - - [Parameter(HelpMessage="The EFT admin port number where EFT accepts administrative connections.")] - [int]$EFTAdminPort = $(Read-Host "Enter EFTPort (Default ""1100"")"), - - [Parameter(HelpMessage="The EFT admin authentication type (0-2). EFTLogin = 0, IWALogin = 1, NetLogon = 2.")] - [int]$EFTAdminAuthType = $(Read-Host "Enter EFTPort (Default ""1"")"), - - [Parameter(HelpMessage="The EFT Admin Username.")] - [string]$EFTAdminUsername = $(Read-Host "Enter EFTAdminUsername (Default ""$env:UserDomain\$env:UserName"")"), - - [Parameter(HelpMessage="The EFT Admin Password. leave empty if you are using IWALogin (Currently User Logged On User")] - [string]$EFTAdminPassword = $($(Read-Host -asSecureString "Enter EFT Admin password (Emtpy)") | convertfrom-securestring ), - - #[Parameter(HelpMessage="The Reportn file name where the report will be written.")] - #[ValidateNotNullOrEmpty()] - #[string]$ReportFile = $(Read-Host "Enter ReportFile (Default ""Executive_Config_Report_.txt"")"), - - [Parameter(HelpMessage="The SMTP Email To field, used to send an email using EFT SMTP Settings for testing settings, empty value will omit this process.")] - [string]$SMTPEMailTo = "" -) - -# Input Validations - -if ($EFTAdminHostname -eq $null -or $EFTAdminHostname -eq ""){ - $EFTAdminHostname = "Localhost" -} - -if ($EFTAdminPort -eq $null -or $EFTAdminPort -eq ""){ - $EFTAdminPort = "1100" -} - -if ($EFTAdminAuthType -eq $null -or $EFTAdminAuthType -eq ""){ - $EFTAdminAuthType = "1" -} - -if ($EFTAdminUsername -eq $null -or $EFTAdminUsername -eq ""){ - $EFTAdminUsername = "$env:UserDomain\$env:UserName" -} - -# if ($ReportFile -eq $null -or $ReportFile -eq ""){ -# $ReportFile = "Executive_Config_Report_" + $(get-date -f yyyyMMdd_HHmmss) +".txt" -#} - -# Variables - -$EFTServer = $null -#$EFTSites = $null -#$EFTSite = $null - - -$ReportContent = $null -$ReportContent | Set-Content $ReportFile - -$SecurePassword = ConvertTo-SecureString $EFTAdminPassword -$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecurePassword) -$EFTAdminPasswordUnsecure = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) - -Clear-Host -Write-host "*******************************************************************************************************" -ForegroundColor red -Write-host " QUICKSTART EFT CONFIGURATION REPORT"-ForegroundColor red -Write-host " EFTAdminHostname : $EFTAdminHostname"-ForegroundColor red -Write-host " EFTAdminPort : $EFTAdminPort"-ForegroundColor red -Write-host " EFTAdminAuthType : $EFTAdminAuthType "-ForegroundColor red -Write-host " EFTAdminUsername : $EFTAdminUsername"-ForegroundColor red -<# Write-host " EFTAdminPassword : $EFTAdminPasswordUnsecure" -ForegroundColor red#> -Write-host " SMTPEMailTo : $SMTPEMailTo"-ForegroundColor red -Write-host "*******************************************************************************************************" -ForegroundColor red - -Write-host "Current Date : $(get-date)" -Write-Host "`n" - -$EFTServer = new-object -ComObject "SFTPCOMInterface.CIServer" -Write-verbose "Connecting EFT Server TCP://$EFTAdminUsername@$EFTAdminHostname : $EFTAdminPort " - -try { - $EFTServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $EFTAdminPasswordUnsecure) - $EFTSites = $EFTServer.Sites() -} -catch { - Write-Error "ERROR" -ForegroundColor Red - Write-Error "Exception : $_" -ForegroundColor Red - exit -} -Write-verbose "Done" - -################################################################################################################ -# Begin Server Information Dump -################################################################################################################ - -$arIPS = $EFTServer.GetAdminIPs() - -Write-host "Connected to server: $EFTAdminHostname" -ForegroundColor Green -Write-host "Server Settings:" -ForegroundColor Cyan -Write-host "=============================================================================" -ForegroundColor Cyan -Write-host "Server Name:`t`t`t" $EFTAdminHostname -Write-host "Server Admin IP:`t`t" $arIPS[$EFTServer.ListenIP] -Write-host "Admin Port:`t`t`t" $EFTServer.AdminPort -Write-host "Remote Admin Enabled:`t`t" $EFTServer.AllowRemoteAdministration -Write-host "Use SSL for Admin:`t`t" $EFTServer.UseSSLForAdministration -Write-host "Local Config Path:`t`t" $EFTServer.ConfigurationFilePath - -<# try { - Write-host "AllowRemoteAdministration : $($EFTServer.AllowRemoteAdministration)" -} -catch { - Write-Host "ERROR" -ForegroundColor Red - Write-Host "Excepion : $_" -ForegroundColor Red -} #> - -Write-host "`n" -Write-host "Security Settings:"-ForegroundColor Cyan -Write-host "============================================================================="-ForegroundColor Cyan -Write-host "FIPS for SSH Enabled:`t`t" $EFTServer.SSHFIPSEnabled -Write-host "FIPS for SSL Enabled:`t`t" $EFTServer.SSLFIPSEnabled -Write-host "Allow CCC:`t`t`t" $EFTServer.AllowClearCommandChannel -Write-host "Allow Prot C:`t`t`t" $EFTServer.AllowUnprotectedDataChannel -$sslmask = [Convert]::ToString($EFTServer.SSLVersionMask,2) -While($SSlmask.length -lt 5) - { - $sslmask = "0" + $sslmask - } -$sslon = "False" -If ($sslmask.substring(0,1) -eq 1) { - $sslon="True" -} -Write-host "TLS 1.2 Enabled:`t`t" $sslon -$sslon = "False" -If ($sslmask.substring(1,1) -eq 1) { - $sslon="True" -} -Write-host "TLS 1.1 Enabled:`t`t" $sslon -$sslon = "False" -If ($sslmask.substring(4,1) -eq 1) { - $sslon="True" -} -Write-host "TLS 1.0 Enabled:`t`t" $sslon -$sslon = "False" -If ($sslmask.substring(3,1) -eq 1) { - $sslon="True" -} -Write-host "SSL 3.0 Enabled:`t`t" $sslon -$sslon = "False" -If ($sslmask.substring(2,1) -eq 1) { - $sslon="True" -} -Write-host "SSL 2.0 Enabled:`t`t" $sslon -$sslon = "False" - -Write-host "`n" -Write-host "SMTP Server Settings:" -ForegroundColor Cyan -Write-host "=============================================================================" -ForegroundColor Cyan -Write-host "SMTP Server Host:`t`t" $EFTServer.SMTPServer -Write-host "SMTP Server Port:`t`t" $EFTServer.SMTPPort -Write-host "SMTP From Address: `t`t" $EFTServer.SMTPSenderAddr -Write-host "SMTP From Name:`t`t`t" $EFTServer.SMTPSenderName -Write-host "Requires Authentication:`t" $EFTServer.SMTPUseAuthentication - -Write-Host "`n" -Write-Host "Audit & Reporting Database (ARM) and Log Settings:" -ForegroundColor Cyan -Write-host "=============================================================================" -ForegroundColor Cyan -Write-host "Log Folder:`t`t`t" $EFTServer.LogPath -Write-host "ARM Database Enabled:`t`t" $EFTServer.EnableARM -$ARMDBType = $EFTServer.ARMDatabaseType -If ($ARMDBType -eq 0) { - $ARMDBType = "Oracle"} - Else{ - $ARMDBType = "SQL Server"} -Write-host "ARM Database Type:`t`t" $ARMDBType -Write-host "ARM Host:`t`t`t" $EFTServer.ARMServerName -Write-host "ARM DB Name:`t`t`t" $EFTServer.ARMDatabaseName -$ARMDBType = $EFTServer.ARMAuthenticationType -If ($ARMDBType -eq 0) { - $ARMDBType = "Windows Authentication"} - Else{ - $ARMDBType = "SQL Authentication"} -Write-host "ARM Auth Type:`t`t`t" $ARMDBType -Write-host "ARM Error Email:`t`t" $EFTServer.ARMFailureEmailList -# Write-host "Audit Database Status:`t" $EFTServer.ARMConnectionStatus - -Write-Host "`n" -Write-host "Server Administrators " -ForegroundColor Cyan -Write-host "=============================================================================" -ForegroundColor Cyan -$accounts = $EFTServer.AdminAccounts -ForEach ($admin in $accounts) { - Write-host "["$admin.Login"] has the following permissions:"-ForegroundColor Red - for ($i=0; $i -le $admin.GetPermissionsCount() - 1; $i++){ - $permission = $admin.GetPermission($i) - # AdminPermissionsPolicy: - # ServerManagement = 0, - # SiteManagement = 1, - # STManagement = 2, - # UserCreation = 3, - # ChangePassword = 4, - # COMManagement = 5, - # ReportManagement = 6, - Switch ($permission.Permission) - { - 0 {Write-host "`tFULL - Server Management Admin"} - 1 {Write-host "`tSite Admin for site " $permission.SiteName} - 2 {Write-host "`tTemplate Admin management ["$permission.TemplateName"] for site ["$permission.SiteName"]"} - 3 {Write-host "`tUser creation Admin for template ["$permission.TemplateName"] for site ["$permission.SiteName"]"} - 4 {Write-host "`tChange password Admin for template ["$permission.TemplateName"] for site ["$permission.SiteName"]"} - 5 {Write-host "`t`tManagement via COM"} - 6 {Write-host "`t`tReport management"} - 7 {Write-host "`tEvent Rule Admin for site " $permission.SiteName} - } - } -} - -################################################################################################################ -# Begin Site Information Dump -############################################################################################################### - -Write-Host "`n" -$sites = $EFTServer.Sites() -$SitesTotal = $Sites.count() - Write-host "Found " $SitesTotal " sites on server." -ForegroundColor Cyan - Write-host "ID`t`t Site Name`t`t Site IP Address" -ForegroundColor Cyan - Write-host "=============================================================================" -ForegroundColor Cyan -For ($iCount=0; $iCount -le $Sites.count() - 1; $iCount++){ - $site = $Sites.Item($iCount) - $SiteIPaddr = $site.GetIP() - Write-host $site.ID "`t`t" $site.Name "`t`t" $arIPS[$SiteIPaddr] -} - -For ($iSite=0; $iSite -le $Sites.Count() - 1; $iSite++){ - $site = $Sites.Item($iSite) - - Write-host "`n" - Write-host "Site-Specific Information for: " $site.Name -ForegroundColor Cyan - Write-host "=============================================================================" -ForegroundColor Cyan - Write-host "Site Started:`t`t`t" $site.IsStarted - Write-host "Site Root Folder Path:`t`t" $site.GetRootFolder() - - $SiteAuthType = $null - Switch ($site.GetAuthManagerID()) - { - 0 {$SiteAuthType = "GS Authentication"; write-host "Site Auth Type:`t`t`t" $SiteAuthType;Write-host "Auth Configuration:`t`t" $site.ODBCSettings} - 1 {$SiteAuthType = "Active Directory/NTLM"; write-host "Site Auth Type:`t`t`t" $SiteAuthType;Write-host "Auth Configuration:`t`t" $site.ODBCSettings} - 2 {$SiteAuthType = "ODBC"; write-host "Site Auth Type:`t`t`t" $SiteAuthType;Write-host "Auth Configuration:`t`t" $site.ODBCSettings} - 3 {$SiteAuthType = "LDAP Authentication"; write-host "Site Auth Type:`t`t`t" $SiteAuthType;Write-host "Auth Configuration:`t`t" $site.ODBCSettings} - } - - - Write-host "SSL Certificate:`t`t" $site.GetCertFilePath() - Write-host "SSL Key:`t`t`t" $site.GetKeyFilePath() - Write-host "SSL Passphrase:`t`t`t" $site.GetPassPhrase() - Write-host "SSH Key:`t`t`t" $site.GetSSHKeyFilePath() - # Write-host "SSH Passphrase:`t`t" $site.SFTPKeyPassphrase -ForegroundColor Red - Write-host "Default PGP Key:`t`t`t" $site.DefaultPGPKeyID - # Write-host "Default PGP Passphrase:`t`t" $site.DefaultPGPKeyPassphrase -ForegroundColor Red - - # dmz info - # set oDMZ = site.DMZGateway() - # Write-host Chr(9) & "DMZ Gateway Enabled: " & Chr(9) & oDMZ.Enabled) - # Write-host Chr(9) & "DMZ Gateway Server: " & Chr(9) & oDMZ.GatewayIP) - # Write-host Chr(9) & "DMZ Gateway Port: " & Chr(9) & oDMZ.GatewayPort) - Write-host "DMZ Gateway Connected:`t`t" $site.DMZConnected - - Write-Host "`n" - $userslist = $site.GetUsers() - $total = $userslist.getupperbound(0) + 1 - Write-host "Total Number of Users:`t`t" $total - - $settingsTemplatesList = $site.GetSettingsLevels() - $total = $settingsTemplatesList.getupperbound(0) + 1 - Write-host "Total No. Settings Templates:`t" $total - - Write-host "Protocols enabled/Ports:" - If ($site.GetFTPAccess()) { - $ftp = $site.GetPort() - }else{ - $ftp = "Disabled" - } - Write-host "`tFTP:`t`t`t" $ftp - - If ($site.GetSSLAuth()) { - $ftpse = $site.GetPort() - }else{ - $ftpse = "Disabled" - } - Write-host "`tFTPS Explicit:`t`t" $ftpse - - If ($site.GetSSLImp()) { - $ftpsi = $site.FTPSImplicitPort - }else{ - $ftpsi = "Disabled" - } - Write-host "`tFTPS Implicit:`t`t" $ftpsi - - If ($site.GetSFTPAccess()) { - $sftp = $site.SFTPPort - }else{ - $sftp = "Disabled" - } - Write-host "`tSFTP:`t`t`t" $sftp - - If ($site.GetHTTPAccess()) { - $http = $site.GetHTTPPort() - }else{ - $http = "Disabled" - } - Write-host "`tHTTP:`t`t`t" $http - - If ($site.GetHTTPSAccess()) { - $https = $site.GetHTTPSPort() - }else{ - $https = "Disabled" - } - Write-host "`tHTTPS:`t`t`t" $https - - #WORKFLOW AND CUSTOM COMMAND COUNTS & EVENT RULE COUNTS - Write-Host "`n" - Write-host "Advanced Workflows:`t`t" $site.AdvancedWorkflowsCount - $customcommandslist = $site.GetCommands() - $total = $customcommandslist.getupperbound(0) + 1 - Write-host "Custom Commands:`t`t" $total - - Write-host "Event Types and Counts:" - #code for event rules - #OnTimer = 4097, - $eRules = $site.EventRules(4097) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Timer Rules: " $eRules.Count() - } - #OnLogRotate = 4098, - $eRules = $site.EventRules(4098) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Log Rotate Rules: " $eRules.Count() - } - #OnServiceStopped = 4099, - $eRules = $site.EventRules(4099) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Service Stopped Rules: " $eRules.Count() - } - #OnServiceStarted = 4100, - $eRules = $site.EventRules(4100) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Service Started Rules: " $eRules.Count() - } - #MonitorFolder = 4101, - $eRules = $site.EventRules(4101) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tFolder Monitor Rules: " $eRules.Count() - } - #OnMonitorFolderFailed = 4102, - $eRules = $site.EventRules(4102) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Monitor Folder Failed Rules: " $eRules.Count() - } - #OnSiteStarted = 8193, - $eRules = $site.EventRules(8193) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Site Started Rules: " $eRules.Count() - } - #OnSiteStopped = 8194, - $eRules = $site.EventRules(8194) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Site Stopped Rules: " $eRules.Count() - } - #OnClientConnected = 12289, - $eRules = $site.EventRules(12289) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Client Connected Rules: " $eRules.Count() - } - #OnClientConnectionFailed = 12290, - $eRules = $site.EventRules(12290) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Client Connection Failed Rules: " $eRules.Count() - } - #OnClientDisconnected = 12291, - $eRules = $site.EventRules(12291) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Client Disconnected Rules: " $eRules.Count() - } - #OnClientDisabled = 16385, - $eRules = $site.EventRules(16385) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Client Disabled Rules: " $eRules.Count() - } - #OnClientQuotaExceeded = 16386, - $eRules = $site.EventRules(16386) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Client Quota Exceeded Rules: " $eRules.Count() - } - #OnClientLoggedOut = 16387, - $eRules = $site.EventRules(16387) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Client Logged Out Rules: " $eRules.Count() - } - #OnClientLoggedIn = 16388, - $eRules = $site.EventRules(16388) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Client Logged In Rules: " $eRules.Count() - } - #OnClientLoginFailed = 16389, - $eRules = $site.EventRules(16389) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Client Login Failed Rules: " $eRules.Count() - } - #OnClientPasswordChanged = 16390, - $eRules = $site.EventRules(16390) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Client Password Changed Rules: " $eRules.Count() - } - #OnClientCreated = 16391, - $eRules = $site.EventRules(16391) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Client Created Rules: " $eRules.Count() - } - #OnClientLocked = 16392, - $eRules = $site.EventRules(16392) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Client Locked Rules: " $eRules.Count() - } - #OnFileDeleted = 20481, - $eRules = $site.EventRules(20481) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn File Deleted Rules: " $eRules.Count() - } - #OnFileUpload = 20482, - $eRules = $site.EventRules(20482) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn File Upload Rules: " $eRules.Count() - } - #BeforeFileDownload = 20483, - $eRules = $site.EventRules(20483) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tBefore File Download Rules: " $eRules.Count() - } - #OnFileDownload = 20484, - $eRules = $site.EventRules(20484) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn File Download Rules: " $eRules.Count() - } - #OnFileRenamed = 20485, - $eRules = $site.EventRules(20485) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn File Renamed Rules: " $eRules.Count() - } - #OnFolderCreated = 20486, - $eRules = $site.EventRules(20486) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Folder Created Rules: " $eRules.Count() - } - #OnFolderDeleted = 20487, - $eRules = $site.EventRules(20487) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Folder Deleted Rules: " $eRules.Count() - } - #OnUploadFailed = 20489, - $eRules = $site.EventRules(20489) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Upload Failed Rules: " $eRules.Count() - } - #OnDownloadFailed = 20490, - $eRules = $site.EventRules(20490) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Download Failed Rules: " $eRules.Count() - } - #OnChangeFolder = 20491, - $eRules = $site.EventRules(20491) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Change Folder Rules: " $eRules.Count() - } - #OnFileMoved = 20492, - $eRules = $site.EventRules(20492) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn File Moved Rules: " $eRules.Count() - } - #OnVerifiedUploadSuccess = 20493, - $eRules = $site.EventRules(20493) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Verified Upload Success Rules: " $eRules.Count() - } - #OnVerifiedUploadFailure = 20494, - $eRules = $site.EventRules(20494) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Verified Upload Failure Rules: " $eRules.Count() - } - #OnVerifiedDownloadSuccess = 20495, - $eRules = $site.EventRules(20495) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Verified Download Success Rules: " $eRules.Count() - } - #OnVerifiedDownloadFailure = 20496, - $eRules = $site.EventRules(20496) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tOn Verified Download Failure Rules: " $eRules.Count() - } - #AS2InboundTransactionSucceeded = 24577, - $eRules = $site.EventRules(24577) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tAS2 Inbound Transaction Succeeded Rules: " $eRules.Count() - } - #AS2InboundTransactionFailed = 24578, - $eRules = $site.EventRules(24578) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tAS2 Inbound Transaction Failed Rules: " $eRules.Count() - } - #AS2OutboundTransactionSucceeded = 24579, - $eRules = $site.EventRules(24579) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tAS2 Outbound Transaction Succeeded Rules: " $eRules.Count() - } - #AS2OutboundTransactionFailed = 24580, - $eRules = $site.EventRules(24580) - $eventrules = $eventrules + $eRules.Count() - If ($eRules.Count() -gt 0) { - Write-host "`tAS2 Outbound Transaction Failed Rules: " $eRules.Count() - } - Write-host "Event Rules Totals:`t`t" $eventrules - $eventrules = 0 - - -} - -Write-Host "`n" -Write-Host "REPORT COMPLETE!!" -ForegroundColor Magenta -Write-Host "`n" - -#Sample script - - -#Write-host "Detecting EFT site: EFTSiteName ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline -#$siteFound = $false -#for ($i=0; $i -le $EFTSites.Count()-1; $i++ ) { -# $EFTSite = $EFTSites.Item($i) -# if ($EFTSite.Name -eq $EFTSiteName) { -# $siteFound =$true -# break -# } -#} -#if ($siteFound -ne $true) { -# Write-host " ERROR" -ForegroundColor Red -# Write-Host "Site Not found" -ForegroundColor Red -# exit -#} -#Write-host " OK" -ForegroundColor Green - - - -#Write-host "Configuring EFT Advanced Workflows ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline -#Write-host " OK" -ForegroundColor Green -#Get-ChildItem "aml\" -Filter *.aml | -#Foreach-Object { - -# Write-host "Importing Advanced Workflow : $_".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - -# $workflowIndex = -1 - -# try { -# $workflowIndex = $EFTSite.GetAdvancedWorkflowIndex($_.BaseName) -# # Importing workflow - -# if ($workflowIndex -gt -1) { -# # Updating Workflow -# $workflowParams = $EFTSite.GetAdvancedWorkflowParams($workflowIndex) -# $workflowParams = new-object -ComObject "SFTPCOMInterface.CIAdvancedWorkflowParams" -# $workflowParams.Name = $_.BaseName -# $workflowParams.Description = "" -# $workflowParams.TimeoutSeconds = 120 -# $workflowParams.LogMode = 0 # AWLogNone = 0 -# $workflowParams.Code = (Get-Content $_.FullName ) -join "`n" -# $EFTSite.SetAdvancedWorkflowParams($workflowIndex, $workflowParams) -# } -# else { -# # Adding Workflow -# $workflowParams = new-object -ComObject "SFTPCOMInterface.CIAdvancedWorkflowParams" -# $workflowParams.Name = $_.BaseName -# $workflowParams.Description = "" -# $workflowParams.TimeoutSeconds = 120 -# $workflowParams.LogMode = 0 # AWLogNone = 0 -# $workflowParams.Code = (Get-Content $_.FullName ) -join "`n" -# $EFTSite.AddAdvancedWorkflow($workflowParams) | Out-Null -# } -# Write-host " OK" -ForegroundColor Green -# } -# catch { -# Write-host " ERROR" -ForegroundColor Red -# Write-host "Exception : $_" -ForegroundColor Red - -# } - -#} - -#Write-host "Configuring EFT Event Rules ".PadRight($MAX_PAD, $PAD_CHR) -NoNewline -#Write-host " OK" -ForegroundColor Green -#Get-ChildItem "event_rules\" -Filter *.xml | -#Foreach-Object { -# $eventTypes = $EFTServer.AvailableEvents -# $isDeleted = $false -# try { -# for ($i=0 ;$i -le $eventTypes.Length - 1 ;$i++) -# { -# $currentEventType = $eventTypes[$i].type -# $currentEventTypeName = $eventTypes[$i].Name - -# $eventRules = $EFTSite.EventRules($currentEventType) - -# for ($j=0 ; $j -le $eventRules.Count() -1 ; $j++ ) -# { -# $eventRule = $eventRules.Item($j) -# if ($_.BaseName -eq $eventRule.GetParams().Name) -# { -# Write-host "Deleting Event Rule: $($_.BaseName)".PadRight($MAX_PAD, $PAD_CHR) -NoNewline -# $eventRules.Delete($j) -# Write-host " OK" -ForegroundColor Green -# $isDeleted = $true -# break -# } -# } -# if ($isDeleted) { -# break -# } -# } - -# # Importing Event Rules -# Write-host "Importing Event Rule: $_".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - -# # Adding Event Rule -# $EFTSite.ImportEventRules($_.FullName) - -# Write-host " OK" -ForegroundColor Green -# } -# catch { -# Write-host " ERROR" -ForegroundColor Red -# Write-Host "Exception : $_" -ForegroundColor Red -# } - -#} - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/System.Data.SQLite.dll b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/System.Data.SQLite.dll deleted file mode 100644 index fd9c38a..0000000 Binary files a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/System.Data.SQLite.dll and /dev/null differ diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.Convert-ByteArrayToHex.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.Convert-ByteArrayToHex.ps1 deleted file mode 100644 index 2a30a06..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.Convert-ByteArrayToHex.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -[cmdletbinding()] - -param( - [parameter(Mandatory=$true)] - [Byte[]] - $Bytes -) - -$HexString = [System.Text.StringBuilder]::new($Bytes.Length * 2) - -ForEach($byte in $Bytes){ - $HexString.AppendFormat("{0:x2}", $byte) | Out-Null -} - -$HexString.ToString() \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.Convert-HexToByteArray.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.Convert-HexToByteArray.ps1 deleted file mode 100644 index 90df8ac..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.Convert-HexToByteArray.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -[cmdletbinding()] - -param( - [parameter(Mandatory=$true)] - [String] - $HexString -) - -$Bytes = [byte[]]::new($HexString.Length / 2) - -For($i=0; $i -lt $HexString.Length; $i+=2){ - $Bytes[$i/2] = [convert]::ToByte($HexString.Substring($i, 2), 16) -} - -$Bytes \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.DecodeFromBase64.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.DecodeFromBase64.ps1 deleted file mode 100644 index f34bc18..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.DecodeFromBase64.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -## -## 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. - -<# - .SYNOPSIS - Decode Base64 to plain text. - .DESCRIPTION - Decodes encoded text from Base64 to plain text - .PARAMETER EncodedText - The plain text you want to decode. I.E. "dGV4dCB0byBiZSBlbmNvZGVk" - .EXAMPLE - .\Utils.EncodeToBase64.ps1 -EncodedText dGV4dCB0byBiZSBlbmNvZGVk -#> - param( - [Parameter(Mandatory=$true, HelpMessage = "Input Text to Decode")] [String]$EncodedText - ) - - $decodedText = [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($EncodedText)) - $decodedText - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.EncodeToBase64.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.EncodeToBase64.ps1 deleted file mode 100644 index 378b4a9..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.EncodeToBase64.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -## -## 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. - -<# - .SYNOPSIS - Encode to plain text to Base64. - .DESCRIPTION - Encodes plain text using Base64. - .PARAMETER PlainText - The plain text you want to encode. I.E. "text to be encoded" - .EXAMPLE - .\Utils.EncodeToBase64.ps1 -PlainText "text to be encoded" -#> -[CmdletBinding()] -param( - [Parameter(Mandatory = $true, HelpMessage = "Input Text to Encode")] [String]$PlainText -) -$encoded = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($PlainText)) - -$encoded \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.PathLength.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.PathLength.ps1 deleted file mode 100644 index 10d854e..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.PathLength.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -## -## 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(SupportsShouldProcess)] -Param( - [Parameter(Position = 0, Mandatory = $true, HelpMessage = "Enter source path to be scanned ")] - [string] $sourcePath = "MySite" -) -$results = @() -$folders = Get-ChildItem -Path $sourcePath -Directory -Recurse -for ($i=0 ; $i -le $folders.Length -1 ;$i++){ - $folder = $folders[$i] - Write-Progress -Activity "Scanning Folders" -status "Folder $($folder.FullName) ($i/$($folders.length))" -percentComplete ($i / $folders.length * 100) - $FolderName = $folder.FullName - $PathLength = $folder.FullName.Length - $results += new-object psobject -Property @{ - Path = $FolderName; - PathLength = $PathLength; - } -} -$results \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.ReplacePathsFormDictionary.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.ReplacePathsFormDictionary.ps1 deleted file mode 100644 index eff8923..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.ReplacePathsFormDictionary.ps1 +++ /dev/null @@ -1,68 +0,0 @@ -## -## 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(SupportsShouldProcess)] -Param( - [Parameter(Position = 0, Mandatory = $True, HelpMessage = "Enter the input folder where files will be read for deploy")] - [String] [ValidateScript( {Test-Path $_ -isValid})] $InputFolder = "MySite" , - - [Parameter(Position = 1, Mandatory = $false, HelpMessage = "Dictionary file used for converting Paths")] - [string] $DictionaryCsvFile = "" -) -$MAX_PAD = 100 -$PAD_CHR = "." -# Validations -if ($InputFolder -notmatch '.+?\\$') { - $InputFolder += '\' -} -If ( (Test-Path $InputFolder) -eq $false) { - Write-host "Input folder doesn't exist" - exit -} -$InputFolder = Convert-Path $InputFolder -$sw = [Diagnostics.Stopwatch]::StartNew() -$i = 0 -$errors = 0 -# Dictionary File -if ($DictionaryCsvFile -eq "") { - #Uncomment the following to enter paramters for each site - $dictionaryList = @( - # @{ Path = "C:\"; NewPath = "\\ServerA\C\"; } - # @{ Path = "D:\"; NewPath = "\\ServerA\D\"; } - ) -} -else { - $dictionaryList = Import-Csv $DictionaryCsvFile - # "Path","NewPath" -} - -Get-ChildItem $InputFolder -File -Recurse | - Foreach-Object { - try { - foreach ($dictionaryEntry in $dictionaryList) { - $Path = $dictionaryEntry.Path - $NewPath = $dictionaryEntry.NewPath - $source = (Get-Content $_.FullName ) -join "`n" - - $NewSource = [regex]::Replace($source,[regex]::Escape($Path),$NewPath,[System.Text.RegularExpressions.RegexOptions]::IgnoreCase) - if ($source -ne $NewSource) { - Write-host " $($_.Name): $Path -> '$NewPath'".PadRight($MAX_PAD, $PAD_CHR) -NoNewline - $sw.Restart() - Set-Content -path $_.FullName -Value $NewSource -Encoding UTF8 - Write-Host "OK ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor green - $i++ - } - - } - } - catch { - Write-Host "ERROR ($($sw.ElapsedMilliseconds)ms)" -ForegroundColor red - Write-host "Exception : $_" -ForegroundColor Red - $errors++ - } -} \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.RoboCopy.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.RoboCopy.ps1 deleted file mode 100644 index 604ad72..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.RoboCopy.ps1 +++ /dev/null @@ -1,43 +0,0 @@ -## -## 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(SupportsShouldProcess)] -Param( - [Parameter(Position = 0, Mandatory = $true, HelpMessage = "Enter source path to be copied ")] - [string] $sourcePath = "", - - [Parameter(Position = 1, Mandatory = $true, HelpMessage = "Enter destination path")] - [string] $destinationPath = "", - - [Parameter(Position = 2, Mandatory = $false, HelpMessage = "Enter filename of the log ")] - [string] $Logfile = "" -) -Write-host "******* Utils RoboCopy SCRIPT 1.0 *************************************************" -ForegroundColor Yellow -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path) -$df = 'yyyy-MM-dd hh:mm:ss.fff' - -$CurrentUserName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name - -Write-Host "Current datetime : $(Get-Date -f $df)" -Write-Host "Current User : $CurrentUserName" -Write-Host "Admin Privileges : $adminPrivileges" - -if ($Logfile -eq "") { - $timestamp = $(Get-date -f 'yyyy_MM_dd-hh_mm_ss') - $LogFile = "$here\Robocopy_$timestamp.log" -} -# /v Verbose -# /E Include Empty directories -# /SEC Copy files with SECurity (equivalent to /COPY:DATS). -# /r:[n] Number of Retries on failed copies -# /r:[n] Wait time between retries: default is 30 seconds. -# /TEE output to console window, as well as the log file. -# /XO eXclude Older files. -# /NP No Progress - don't display percentage copied -# ROBOCOPY.EXE *.* /s /e /mir /np /mt /R:3 /W:2 /log:backup_.log -Robocopy "$sourcePath" "$destinationPath" /V /E /r:1 /w:15 /log+:"$LogFile" /XO /NP diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.ScanPaths.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.ScanPaths.ps1 deleted file mode 100644 index 5099a28..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.ScanPaths.ps1 +++ /dev/null @@ -1,58 +0,0 @@ -## -## 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(SupportsShouldProcess)] -Param( - [Parameter(Position = 0, Mandatory = $true, HelpMessage = "Enter source path to be scanned ")] - [string] $sourcePath = "MySite", - - [Parameter(Position = 1, Mandatory = $false, HelpMessage = "use this to include the line where the path was found")] - [switch] $IncludeLineSource =$false, - - [Parameter(Position = 2, Mandatory = $false, HelpMessage = "use this to validate paths exist")] - [switch] $ValidatePath = $false -) -# http://regexstorm.net/tester?p=%5e*%28%28%5ba-zA-Z%5d%3a%7c%5c%5c%5c%5c%5cw%5b+%5cw%5c%5d*%29%28%5c%5c%5cw%5b+%5cw%5c.%5d*%29%2b%28%5c%5c%5cw%5b+%5cw%5c.%5d*%29*%29%5c%5c&i=AMVARIABLE+C%3a%5cfoo.tes%0d%0aNAME%3d%22fileresultpath%22%26gt%3bC%3a%5cUsers%5crguzman%5cDesktop%5cfilelist_%25timestamp%25.txt%26lt%3b%2fAMVARIABLE%26gtC%3a%5c%0d%0aC%3a%5c%0d%0aC%3a%5ctempo%5c%0d%0a%5c%5cServerA%5c%0d%0a%5c%5c192.1.1.1%5casd%0d%0a%5c%5c127.1.1.2%5c%0d%0aasd%5c%5c127.1.1.2%5c%0d%0aa3sC%3a%5c - -$results = @() -# matches file paths with Context variables -#$FilePathpattern = '^*(([a-zA-Z]:|\\\\\w[ \w\.]*)(\\\w[ \w\.]*|\\%[ \w\.]+%+)+|%[ \w\.]+%(\\\w[ \w\.]*|\\%[ \w\.]+%+)*)' -#matches only file paths -$FilePathpattern = '^*(([a-zA-Z]:|\\\\\w[ \w-_\]*)(\\\w[ \w\.]*)+(\\\w[ \w\.]*)*)\\' -# $FilePathpattern = '^(?:[a-z]:|\\\\[a-z0-9_.$●-]+\\[a-z0-9_.$●-]+)\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$' -$sourceFullPath = Resolve-path $sourcePath -$files = Get-ChildItem -Path $sourcePath -File -Recurse -Filter *.xml - -for ($i=0 ; $i -le $files.Length -1 ;$i++){ - $file = $files[$i] - Write-Progress -Activity "Scanning Files" -status "File $file ($i/$($files.length))" -percentComplete ($i / $files.length * 100) - $result = Select-String -Path $file.FullName -pattern $FilePathpattern -AllMatches - foreach ($item in $result) { - foreach ($match in $item.matches) { - - if($IncludeLineSource){ - $line = $item.Line; - } - $SourceRelativePath = $item.Path.Replace($sourceFullPath,"") - if($ValidatePath){ - Write-Progress -Activity "Validating Paths on $SourceRelativePath" -status "Path $match.value ($i/$($files.length))" -percentComplete ($i / $files.length * 100) - $IsValid = if(Test-Path $match.value) { "OK" } else { "INVALID" } - } - - $results += new-object psobject -Property @{ - Path = $match.value; - LineNumber = $item.LineNumber; - SourceFilename = $item.Filename; - SourceRelativePath = $SourceRelativePath; - IsValidPath = $IsValid; - } - } - } - -} -$results \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.TestHostPort.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.TestHostPort.ps1 deleted file mode 100644 index 58d6c65..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/Utils.TestHostPort.ps1 +++ /dev/null @@ -1,50 +0,0 @@ -[CmdletBinding(SupportsShouldProcess)] -Param( - [Parameter(Position = 0, Mandatory = $false, HelpMessage = "Enter the servers from CSV file ")] - [string] $hostnamesCsvFile = "hostnames.csv" -) - -if ($hostnamesCsvFile -eq "") { - #Uncomment the following to enter paramters for each site - $ServerList = @( - #@{ Hostname = "localhost"; Port = 21 } - #@{ Hostname = "localhost"; Port = 221 } - #@{ Hostname = "localhost"; Port = 4433 } - ) -} -else { - $ServerList = Import-Csv $hostnamesCsvFile - # "Hostname","Port" -} -$results = @() -$sw = [Diagnostics.Stopwatch]::StartNew() -$df = 'yyyy-MM-dd hh:mm:ss.fff' -foreach ($server in $ServerList) { - Write-Progress -Activity "Testing Server" -status "$($server.hostname):$($server.Port)" - $Connected = $true - $Exception = "" - try { - $sw.Restart() - $client = New-Object System.Net.Sockets.TcpClient - $client.SendTimeout = 1000 * 30 # 30 seconds - $client.Connect($server.hostname, $server.Port) - $client.P - $Connected = $client.Connected - } - catch { - $Connected = $false - $Exception = $_.Exception.Message - } - finally { - $client.Close() - } - $results += New-Object psobject -Property @{ - DateTime = $(Get-Date -f $df); - Hostname = $server.hostname; - Port = $server.Port; - Connected = $Connected; - Elapsed = $sw.ElapsedMilliseconds - Exception = $Exception; - } -} -$results diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.AddParticipant.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.AddParticipant.ps1 deleted file mode 100644 index 1f77b31..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.AddParticipant.ps1 +++ /dev/null @@ -1,72 +0,0 @@ -[CmdletBinding(SupportsShouldProcess)] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTUri = "https://localhost:4433/", - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTUsername = "rguzman", - - [Parameter(Position = 4, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password ="1234", - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Workspaces ID")] - [String] $WorkspaceID = "59976727-c92d-4a82-aece-510756241722", - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Participant's email address")] - [String] $emailaddress = "rguzman@globals.com" -) -if ($EFTUri.EndsWith("/")){ - $EFTUri = $EFTUri.Remove($EFTUri.Length-1,1) -} -add-type @" - using System.Net; - using System.Security.Cryptography.X509Certificates; - public class TrustAllCertsPolicy : ICertificatePolicy { - public bool CheckValidationResult( - ServicePoint srvPoint, X509Certificate certificate, - WebRequest request, int certificateProblem) { - return true; - } - } -"@ - -$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12' -[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols -[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy -# To get faster performance use: -#$ProgressPreference = 'SilentlyContinue' - - -if ($emailaddress -like "*,*" -or $emailaddress -like "*;*") { - $emailaddress = $emailaddress.Replace(";",",") - $emailaddresList = $emailaddress.Split(",") -} -else { - $emailaddresList += $emailaddress -} - -$LoginGet = Invoke-WebRequest -Method GET -Uri "$EFTUri/EFTClient/Account/Login.htm" -UserAgent "Powershell" -SessionVariable Session -$cookies = $session.Cookies.GetCookies($efturi) -$token = "" -foreach($cookie in $cookies){ - if ($cookie.name -eq 'token') { - $token = $cookie.value - } -} - - -$LoginResponse = Invoke-WebRequest -Method POST -Uri "$EFTUri/EFTClient/Account/Login.htm?token=$token" -ContentType "application/x-www-form-urlencoded" -Body "username=$EFTUsername&password=$Password" -UserAgent "Powershell" -SessionVariable Session -#$AuthContent = $LoginResponse.Content | ConvertFrom-Json -#$session.Headers.Add("X-CSRF-TOKEN",$token) - -# Add participant to an existing Workspace -$body = "[" - -foreach ($address in $emailaddresList) { - $body += "{""email"":""$address"",""permissions"":{""canUploadFile"":true,""canDownloadFile"":true,""canDeleteFile"":true,""canRenameFileFolder"":true,""canCreateFolder"":true,""canDeleteFolder"":true}}," -} -$body = $body.Substring(0,$body.Length-1) -$body += "]" - -$AddParticipantResponse = Invoke-WebRequest -Method POST -Uri "$EFTUri/Workspaces/v1/Shares/$WorkspaceID/Participants" -Body $body -UserAgent "Powershell" -WebSession $Session -$AddParticipantResponse diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.ChangeParticipantPermissions.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.ChangeParticipantPermissions.ps1 deleted file mode 100644 index 85b0a3b..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.ChangeParticipantPermissions.ps1 +++ /dev/null @@ -1,67 +0,0 @@ -[CmdletBinding(SupportsShouldProcess)] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTUri = "https://localhost:4433/", - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTUsername = "rguzman", - - [Parameter(Position = 4, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password ="1234", - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Workspaces ID")] - [String] $WorkspaceID = "5c3316ee-246b-4b35-8add-9fc5e917080b", - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Participant's ID")] - [String] $ParticipantID = "49aa90cf-64b7-417d-89e8-7f011d2813a7" -) -if ($EFTUri.EndsWith("/")){ - $EFTUri = $EFTUri.Remove($EFTUri.Length-1,1) -} -add-type @" - using System.Net; - using System.Security.Cryptography.X509Certificates; - public class TrustAllCertsPolicy : ICertificatePolicy { - public bool CheckValidationResult( - ServicePoint srvPoint, X509Certificate certificate, - WebRequest request, int certificateProblem) { - return true; - } - } -"@ - -$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12' -[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols -[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy -# To get faster performance use: -#$ProgressPreference = 'SilentlyContinue' - - -if ($emailaddress -like "*,*" -or $emailaddress -like "*;*") { - $emailaddress = $emailaddress.Replace(";",",") - $emailaddresList = $emailaddress.Split(",") -} -else { - $emailaddresList += $emailaddress -} - -$LoginGet = Invoke-WebRequest -Method GET -Uri "$EFTUri/EFTClient/Account/Login.htm" -UserAgent "Powershell" -SessionVariable Session -$cookies = $session.Cookies.GetCookies($efturi) -$token = "" -foreach($cookie in $cookies){ - if ($cookie.name -eq 'token') { - $token = $cookie.value - } -} - - -$LoginResponse = Invoke-WebRequest -Method POST -Uri "$EFTUri/EFTClient/Account/Login.htm?token=$token" -ContentType "application/x-www-form-urlencoded" -Body "username=$EFTUsername&password=$Password" -UserAgent "Powershell" -SessionVariable Session -#$AuthContent = $LoginResponse.Content | ConvertFrom-Json -#$session.Headers.Add("X-CSRF-TOKEN",$token) - -# Add participant to an existing Workspace -$body = "{""canCreateFolder"":true,""canDeleteFile"":true,""canDeleteFolder"":false,""canDownloadFile"":true,""canRenameFileFolder"":true,""canUploadFile"":true}" - -#https://localhost:4433/Workspaces/v1/Shares/69ec72af-b6c6-4357-bdca-a9c0ceef3fdb/Participants/c6224cad-1aa0-4e0e-a138-345a2d380485 -$ChangeParticipantPermissionsResponse = Invoke-WebRequest -Method PUT -Uri "$EFTUri/Workspaces/v1/Shares/$WorkspaceID/Participants/$ParticipantID" -Body $body -UserAgent "Powershell" -WebSession $Session -$ChangeParticipantPermissionsResponse diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.CreateWorkspaces.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.CreateWorkspaces.ps1 deleted file mode 100644 index 5a8a75e..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.CreateWorkspaces.ps1 +++ /dev/null @@ -1,110 +0,0 @@ -[CmdletBinding(SupportsShouldProcess)] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTUri = "https://localhost:4433/", - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTUsername = "rguzman", - - [Parameter(Position = 4, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password ="1234", - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Enter Workspace name")] - [String] $name = "MyWorkspace", - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Enter virtual path")] - [String] $vpath = "/ReportX/", - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter Is Private")] - [String] $Private, - - [Parameter(Position = 7, Mandatory = $False, HelpMessage = "Enter Expired time")] - [String] $expireTime, - - [Parameter(Position = 9, Mandatory = $False, HelpMessage = "Enter Message")] - [String] $email = "ramiroguzman@gmail.com", - - [Parameter(Position = 9, Mandatory = $False, HelpMessage = "Enter Message")] - [String] $Message = "My Message" - - -) -if ($EFTUri.EndsWith("/")){ - $EFTUri = $EFTUri.Remove($EFTUri.Length-1,1) -} -add-type @" - using System.Net; - using System.Security.Cryptography.X509Certificates; - public class TrustAllCertsPolicy : ICertificatePolicy { - public bool CheckValidationResult( - ServicePoint srvPoint, X509Certificate certificate, - WebRequest request, int certificateProblem) { - return true; - } - } -"@ - -$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12' -[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols -[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy -# To get faster performance use: -#$ProgressPreference = 'SilentlyContinue' - - -$LoginGet = Invoke-WebRequest -Method GET -Uri "$EFTUri/EFTClient/Account/Login.htm" -UserAgent "Powershell" -SessionVariable Session -$cookies = $session.Cookies.GetCookies($efturi) -$token = "" -foreach($cookie in $cookies){ - if ($cookie.name -eq 'token') { - $token = $cookie.value - } -} - - -$LoginResponse = Invoke-WebRequest -Method POST -Uri "$EFTUri/EFTClient/Account/Login.htm?token=$token" -ContentType "application/x-www-form-urlencoded" -Body "username=$EFTUsername&password=$Password" -UserAgent "Powershell" -SessionVariable Session -#$AuthContent = $LoginResponse.Content | ConvertFrom-Json -#$session.Headers.Add("X-CSRF-TOKEN",$token) - -# Create Transactional WS -if ($Private) { - $Private = "true" -} else { - $Private = "false" -} - -# a participant is required to create a Workspace -$body = @" -{ - "name":"ReportX", - "vpath":"/ReportX/", - "expireTime":0, - "participants":[{ - "email":"$email", - "permissions": { - "canUploadFile":true, - "canDownloadFile":true, - "canDeleteFile":true, - "canRenameFileFolder":true, - "canCreateFolder":true, - "canDeleteFolder":true - } - }], - "notifications": { - "notifPeriod":"DAILY", - "onDownload":true, - "onUpload":true, - "onDelete":true, - "onReplace":true, - "onRename":true, - "onFileComments":true - }, - "private":$Private, - "message":"$message" -} -"@ - -$CreateWorkspaceResponse = Invoke-WebRequest -Method POST -Uri "$EFTUri/Workspaces/v1/Shares/" -Body $body -UserAgent "Powershell" -WebSession $Session -$response = $CreateWorkspaceResponse.Content | ConvertFrom-Json - -$response.Response.ID - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.GetWorkspaces.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.GetWorkspaces.ps1 deleted file mode 100644 index 2635b86..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.GetWorkspaces.ps1 +++ /dev/null @@ -1,62 +0,0 @@ -[CmdletBinding(SupportsShouldProcess)] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTUri = "https://localhost:4433/", - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTUsername = "rguzman", - - [Parameter(Position = 4, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password ="1234", - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Enter Workspace name")] - [String] $WorkspaceID = "59976727-c92d-4a82-aece-510756241722" -) -if ($EFTUri.EndsWith("/")){ - $EFTUri = $EFTUri.Remove($EFTUri.Length-1,1) -} -add-type @" - using System.Net; - using System.Security.Cryptography.X509Certificates; - public class TrustAllCertsPolicy : ICertificatePolicy { - public bool CheckValidationResult( - ServicePoint srvPoint, X509Certificate certificate, - WebRequest request, int certificateProblem) { - return true; - } - } -"@ - -$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12' -[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols -[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy -# To get faster performance use: -#$ProgressPreference = 'SilentlyContinue' - - -# $LoginGet = Invoke-WebRequest -Method GET -Uri "$EFTUri/EFTClient/Account/Login.htm" -UserAgent "Powershell" -SessionVariable Session -# $cookies = $session.Cookies.GetCookies($efturi) -# $token = "" -# foreach($cookie in $cookies){ -# if ($cookie.name -eq 'token') { -# $token = $cookie.value -# } -# } - - -Invoke-WebRequest -Method POST -Uri "$EFTUri/EFTClient/Account/Login.htm?token=$token" -ContentType "application/x-www-form-urlencoded" -Body "username=$EFTUsername&password=$Password" -UserAgent "Powershell" -SessionVariable Session - -# Get Workspaces -$GetWorkspaceResponse = Invoke-WebRequest -Method GET -Uri "$EFTUri/Workspaces/v1/Shares/$WorkspaceID/" -ContentType "application/json" -UserAgent "Powershell" -WebSession $Session -$GetWorkspaceResponse.Content -exit -$response = $GetWorkspaceResponse.Content | ConvertFrom-Json -if ($WorkspaceID -eq ""){ - $Workspaces = $response.Response.workspaces -} -else { - $Workspaces = $response.Response -} - - -$Workspaces diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.RemoveParticipant.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.RemoveParticipant.ps1 deleted file mode 100644 index d7d411d..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.RemoveParticipant.ps1 +++ /dev/null @@ -1,55 +0,0 @@ -[CmdletBinding(SupportsShouldProcess)] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTUri = "https://localhost:4433/", - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTUsername = "rguzman", - - [Parameter(Position = 4, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password ="1234", - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Workspaces ID")] - [String] $WorkspaceID = "331f7084-bdbb-4267-8427-be043753be28", - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Participant's ID")] - [String] $ParticipantID = "331f7084-bdbb-4267-8427-be043753be28" -) -if ($EFTUri.EndsWith("/")){ - $EFTUri = $EFTUri.Remove($EFTUri.Length-1,1) -} -add-type @" - using System.Net; - using System.Security.Cryptography.X509Certificates; - public class TrustAllCertsPolicy : ICertificatePolicy { - public bool CheckValidationResult( - ServicePoint srvPoint, X509Certificate certificate, - WebRequest request, int certificateProblem) { - return true; - } - } -"@ - -$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12' -[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols -[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy -# To get faster performance use: -#$ProgressPreference = 'SilentlyContinue' - - -$LoginGet = Invoke-WebRequest -Method GET -Uri "$EFTUri/EFTClient/Account/Login.htm" -UserAgent "Powershell" -SessionVariable Session -$cookies = $session.Cookies.GetCookies($efturi) -$token = "" -foreach($cookie in $cookies){ - if ($cookie.name -eq 'token') { - $token = $cookie.value - } -} - -$LoginResponse = Invoke-WebRequest -Method POST -Uri "$EFTUri/EFTClient/Account/Login.htm?token=$token" -ContentType "application/x-www-form-urlencoded" -Body "username=$EFTUsername&password=$Password" -UserAgent "Powershell" -SessionVariable Session -#$AuthContent = $LoginResponse.Content | ConvertFrom-Json -#$session.Headers.Add("X-CSRF-TOKEN",$token) - -#https://localhost:4433/Workspaces/v1/Shares/69ec72af-b6c6-4357-bdca-a9c0ceef3fdb/Participants/49aa90cf-64b7-417d-89e8-7f011d2813a7 -$RemoveParticipantResponse = Invoke-WebRequest -Method DELETE -Uri "$EFTUri/Workspaces/v1/Shares/$WorkspaceID/Participants/$ParticipantID" -Body $body -UserAgent "Powershell" -WebSession $Session -$RemoveParticipantResponse diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.RemoveWorkspaces.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.RemoveWorkspaces.ps1 deleted file mode 100644 index ce4aefc..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.RemoveWorkspaces.ps1 +++ /dev/null @@ -1,52 +0,0 @@ -[CmdletBinding(SupportsShouldProcess)] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTUri = "https://localhost:4433/", - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTUsername = "rguzman", - - [Parameter(Position = 4, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password ="1234", - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Enter Workspace name")] - [String] $WorkspaceID = "cf78bb0c-fee6-4600-ad2e-29e7f226f360" - -) -if ($EFTUri.EndsWith("/")){ - $EFTUri = $EFTUri.Remove($EFTUri.Length-1,1) -} -add-type @" - using System.Net; - using System.Security.Cryptography.X509Certificates; - public class TrustAllCertsPolicy : ICertificatePolicy { - public bool CheckValidationResult( - ServicePoint srvPoint, X509Certificate certificate, - WebRequest request, int certificateProblem) { - return true; - } - } -"@ - -$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12' -[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols -[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy -# To get faster performance use: -#$ProgressPreference = 'SilentlyContinue' - - -$LoginGet = Invoke-WebRequest -Method GET -Uri "$EFTUri/EFTClient/Account/Login.htm" -UserAgent "Powershell" -SessionVariable Session -$cookies = $session.Cookies.GetCookies($efturi) -$token = "" -foreach($cookie in $cookies){ - if ($cookie.name -eq 'token') { - $token = $cookie.value - } -} - -$LoginResponse = Invoke-WebRequest -Method POST -Uri "$EFTUri/EFTClient/Account/Login.htm?token=$token" -ContentType "application/x-www-form-urlencoded" -Body "username=$EFTUsername&password=$Password" -UserAgent "Powershell" -SessionVariable Session - -# Remove Workspace -$RemoveWorkspaceResponse = Invoke-WebRequest -Method DELETE -Uri "$EFTUri/Workspaces/v1/Shares/$WorkspaceID" -UserAgent "Powershell" -WebSession $Session -$RemoveWorkspaceResponse - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.ResendInvitation.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.ResendInvitation.ps1 deleted file mode 100644 index 5e48006..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.ResendInvitation.ps1 +++ /dev/null @@ -1,73 +0,0 @@ -[CmdletBinding(SupportsShouldProcess)] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTUri = "https://localhost:4433/", - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTUsername = "rguzman", - - [Parameter(Position = 4, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password ="1234", - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Workspaces ID")] - [String] $WorkspaceID = "5c3316ee-246b-4b35-8add-9fc5e917080b", - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Invitees's IDs ")] - [String] $invitesIDs = "2a283d5a-d765-40a4-9dd1-10da2d84c3bf" -) -if ($EFTUri.EndsWith("/")){ - $EFTUri = $EFTUri.Remove($EFTUri.Length-1,1) -} -add-type @" - using System.Net; - using System.Security.Cryptography.X509Certificates; - public class TrustAllCertsPolicy : ICertificatePolicy { - public bool CheckValidationResult( - ServicePoint srvPoint, X509Certificate certificate, - WebRequest request, int certificateProblem) { - return true; - } - } -"@ - -$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12' -[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols -[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy -# To get faster performance use: -#$ProgressPreference = 'SilentlyContinue' - -$invitesIDList = "" -if ($invitesIDs -like "*,*" -or $invitesIDs -like "*;*") { - $invitesIDs = $invitesIDs.Replace(";",",") - $invitesIDList = $invitesIDs.Split(",") -} -else { - $invitesIDList += $invitesIDs -} - -$LoginGet = Invoke-WebRequest -Method GET -Uri "$EFTUri/EFTClient/Account/Login.htm" -UserAgent "Powershell" -SessionVariable Session -$cookies = $session.Cookies.GetCookies($efturi) -$token = "" -foreach($cookie in $cookies){ - if ($cookie.name -eq 'token') { - $token = $cookie.value - } -} - - -$LoginResponse = Invoke-WebRequest -Method POST -Uri "$EFTUri/EFTClient/Account/Login.htm?token=$token" -ContentType "application/x-www-form-urlencoded" -Body "username=$EFTUsername&password=$Password" -UserAgent "Powershell" -SessionVariable Session -#$AuthContent = $LoginResponse.Content | ConvertFrom-Json -#$session.Headers.Add("X-CSRF-TOKEN",$token) - -# Add participant to an existing Workspace -$body = "{""ID"":""$WorkspaceID"",""invitees"":[ " - -foreach ($inviteeID in $invitesIDList) { - #{"ID":"5c3316ee-246b-4b35-8add-9fc5e917080b","invitees":["2a283d5a-d765-40a4-9dd1-10da2d84c3bf"]}: - $body += """$inviteeID""," -} -$body = $body.Substring(0,$body.Length-1) -$body += "]}" - -$ResendInvitationResponse = Invoke-WebRequest -Method POST -Uri "$EFTUri/Workspaces/v1/Invitations" -Body $body -UserAgent "Powershell" -WebSession $Session -$ResendInvitationResponse diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.SendFiles.ps1 b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.SendFiles.ps1 deleted file mode 100644 index a88490b..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/WorkspacesAPI/EFT.WorkspacesAPI.SendFiles.ps1 +++ /dev/null @@ -1,123 +0,0 @@ -[CmdletBinding(SupportsShouldProcess)] -Param( - [Parameter(Position = 1, Mandatory = $False, HelpMessage = "Enter a host name or IP address")] - [String] $EFTUri = "https://localhost:4433/", - - [Parameter(Position = 3, Mandatory = $False, HelpMessage = "Enter login")] - [String] $EFTUsername = "rguzman", - - [Parameter(Position = 4, Mandatory = $False, HelpMessage = "Enter password")] - [String] $Password ="1234", - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Enter To")] - [String] $from = "rguzman@globalscape.com", - - [Parameter(Position = 5, Mandatory = $False, HelpMessage = "Enter To")] - [String] $To = "ramiroguzman@hotmail.com", - - [Parameter(Position = 6, Mandatory = $False, HelpMessage = "Enter Cc")] - [String] $Cc, - - [Parameter(Position = 7, Mandatory = $False, HelpMessage = "Enter Bcc")] - [String] $Bcc, - - [Parameter(Position = 8, Mandatory = $False, HelpMessage = "Enter Subjec")] - [String] $Subject = "My Test subject", - - [Parameter(Position = 9, Mandatory = $False, HelpMessage = "Enter Body")] - [String] $Message = "My Message", - - [Parameter(Position = 10, Mandatory = $False, HelpMessage = "Send message body securely")] - [bool] $UseSecureBody = $false, - - [Parameter(Position = 10, Mandatory = $False, HelpMessage = "Send message body securely")] - [string] $FilePath = "C:\Users\rguzman\Desktop\readme.txt" - - -) -if ($EFTUri.EndsWith("/")){ - $EFTUri = $EFTUri.Remove($EFTUri.Length-1,1) -} -add-type @" - using System.Net; - using System.Security.Cryptography.X509Certificates; - public class TrustAllCertsPolicy : ICertificatePolicy { - public bool CheckValidationResult( - ServicePoint srvPoint, X509Certificate certificate, - WebRequest request, int certificateProblem) { - return true; - } - } -"@ - -$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12' -[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols -[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy -# To get faster performance use: -#$ProgressPreference = 'SilentlyContinue' - - -$LoginGet = Invoke-WebRequest -Method GET -Uri "$EFTUri/EFTClient/Account/Login.htm" -UserAgent "Powershell" -SessionVariable Session -$cookies = $session.Cookies.GetCookies($efturi) -$token = "" -foreach($cookie in $cookies){ - if ($cookie.name -eq 'token') { - $token = $cookie.value - } -} - - -$LoginResponse = Invoke-WebRequest -Method POST -Uri "$EFTUri/EFTClient/Account/Login.htm?token=$token" -ContentType "application/x-www-form-urlencoded" -Body "username=$EFTUsername&password=$Password" -UserAgent "Powershell" -SessionVariable Session -#$AuthContent = $LoginResponse.Content | ConvertFrom-Json -#$session.Headers.Add("X-CSRF-TOKEN",$token) - -# Create Transactional WS -$CreateWorkspaceResponse = Invoke-WebRequest -Method POST -Uri "$EFTUri/Workspaces/v1/Shares/" -ContentType "application/x-www-form-urlencoded" -Body '{"parameters":{"type":"transactional"}}' -UserAgent "Powershell" -WebSession $Session - -$WSContent = $CreateWorkspaceResponse.Content | ConvertFrom-Json -$WorkspaceID = $WSContent.Response.ID -$WorkspaceUrl = $WSContent.Response.Url -$WorkspacevPath = $WSContent.Response.vpath - - -# Upload file(s) -$outputFile = Split-Path $FilePath -leaf -$WorkspaceUpload = Invoke-WebRequest -Method POST -Uri "$EFTUri/WorkspacesSendMessage/$WorkspaceID/" -InFile $FilePath -Headers @{"Content-Disposition"="attachment; filename=""$($outputFile)"""} -UserAgent "Powershell" -WebSession $Session - -if ($UseSecureBody) { - $UseSecureBody = "true" -} else { - $UseSecureBody = "false" -} - -$body = @" -{ - "parameters":{ - "operation":"commit", - "files": [{"name":"$outputFile"}], - "message":"$Message", - "secureMessageBody": $UseSecureBody, - "type":"transactional", - "sendLinks":true, - "from":"$from", - "participants":[{"type":"to","email":"$To"}], - "subject":"$Subject", - "expireIn": {"timeUnit":"Month","value":1}, - "notifications": { - "notifPeriod":"DAILY", - "onDownload":true, - "onFileComments":true, - "onDelete":true, - "onReplace":true, - "onRename":true, - "onUpload":true - }, - "anonymous":false, - "single-use":true - } -} -"@ - -# Commit Workspace -$CommitWorkspaceResponse = Invoke-WebRequest -Method PUT -Uri "$EFTUri/Workspaces/v1/Shares/$WorkspaceID" -Body $body -UserAgent "Powershell" -WebSession $Session - diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/changelog.md b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/changelog.md deleted file mode 100644 index d2a744f..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/changelog.md +++ /dev/null @@ -1,21 +0,0 @@ -## 1.6 (April 14, 2018) -FEATURES: -- EventRulesEnableState: Added Export and Import EventRulesEnableState cmdlets -- Added Convert-StringToBase64 and Convert-StringFromBase64 cmdlets -IMPROVEMENTS: -- enhancement: Code cleanup - -BUG FIXES: -- - -## 1.5 (March 25, 2018) -FEATURES: -- ExportUserStorage: Added Get-CountFiles and Export-EftUserStorageSpace - -IMPROVEMENTS: -- enhancement: Code cleanup - -BUG FIXES: -- bug: exceptions messages not being displayed - -## 1.4 (February 20, 2018) diff --git a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/readme.md b/powershell/EFTPowerToolsPS/EFTPowerToolsPS/readme.md deleted file mode 100644 index 86ce651..0000000 --- a/powershell/EFTPowerToolsPS/EFTPowerToolsPS/readme.md +++ /dev/null @@ -1,17 +0,0 @@ -Recommended resources for beginners -Windows PowerShell Documentation Pack -http://www.microsoft.com/downloads/details.aspx?FamilyId=B4720B00-9A66-430F-BD56- -EC48BFCA154F&displaylang=en -Windows PowerShell Owner’s Manual -http://www.microsoft.com/technet/scriptcenter/topics/winpsh/manual/default.mspx -Next Generation Command Line Scripting (a webcast by the inventor of PowerShell) -http://msevents.microsoft.com/cui/WebCastEventDetails.aspx? -EventID=1032306183&EventCategory=3&culture=en-US&CountryCode=US -Free Windows PowerShell book available from msdn -https://blogs.technet.com/chitpro-de/archive/2007/05/10/english-version-of-windows-powershellcourse-book-available-for-download.aspx -What can I do with Windows PowerShell? -http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/index.mspx -Mastering PowerShell in your lunchbreak -http://powershelllive.com/blogs/lunch/default.aspx -An introduction to Windows PowerShell -http://www.slideshare.net/dalelane/an-introduction-to-windows-powershell/ \ No newline at end of file diff --git a/powershell/EFTPowerToolsPS/passphrase.txt b/powershell/EFTPowerToolsPS/passphrase.txt deleted file mode 100644 index 0e35170..0000000 --- a/powershell/EFTPowerToolsPS/passphrase.txt +++ /dev/null @@ -1 +0,0 @@ -EFTPowerToolsPS-v1.2.0 \ No newline at end of file