mirror of
https://github.com/helpsystems/EFTScriptSamples.git
synced 2025-01-18 01:21:55 -06:00
Merge pull request #2 from helpsystems/migrate_scripts
Added existing scripts
This commit is contained in:
commit
a88aaaef45
14
aml/GS_Variablize remote files.aml
Normal file
14
aml/GS_Variablize remote files.aml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<AMTASK>
|
||||||
|
<AMTASKHEAD>
|
||||||
|
<TASKINFO TASKVERSION="8090" />
|
||||||
|
</AMTASKHEAD>
|
||||||
|
|
||||||
|
<AMFUNCTION NAME="Main" RETURNTYPE="variable">
|
||||||
|
<AMFTP ACTIVITY="logon" SERVER="192.168.102.28" USERNAME="test" PASSWORD="AM2T0ncdJUXqLI7Sbl05hfcsg==aME" TYPE="sftp" PORT="22" />
|
||||||
|
<AMFTP ACTIVITY="advanced" FTPCOMMAND="long_list" PARAMETER="*.*" FTPLONGLISTDATASET="NewDataset" />
|
||||||
|
<AMLOOP TYPE="DATASET" DATASET="NewDataset">
|
||||||
|
<AMFILEWRITE FILE="C:\wd\filelist.txt">%NewDataset.FTPFileName%</AMFILEWRITE>
|
||||||
|
</AMLOOP>
|
||||||
|
</AMFUNCTION>
|
||||||
|
|
||||||
|
</AMTASK>
|
22
powershell/AWE_PID.ps1
Normal file
22
powershell/AWE_PID.ps1
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
$AMLHead = '</AMTASKHEAD>
|
||||||
|
|
||||||
|
<AMFUNCTION NAME="Main" ACCESS="private" RETURNTYPE="variable">'
|
||||||
|
|
||||||
|
# Set Variable to replace start of AWE with Start of AWE and Capture PID flow
|
||||||
|
#Change "<AMFILESYSTEM ACTIVITY" Line to a file location on your server
|
||||||
|
|
||||||
|
$AMLtask = '</AMTASKHEAD>
|
||||||
|
|
||||||
|
<AMFUNCTION NAME="Main" ACCESS="private" RETURNTYPE="variable">
|
||||||
|
<AMVARIABLE NAME="ProcessPID" VALUE="" PRIVATE="YES" />
|
||||||
|
<AMSCRIPT>Declare Function GetCurrentProcessId Lib "kernel32" () As Long
|
||||||
|
Sub Main
|
||||||
|
ProcessPID = GetCurrentProcessId()
|
||||||
|
End Sub</AMSCRIPT>
|
||||||
|
<AMFILESYSTEM ACTIVITY="write_file" FILE="C:\Temp\PID%ProcessPID%.log">%Now()%, %GetTaskName()% --- %AWE_TASK_NAME%, PID: %ProcessPID%</AMFILESYSTEM>
|
||||||
|
|
||||||
|
'
|
||||||
|
Get-ChildItem 'C:\Users\jbranan\Desktop\test\*.aml' -Recurse | ForEach {
|
||||||
|
(Get-Content $_ | ForEach { $_ -replace $AMLHead, $AMLtask }) |
|
||||||
|
Set-Content $_
|
||||||
|
}
|
7
powershell/AWE_Reaper.ps1
Normal file
7
powershell/AWE_Reaper.ps1
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
$startTimeLimit = (get-date) - (new-timespan -minutes 2)
|
||||||
|
$processes_to_kill = get-process |
|
||||||
|
where {$_.StartTime -lt $startTimeLimit -and ($_.path -like "GSAWE.exe") }
|
||||||
|
if ($processes_to_kill -ne $null)
|
||||||
|
{
|
||||||
|
$processes_to_kill | foreach { $_.Kill() }
|
||||||
|
}
|
72
powershell/AdminLockTest.ps1
Normal file
72
powershell/AdminLockTest.ps1
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#List of hostnames
|
||||||
|
$hostnames=@("CELES0272016","TERRA0372016");
|
||||||
|
|
||||||
|
#EFT Admin Credentials
|
||||||
|
$EFTAdminUsername = "a";
|
||||||
|
$EFTAdminPassword = "a";
|
||||||
|
$EFTAdminPort = 1100;
|
||||||
|
|
||||||
|
#EFT Com Object
|
||||||
|
$script:EftServer = $null
|
||||||
|
|
||||||
|
#List of hostnames that can be administrated at the same time
|
||||||
|
$output=@();
|
||||||
|
#$output=$hostnames# Debug, uncomment this line and set $lockfailure to "true".
|
||||||
|
#String representing lock failure.
|
||||||
|
$lockfailure=$false;
|
||||||
|
|
||||||
|
#Output <DATE> <TIME> <UTC Offset>
|
||||||
|
Function getdate
|
||||||
|
{
|
||||||
|
Get-Date -Format "MM/dd/yyyy HH:mm:ss K "
|
||||||
|
}
|
||||||
|
$currenttime = getdate
|
||||||
|
|
||||||
|
#Path to log file
|
||||||
|
$Logfile = "\\IV-S2019B-3\config\adminlock.log"
|
||||||
|
|
||||||
|
#Function to accept string input and append to $Logfile
|
||||||
|
Function LogWrite
|
||||||
|
{
|
||||||
|
Param ([string]$logstring)
|
||||||
|
|
||||||
|
Add-content $Logfile -value $logstring
|
||||||
|
}
|
||||||
|
#$EFTnodename = ''
|
||||||
|
#Set-Variable -Name "EFTnodename" ($EFT_CONTEXT.GetVariable("SERVER.NODE_NAME"))
|
||||||
|
#$logstring = $EFTnodename
|
||||||
|
#LogWrite $logstring
|
||||||
|
#Main, Loop through hostnames in $hostname array and attempt connection via com.Successful connections are counted by $flag.
|
||||||
|
#If a COM connection is successful to more than one server in the array, the $lockfailure variable is set to true.
|
||||||
|
$flag=0;
|
||||||
|
$output=''
|
||||||
|
for ($i=0;$i -le $hostnames.count-1; $i++){
|
||||||
|
foreach ($EFTAdminHostname in $hostnames[$i]){
|
||||||
|
$script:EftServer = new-object -ComObject "SFTPCOMInterface.CIServer"
|
||||||
|
try {
|
||||||
|
$script:EftServer.ConnectEx($EFTAdminHostname, $EFTAdminPort, $EFTAdminAuthType, $EFTAdminUsername, $EFTAdminPassword)
|
||||||
|
$flag++;
|
||||||
|
$output=$output +' '+ $EFTAdminHostname
|
||||||
|
$script:EftServer.close();
|
||||||
|
}
|
||||||
|
catch [System.Runtime.InteropServices.COMException] {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($flag -gt 1){
|
||||||
|
$lockfailure=$true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($lockfailure -eq $true){
|
||||||
|
$lockstatus = 'AdminsLock unstable.';
|
||||||
|
$lockstatusdetail = " Multiple servers can be accessed:"+' '+$output;
|
||||||
|
$logstring= $currenttime + $lockstatus + $lockstatusdetail+" LockFailure:Yes" +" Flag:"+ $flag #+ " ERNode:" + $EFT_CONTEXT.GetVariable("SERVER.NODE_NAME")
|
||||||
|
Write-Host $currenttime $lockstatus $lockstatusdetail
|
||||||
|
LogWrite $logstring
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$lockstatus = 'AdminsLock stable.'
|
||||||
|
$lockstatusdetail = " Connected to:"+' '+$output;
|
||||||
|
$logstring= $currenttime + $lockstatus +$lockstatusdetail + " LockFailure:No" +" Flag:"+ $flag #+ " ERNode:" + $EFT_CONTEXT.GetVariable("SERVER.NODE_NAME")
|
||||||
|
Write-Host $currenttime $lockstatus + $output
|
||||||
|
LogWrite $logstring
|
||||||
|
}
|
5
powershell/Arcus_domain_checker.ps1
Normal file
5
powershell/Arcus_domain_checker.ps1
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
$clients_to_check = @('a', 'b')
|
||||||
|
|
||||||
|
foreach($client in $clients_to_check){
|
||||||
|
Start-Process https://$client.arcusapp.globalscape.com
|
||||||
|
}
|
140
powershell/DummyFileCreatorRelase1.ps1
Normal file
140
powershell/DummyFileCreatorRelase1.ps1
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
# (c) Robert Carter
|
||||||
|
# Hide PowerShell Console
|
||||||
|
Add-Type -Name Window -Namespace Console -MemberDefinition '
|
||||||
|
[DllImport("Kernel32.dll")]
|
||||||
|
public static extern IntPtr GetConsoleWindow();
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);
|
||||||
|
'
|
||||||
|
$consolePtr = [Console.Window]::GetConsoleWindow()
|
||||||
|
[Console.Window]::ShowWindow($consolePtr, 0)
|
||||||
|
|
||||||
|
|
||||||
|
Add-Type -AssemblyName System.Windows.Forms
|
||||||
|
[System.Windows.Forms.Application]::EnableVisualStyles()
|
||||||
|
|
||||||
|
$Form = New-Object system.Windows.Forms.Form
|
||||||
|
$Form.ClientSize = '528,70'
|
||||||
|
$Form.text = "Dummy File Creator v1.0"
|
||||||
|
$Form.TopMost = $false
|
||||||
|
$Form.KeyPreview = $True
|
||||||
|
|
||||||
|
$Form.Add_KeyDown({if ($_.KeyCode -eq "Enter")
|
||||||
|
{Create-Dummy}})
|
||||||
|
$Form.Add_KeyDown({if ($_.KeyCode -eq "Escape")
|
||||||
|
{$Form.Close()}})
|
||||||
|
|
||||||
|
$PathBx = New-Object system.Windows.Forms.TextBox
|
||||||
|
$PathBx.multiline = $false
|
||||||
|
$PathBx.width = 172
|
||||||
|
$PathBx.height = 20
|
||||||
|
$PathBx.location = New-Object System.Drawing.Point(9,35)
|
||||||
|
$PathBx.Font = 'Microsoft Sans Serif,10'
|
||||||
|
$PathBx.Text = $Env:userprofile + "\Desktop"
|
||||||
|
|
||||||
|
$CreateBt = New-Object system.Windows.Forms.Button
|
||||||
|
$CreateBt.text = "Create"
|
||||||
|
$CreateBt.width = 60
|
||||||
|
$CreateBt.height = 30
|
||||||
|
$CreateBt.location = New-Object System.Drawing.Point(449,19)
|
||||||
|
$CreateBt.Font = 'Microsoft Sans Serif,10,style=Bold'
|
||||||
|
|
||||||
|
$SizeBx = New-Object system.Windows.Forms.TextBox
|
||||||
|
$SizeBx.multiline = $false
|
||||||
|
$SizeBx.width = 51
|
||||||
|
$SizeBx.height = 20
|
||||||
|
$SizeBx.location = New-Object System.Drawing.Point(321,35)
|
||||||
|
$SizeBx.Font = 'Microsoft Sans Serif,10'
|
||||||
|
$SizeBx.Text = '20'
|
||||||
|
|
||||||
|
$QuantityBx = New-Object system.Windows.Forms.TextBox
|
||||||
|
$QuantityBx.multiline = $false
|
||||||
|
$QuantityBx.width = 36
|
||||||
|
$QuantityBx.height = 20
|
||||||
|
$QuantityBx.location = New-Object System.Drawing.Point(383,35)
|
||||||
|
$QuantityBx.Font = 'Microsoft Sans Serif,10'
|
||||||
|
$QuantityBx.Text = '1'
|
||||||
|
|
||||||
|
$PathLb = New-Object system.Windows.Forms.Label
|
||||||
|
$PathLb.text = "Path to file:"
|
||||||
|
$PathLb.AutoSize = $true
|
||||||
|
$PathLb.width = 25
|
||||||
|
$PathLb.height = 10
|
||||||
|
$PathLb.location = New-Object System.Drawing.Point(9,12)
|
||||||
|
$PathLb.Font = 'Microsoft Sans Serif,10'
|
||||||
|
|
||||||
|
$SizeLb = New-Object system.Windows.Forms.Label
|
||||||
|
$SizeLb.text = "Size MB:"
|
||||||
|
$SizeLb.AutoSize = $true
|
||||||
|
$SizeLb.width = 25
|
||||||
|
$SizeLb.height = 10
|
||||||
|
$SizeLb.location = New-Object System.Drawing.Point(321,12)
|
||||||
|
$SizeLb.Font = 'Microsoft Sans Serif,10'
|
||||||
|
|
||||||
|
$QuantityLb = New-Object system.Windows.Forms.Label
|
||||||
|
$QuantityLb.text = "Quantity:"
|
||||||
|
$QuantityLb.AutoSize = $true
|
||||||
|
$QuantityLb.width = 25
|
||||||
|
$QuantityLb.height = 10
|
||||||
|
$QuantityLb.location = New-Object System.Drawing.Point(383,11)
|
||||||
|
$QuantityLb.Font = 'Microsoft Sans Serif,10'
|
||||||
|
|
||||||
|
$BrowseBt = New-Object system.Windows.Forms.Button
|
||||||
|
$BrowseBt.text = "..."
|
||||||
|
$BrowseBt.width = 27
|
||||||
|
$BrowseBt.height = 24
|
||||||
|
$BrowseBt.location = New-Object System.Drawing.Point(195,35)
|
||||||
|
$BrowseBt.Font = 'Microsoft Sans Serif,10'
|
||||||
|
$BrowseBt.Add_Click({$browse.ShowDialog();$PathBx.Text = $Browse.SelectedPath })
|
||||||
|
|
||||||
|
$FileNameBx = New-Object system.Windows.Forms.TextBox
|
||||||
|
$FileNameBx.multiline = $false
|
||||||
|
$FileNameBx.width = 75
|
||||||
|
$FileNameBx.height = 20
|
||||||
|
$FileNameBx.location = New-Object System.Drawing.Point(233,35)
|
||||||
|
$FileNameBx.Font = 'Microsoft Sans Serif,10'
|
||||||
|
$FileNameBx.Text = "dummy.txt"
|
||||||
|
|
||||||
|
$FileNameLb = New-Object system.Windows.Forms.Label
|
||||||
|
$FileNameLb.text = "FileName:"
|
||||||
|
$FileNameLb.AutoSize = $true
|
||||||
|
$FileNameLb.width = 25
|
||||||
|
$FileNameLb.height = 10
|
||||||
|
$FileNameLb.location = New-Object System.Drawing.Point(233,13)
|
||||||
|
$FileNameLb.Font = 'Microsoft Sans Serif,10'
|
||||||
|
|
||||||
|
$Browse = new-object system.windows.Forms.FolderBrowserDialog
|
||||||
|
$Browse.RootFolder = [System.Environment+SpecialFolder]'MyComputer'
|
||||||
|
$Browse.ShowNewFolderButton = $true
|
||||||
|
$Browse.selectedPath = "C:\"
|
||||||
|
$Browse.Description = "Choose a directory:"
|
||||||
|
|
||||||
|
$Form.controls.AddRange(@($PathBx,$CreateBt,$SizeBx,$QuantityBx,$PathLb,$SizeLb,$QuantityLb,$BrowseBt,$FileNameBx,$FileNameLb))
|
||||||
|
|
||||||
|
$CreateBt.Add_Click({Create-Dummy})
|
||||||
|
|
||||||
|
Function Create-Dummy {
|
||||||
|
|
||||||
|
$exten = $null
|
||||||
|
|
||||||
|
If ($FileNameBx.Text.Contains('.'))
|
||||||
|
{
|
||||||
|
$exten = '.' + $FileNameBx.Text.Split('.')[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
fsutil file createnew ($PathBx.Text + '\' + $FileNameBx.Text) (($SizeBx.Text -as [INT]) * 1048576)
|
||||||
|
|
||||||
|
For($j = ($QuantityBx.Text -as [INT]); $j -gt 1; $j--)
|
||||||
|
{
|
||||||
|
|
||||||
|
fsutil file createnew ($PathBx.Text + '\' + $FileNameBx.Text.Split('.')[0] + $j + $exten) (($SizeBx.Text -as [INT]) * 1048576)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#Show form
|
||||||
|
$Form.Topmost = $True
|
||||||
|
$Form.Add_Shown({$Form.Activate()})
|
||||||
|
[void] $Form.ShowDialog()
|
15
powershell/EFT_SiteInfoToOutputSitesIDs.ps1
Normal file
15
powershell/EFT_SiteInfoToOutputSitesIDs.ps1
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
$serverIp = "localhost"
|
||||||
|
$serverPort = 1100
|
||||||
|
$serverUsername = "a"
|
||||||
|
$serverPassword = "a"
|
||||||
|
|
||||||
|
$EFTServer = New-Object -COM "SFTPCOMInterface.CIServer"
|
||||||
|
$EFTServer.ConnectEX($serverIP, $serverPort, 0, $serverUsername, $serverPassword)
|
||||||
|
$EFTServer.Sites().Count()
|
||||||
|
|
||||||
|
for($j = 0; $j -lt $EFTServer.Sites().Count(); $j++)
|
||||||
|
{
|
||||||
|
Write-Host "Site Index - Site Name - Site GUID"
|
||||||
|
$a = $j + 1
|
||||||
|
Write-Host $a - $EFTServer.Sites().Item($j).Name - $EFTServer.Sites().Item($j).GUID
|
||||||
|
}
|
62
powershell/Folder Watch Dog.ps1
Normal file
62
powershell/Folder Watch Dog.ps1
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Watchdog Script that will send a notification if a folder gets too full.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
The Script will Send E-Mail for folders with files over a specified amount. This ammount is controlled by the $filelimit variable.
|
||||||
|
The script supports searching multiple directories; The folders will need to be inserted into the array $folderlist.
|
||||||
|
Change the SMTP server variable block to work in your environment.
|
||||||
|
|
||||||
|
.AUTHOR
|
||||||
|
Jonathan Branan <jbranan@globalscape.com>
|
||||||
|
.WARRANTY
|
||||||
|
This script is provided with no warranty and is not garunteed to work. Globalscape, Helpsystems or the Author assume NO responsibility for
|
||||||
|
the outcome of running the script.
|
||||||
|
#>
|
||||||
|
|
||||||
|
# List of folders to parse. Delimit by commas, make sure the paths are in double quotes.
|
||||||
|
$folderlist = @("C:\InetPub\EFTRoot\MySite")
|
||||||
|
# Minimum of files in a directory before the notfication is sent.
|
||||||
|
$filelimit = 100
|
||||||
|
|
||||||
|
#SMTP Server Block # CHANGE ME
|
||||||
|
$smtpserver = "mail.globalscape.com"
|
||||||
|
$from = "watchdog@server.com"
|
||||||
|
$to = "jbranan@globalscape.com"
|
||||||
|
$subject = "Folder Watch Dog"
|
||||||
|
$port = 25
|
||||||
|
|
||||||
|
$data = ForEach($Folder in $folderlist){
|
||||||
|
Get-ChildItem $Folder -Directory -Recurse|
|
||||||
|
ForEach-Object{
|
||||||
|
[pscustomobject]@{
|
||||||
|
FullName = $_.Fullname.ToLower()
|
||||||
|
FileCount = $_.GetFiles().Count
|
||||||
|
# Filters
|
||||||
|
} | Where-Object {$_.FileCount -ge $filelimit} | Where-Object {$_.FullName -cnotlike '*archive*'}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Building a table
|
||||||
|
$tbl = New-Object System.Data.DataTable "FileCount"
|
||||||
|
$col1 = New-Object System.Data.DataColumn FullName
|
||||||
|
$col2 = New-Object System.Data.DataColumn FileCount
|
||||||
|
$tbl.Columns.Add($col1)
|
||||||
|
$tbl.Columns.Add($col2)
|
||||||
|
|
||||||
|
ForEach($array in $data){
|
||||||
|
$row = $tbl.NewRow()
|
||||||
|
$row.FullName = $array.FullName
|
||||||
|
$row.FileCount = $array.FileCount
|
||||||
|
$tbl.Rows.Add($row)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Formatting the table so we can email it
|
||||||
|
$html = $tbl | Select-Object Fullname, Filecount | ConvertTo-Html -Property FullName, FileCount -Title 'Folders reaching the file limit'
|
||||||
|
$body = "Hi there,<br />Folders reaching the limit:<br /><br />" + $html
|
||||||
|
|
||||||
|
#Send the email
|
||||||
|
Send-MailMessage -smtpserver $smtpserver -Port $port -from $from -to $to -subject $subject -body $body -bodyashtml
|
||||||
|
|
||||||
|
#You can comment out Send-MailMessage and uncomment out the next line if you wish to debug filters
|
||||||
|
#$tbl | Select-Object Fullname, Filecount
|
62
powershell/Folder Watch Dog_Arcus.ps1
Normal file
62
powershell/Folder Watch Dog_Arcus.ps1
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Watchdog Script that will send a notification if a folder gets too full.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
The Script will Send E-Mail for folders with files over a specified amount. This ammount is controlled by the $filelimit variable.
|
||||||
|
The script supports searching multiple directories; The folders will need to be inserted into the array $folderlist.
|
||||||
|
Change the SMTP server variable block to work in your environment.
|
||||||
|
|
||||||
|
.AUTHOR
|
||||||
|
Jonathan Branan <jbranan@globalscape.com>
|
||||||
|
.WARRANTY
|
||||||
|
This script is provided with no warranty and is not garunteed to work. Globalscape, Helpsystems or the Author assume NO responsibility for
|
||||||
|
the outcome of running the script.
|
||||||
|
#>
|
||||||
|
|
||||||
|
# List of folders to parse. Delimit by commas, make sure the paths are in double quotes.
|
||||||
|
$folderlist = @("\\file.core.windows.net\gsbdata\InetPub\EFTRoot\MySite\Usr\FTPISO\Archive")
|
||||||
|
# Minimum of files in a directory before the notfication is sent.
|
||||||
|
$filelimit = 2
|
||||||
|
|
||||||
|
#SMTP Server Block # CHANGE ME
|
||||||
|
$smtpserver = "mail.globalscape.com"
|
||||||
|
$from = "watchdog@server.com"
|
||||||
|
$to = "jonathan.branan@helpsystems.com"
|
||||||
|
$subject = "Folder Watch Dog"
|
||||||
|
$port = 25
|
||||||
|
|
||||||
|
$data = ForEach($Folder in $folderlist){
|
||||||
|
Get-ChildItem $Folder -Directory -Recurse|
|
||||||
|
ForEach-Object{
|
||||||
|
[pscustomobject]@{
|
||||||
|
FullName = $_.Fullname.ToLower()
|
||||||
|
FileCount = $_.GetFiles().Count
|
||||||
|
# Filters
|
||||||
|
} | Where-Object {$_.FileCount -ge $filelimit}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Building a table
|
||||||
|
$tbl = New-Object System.Data.DataTable "FileCount"
|
||||||
|
$col1 = New-Object System.Data.DataColumn FullName
|
||||||
|
$col2 = New-Object System.Data.DataColumn FileCount
|
||||||
|
$tbl.Columns.Add($col1)
|
||||||
|
$tbl.Columns.Add($col2)
|
||||||
|
|
||||||
|
ForEach($array in $data){
|
||||||
|
$row = $tbl.NewRow()
|
||||||
|
$row.FullName = $array.FullName
|
||||||
|
$row.FileCount = $array.FileCount
|
||||||
|
$tbl.Rows.Add($row)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Formatting the table so we can email it
|
||||||
|
$html = $tbl | Select-Object Fullname, Filecount | ConvertTo-Html -Property FullName, FileCount -Title 'Folders reaching the file limit'
|
||||||
|
$body = "Hi there,<br />Folders reaching the limit:<br /><br />" + $html
|
||||||
|
|
||||||
|
#Send the email
|
||||||
|
Send-MailMessage -smtpserver $smtpserver -Port $port -from $from -to $to -subject $subject -body $body -bodyashtml
|
||||||
|
|
||||||
|
#You can comment out Send-MailMessage and uncomment out the next line if you wish to debug filters
|
||||||
|
#$tbl | Select-Object Fullname, Filecount
|
7
powershell/Installedupdates.ps1
Normal file
7
powershell/Installedupdates.ps1
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Get-HotFix |
|
||||||
|
|
||||||
|
Where {
|
||||||
|
|
||||||
|
$_.InstalledOn -gt "07/01/2019" -AND $_.InstalledOn -lt "09/01/2019" } |
|
||||||
|
|
||||||
|
sort InstalledOn | Out-File $HOME\desktop\installedupdates.txt
|
26
powershell/RemoveKeyFromUser.ps1
Normal file
26
powershell/RemoveKeyFromUser.ps1
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
$server_ip = "192.168.102.28"
|
||||||
|
$server_port = 1100
|
||||||
|
$admin_username = "insight"
|
||||||
|
$admin_password = "a"
|
||||||
|
$site_name = "GS"
|
||||||
|
|
||||||
|
$server = New-Object -ComObject SFTPCOMInterface.CIServer
|
||||||
|
$server.connect($server_ip,$server_port,$admin_username,$admin_password)
|
||||||
|
|
||||||
|
$site_list = $server.Sites()
|
||||||
|
|
||||||
|
for ($i = 0; $i -lt $site_list.Count(); $i++) {
|
||||||
|
$site = $site_list.Item($i)
|
||||||
|
if ($site.Name -eq $site_name) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$date = "11/1/2006"
|
||||||
|
$date = [datetime] $date
|
||||||
|
|
||||||
|
$username = Read-Host "Which user do you want to remove a key from?"
|
||||||
|
|
||||||
|
$settings = $site.GetUserSettings($username)
|
||||||
|
|
||||||
|
$settings.setExpirationDate($date, 0)
|
63
powershell/eftArmGetSettings.ps1
Normal file
63
powershell/eftArmGetSettings.ps1
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Use EFT's COM interface to configure ARM settings for auditing and reporting.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Use EFT's COM interface to retrieve ARM settings
|
||||||
|
|
||||||
|
.PARAMETER serverName
|
||||||
|
|
||||||
|
.PARAMETER eftAdminPort
|
||||||
|
|
||||||
|
.PARAMETER authMethod
|
||||||
|
|
||||||
|
.PARAMETER eftAdminName
|
||||||
|
|
||||||
|
.PARAMETER eftAdminPassword
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$False)][string]$serverName = "localhost",
|
||||||
|
[Parameter(Mandatory=$False)][int]$eftAdminPort = 1100,
|
||||||
|
[Parameter(Mandatory=$False)][int]$authMethod = 1,
|
||||||
|
[Parameter(Mandatory=$False)][string]$eftAdminName = "",
|
||||||
|
[Parameter(Mandatory=$False)][string]$eftAdminPassword = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# login as admin
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
try {
|
||||||
|
$oServer = New-Object -ComObject 'SFTPComInterface.CIServer'
|
||||||
|
$oServer.ConnectEx( $serverName, $eftAdminPort, $authMethod, $eftAdminName, $eftAdminPassword );
|
||||||
|
Write-Host "connected"
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
$errorMessage = $_.Exception.Message;
|
||||||
|
Write-Host "failed to connect to server ${serverName}: ${errorMessage}"
|
||||||
|
Exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# get ARM settings
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
Write-Output ("ARMServerName: {0}" -f $oServer.ARMServerName)
|
||||||
|
Write-Output ("ARMDatabaseName: {0}" -f $oServer.ARMDatabaseName)
|
||||||
|
Write-Output ("ARMUserName: {0}" -f $oServer.ARMUserName)
|
||||||
|
Write-Output ("ARMPassword: {0}" -f $oServer.ARMPassword)
|
||||||
|
Write-Output ("ARMDatabaseType: {0}" -f $oServer.ARMDatabaseType)
|
||||||
|
Write-Output ("ARMAuthenticationType: {0}" -f $oServer.ARMAuthenticationType)
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# close resources
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
$oServer.Close()
|
||||||
|
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($oServer) | out-null
|
||||||
|
Remove-Variable oServer
|
||||||
|
|
BIN
powershell/eft_cli.ps1
Normal file
BIN
powershell/eft_cli.ps1
Normal file
Binary file not shown.
1
powershell/filesystemoutput.ps1
Normal file
1
powershell/filesystemoutput.ps1
Normal file
@ -0,0 +1 @@
|
|||||||
|
Get-ChildItem -path "\\file.core.windows.net\gsbdata\" -Recurse -Force | Export-Csv D:\siteroot.csv
|
11
powershell/mail.ps1
Normal file
11
powershell/mail.ps1
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
$smtpserver = "mail.globalscape.com"
|
||||||
|
$from = "watchdog@server.com"
|
||||||
|
$to = "jonathan.branan@helpsystems.com"
|
||||||
|
$subject = "Folder Watch Dog"
|
||||||
|
$port = 25
|
||||||
|
|
||||||
|
|
||||||
|
$body = "Hi there,<br />Folders reaching the limit:<br /><br />"
|
||||||
|
|
||||||
|
#Send the email
|
||||||
|
Send-MailMessage -smtpserver $smtpserver -Port $port -from $from -to $to -subject $subject -body $body -bodyashtml
|
115
powershell/reconnect_arm.ps1
Normal file
115
powershell/reconnect_arm.ps1
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Use EFT's COM interface to configure ARM settings for auditing and reporting.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Use EFT's COM interface to check status of ARM and reconnect if needed
|
||||||
|
|
||||||
|
.PARAMETER serverName
|
||||||
|
|
||||||
|
.PARAMETER eftAdminPort
|
||||||
|
|
||||||
|
.PARAMETER authMethod
|
||||||
|
|
||||||
|
.PARAMETER eftAdminName
|
||||||
|
|
||||||
|
.PARAMETER eftAdminPassword
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$False)][string]$serverName = "localhost",
|
||||||
|
[Parameter(Mandatory=$False)][int]$eftAdminPort = 1100,
|
||||||
|
[Parameter(Mandatory=$False)][int]$authMethod = 1,
|
||||||
|
[Parameter(Mandatory=$False)][string]$eftAdminName = "",
|
||||||
|
[Parameter(Mandatory=$False)][string]$eftAdminPassword = ""
|
||||||
|
)
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# Setup logging to a file
|
||||||
|
#------------------------------------------------------------
|
||||||
|
#Output <DATE> <TIME> <UTC Offset>
|
||||||
|
Function getdate
|
||||||
|
{
|
||||||
|
Get-Date -Format "MM/dd/yyyy HH:mm:ss K "
|
||||||
|
}
|
||||||
|
$currenttime = getdate
|
||||||
|
$EFT_CONTEXT.SetVariable("failure", "false")
|
||||||
|
$EFT_CONTEXT.SetVariable("status", "")
|
||||||
|
#Path to log file
|
||||||
|
$Logfile = "D:\ARM-Connection.log"
|
||||||
|
|
||||||
|
#Function to accept string input and append to $Logfile
|
||||||
|
Function LogWrite
|
||||||
|
{
|
||||||
|
Param ([string]$logstring)
|
||||||
|
|
||||||
|
Add-content $Logfile -value $logstring
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# login as admin
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
try {
|
||||||
|
$oServer = New-Object -ComObject 'SFTPComInterface.CIServer'
|
||||||
|
$oServer.ConnectEx( $serverName, $eftAdminPort, $authMethod, $eftAdminName, $eftAdminPassword );
|
||||||
|
Write-Host "connected"
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
$errorMessage = $_.Exception.Message;
|
||||||
|
Write-Host "failed to connect to server ${serverName}: ${errorMessage}"
|
||||||
|
Exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
write-host $oServer.ARMConnectionStatus
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# get ARM settings
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
#Write-Output ("ARMServerName: {0}" -f $oServer.ARMServerName)
|
||||||
|
if ($oServer.ARMConnectionStatus)
|
||||||
|
{
|
||||||
|
$logstring= $currenttime + 'ARM Is Connected.'
|
||||||
|
LogWrite $logstring
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$logstring= $currenttime + 'ARM Is Not Connected. Testing connection to the database...'
|
||||||
|
LogWrite $logstring
|
||||||
|
$EFT_CONTEXT.SetVariable("failure", "true")
|
||||||
|
if ($oServer.ARMTestConnection())
|
||||||
|
{
|
||||||
|
Write-Output ('ARM Test Connection Succeeded. Attempting to reconnect ARM...')
|
||||||
|
$logstring= $currenttime + 'ARM Test Connection Succeeded.'
|
||||||
|
LogWrite $logstring
|
||||||
|
if ($oServer.ARMReconnect())
|
||||||
|
{
|
||||||
|
Write-Output 'ARM connection test succeeded.'
|
||||||
|
$logstring= $currenttime + 'Reconnected the disconnected ARM database'
|
||||||
|
LogWrite $logstring
|
||||||
|
$EFT_CONTEXT.SetVariable("status", "Reconnected the disconnected ARM database")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
write-output 'Failed To Reconnect ARM.'
|
||||||
|
$logstring= $currenttime + 'Failed To Reconnect ARM.'
|
||||||
|
LogWrite $logstring
|
||||||
|
$EFT_CONTEXT.SetVariable("status", "Failed To Reconnect ARM.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Write-Output ('ARM Test Connection Failed.')
|
||||||
|
$logstring=$currenttime + 'ARM Test Connection Failed.'
|
||||||
|
LogWrite $logstring
|
||||||
|
$EFT_CONTEXT.SetVariable("status", "ARM Test Connection Failed.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#$oServer.ARMReconnect()
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# close resources
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
$oServer.Close()
|
||||||
|
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($oServer) | out-null
|
||||||
|
Remove-Variable oServer
|
76
powershell/reset_log_function.ps1
Normal file
76
powershell/reset_log_function.ps1
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
function Reset-Log
|
||||||
|
{
|
||||||
|
#function checks to see if file in question is larger than the paramater specified if it is it will roll a log and delete the oldes log if there are more than x logs.
|
||||||
|
param([string]$fileName, [int64]$filesize = 1mb , [int] $logcount = 5)
|
||||||
|
|
||||||
|
$logRollStatus = $true
|
||||||
|
if(test-path $filename)
|
||||||
|
{
|
||||||
|
$file = Get-ChildItem $filename
|
||||||
|
if((($file).length) -ige $filesize) #this starts the log roll
|
||||||
|
{
|
||||||
|
$fileDir = $file.Directory
|
||||||
|
$fn = $file.name #this gets the name of the file we started with
|
||||||
|
$files = Get-ChildItem $filedir | ?{$_.name -like "$fn*"} | Sort-Object lastwritetime
|
||||||
|
$filefullname = $file.fullname #this gets the fullname of the file we started with
|
||||||
|
#$logcount +=1 #add one to the count as the base file is one more than the count
|
||||||
|
for ($i = ($files.count); $i -gt 0; $i--)
|
||||||
|
{
|
||||||
|
#[int]$fileNumber = ($f).name.Trim($file.name) #gets the current number of the file we are on
|
||||||
|
$files = Get-ChildItem $filedir | ?{$_.name -like "$fn*"} | Sort-Object lastwritetime
|
||||||
|
$operatingFile = $files | ?{($_.name).trim($fn) -eq $i}
|
||||||
|
if ($operatingfile)
|
||||||
|
{$operatingFilenumber = ($files | ?{($_.name).trim($fn) -eq $i}).name.trim($fn)}
|
||||||
|
else
|
||||||
|
{$operatingFilenumber = $null}
|
||||||
|
|
||||||
|
if(($operatingFilenumber -eq $null) -and ($i -ne 1) -and ($i -lt $logcount))
|
||||||
|
{
|
||||||
|
$operatingFilenumber = $i
|
||||||
|
$newfilename = "$filefullname.$operatingFilenumber"
|
||||||
|
$operatingFile = $files | ?{($_.name).trim($fn) -eq ($i-1)}
|
||||||
|
write-host "moving to $newfilename"
|
||||||
|
move-item ($operatingFile.FullName) -Destination $newfilename -Force
|
||||||
|
}
|
||||||
|
elseif($i -ge $logcount)
|
||||||
|
{
|
||||||
|
if($operatingFilenumber -eq $null)
|
||||||
|
{
|
||||||
|
$operatingFilenumber = $i - 1
|
||||||
|
$operatingFile = $files | ?{($_.name).trim($fn) -eq $operatingFilenumber}
|
||||||
|
|
||||||
|
}
|
||||||
|
write-host "deleting " ($operatingFile.FullName)
|
||||||
|
remove-item ($operatingFile.FullName) -Force
|
||||||
|
}
|
||||||
|
elseif($i -eq 1)
|
||||||
|
{
|
||||||
|
$operatingFilenumber = 1
|
||||||
|
$newfilename = "$filefullname.$operatingFilenumber"
|
||||||
|
write-host "moving to $newfilename"
|
||||||
|
move-item $filefullname -Destination $newfilename -Force
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$operatingFilenumber = $i +1
|
||||||
|
$newfilename = "$filefullname.$operatingFilenumber"
|
||||||
|
$operatingFile = $files | ?{($_.name).trim($fn) -eq ($i-1)}
|
||||||
|
write-host "moving to $newfilename"
|
||||||
|
move-item ($operatingFile.FullName) -Destination $newfilename -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ $logRollStatus = $false}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$logrollStatus = $false
|
||||||
|
}
|
||||||
|
$LogRollStatus
|
||||||
|
}
|
||||||
|
|
||||||
|
Reset-Log -fileName $logfile -filesize 1mb -logcount 5
|
6
powershell/restore.ps1
Normal file
6
powershell/restore.ps1
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
$destinationFolder = "\\file.core.windows.net\gsbdata\InetPub\EFTRoot\gsbsup\Usr\Projects\SEG\ "
|
||||||
|
$restoredLocation = "\\file.core.windows.net\gsbdata\InetPub\EFTRoot\RestoredFiles\PubTech_20210128\ "
|
||||||
|
|
||||||
|
$exportfilelocation2 = "d:\restored.txt"
|
||||||
|
|
||||||
|
Robocopy /E /XC /XN /XO $restoredLocation $destinationFolder > $exportfilelocation2
|
6
powershell/robocopy.ps1
Normal file
6
powershell/robocopy.ps1
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
$destinationFolder = "\\TERRA0372016\Users\jbranan\Desktop\share\New folder "
|
||||||
|
$restoredLocation = "\\TERRA0372016\Users\jbranan\Desktop\share\abetest "
|
||||||
|
|
||||||
|
$exportfilelocation2 = "d:\restored.txt"
|
||||||
|
|
||||||
|
Robocopy /E /XC /XN /XO $restoredLocation $destinationFolder > $exportfilelocation2
|
102
powershell/stake_out.ps1
Normal file
102
powershell/stake_out.ps1
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Data collection using tools such Procmon, Procdump and Wireshark
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
This script enables an admnistrator to collect data on their server at times when they are unable to observe the issue live.
|
||||||
|
|
||||||
|
.DISCLAIMER
|
||||||
|
This script is provided without warranty. Globalscape/Helpsystems does not assume any liability for unintended functionality as a result of this script.
|
||||||
|
.VERSION
|
||||||
|
1.0
|
||||||
|
1.1 Added wireshark portable and set procmon to close itself. Also removed /nofilter in procmon.
|
||||||
|
.AUTHOR
|
||||||
|
Jonathan Branan jbranan@globalscape.com jonathan.branan@helpsystems.com
|
||||||
|
#>
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# Main Variables
|
||||||
|
#------------------------------------------------------------
|
||||||
|
$working_drive = 'c:'
|
||||||
|
$working_directory = 'C:\Users\jbranan\Desktop\scripts\stake_out'
|
||||||
|
$total_time = 20
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# Procmon related variables
|
||||||
|
#------------------------------------------------------------
|
||||||
|
$procmon_filename = 'log.pml'
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# Wireshark related variables
|
||||||
|
#------------------------------------------------------------
|
||||||
|
$wireshark_filename = 'capture.pcapng'
|
||||||
|
$wireshark_drive = 'c:'
|
||||||
|
$wireshark_location = 'C:\Users\jbranan\Desktop\scripts\stake_out\WiresharkPortable'
|
||||||
|
$wireshark_filter = 'host 192.168.102.10'
|
||||||
|
$total_wireshark_time = $total_time + 15
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# Procdump related variables
|
||||||
|
#------------------------------------------------------------
|
||||||
|
$take_service_dumps = $false
|
||||||
|
$take_gui_dumps = $false
|
||||||
|
$number_of_dumps = 3
|
||||||
|
$total_procdump_time = 60
|
||||||
|
$total_procdump_time_close = $total_procdump_time + 15
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# Procmon blocks
|
||||||
|
#------------------------------------------------------------
|
||||||
|
Start-Job -Name procmon -ScriptBlock {
|
||||||
|
$using:working_drive
|
||||||
|
cd $using:working_directory"\procmon"
|
||||||
|
./procmon.exe /accepteula /Quiet /BackingFile $using:working_directory"\dumps\"$using:procmon_filename /Minimized /Runtime $using:total_time
|
||||||
|
}
|
||||||
|
|
||||||
|
#Start-Job -Name kill-procmon -ScriptBlock {
|
||||||
|
#sleep -Seconds $using:total_time
|
||||||
|
#
|
||||||
|
#taskkill /IM "Procmon64.exe" /F
|
||||||
|
#Stop-Job -Name procmon
|
||||||
|
#exit
|
||||||
|
#}
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# Wireshark blocks
|
||||||
|
#------------------------------------------------------------
|
||||||
|
Start-Job -Name wireshark -ScriptBlock {
|
||||||
|
$using:wireshark_drive
|
||||||
|
cd $using:wireshark_location
|
||||||
|
./WiresharkPortable -k -i Ethernet0 -f "$using:wireshark_filter" -a duration:$using:total_time -w $using:working_directory"\dumps\"$using:wireshark_filename
|
||||||
|
}
|
||||||
|
|
||||||
|
Start-Job -Name kill-wireshark -ScriptBlock {
|
||||||
|
sleep -Seconds $using:total_wireshark_time
|
||||||
|
taskkill /IM "Wireshark.exe" /F
|
||||||
|
Stop-Job -Name wireshark
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# Procdump blocks
|
||||||
|
#------------------------------------------------------------
|
||||||
|
#
|
||||||
|
if ($take_service_dumps) {
|
||||||
|
Start-Job -Name procdump_EFT_service -ScriptBlock {
|
||||||
|
$using:working_drive
|
||||||
|
cd $using:working_directory"\procdump"
|
||||||
|
./procdump.exe -n $using:number_of_dumps -s $using:total_procdump_time -ma cftpstes.exe $using:working_directory"\dumps" -accepteula
|
||||||
|
timeout /T $using:total_procdump_time_close
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($take_gui_dumps) {
|
||||||
|
Start-Job -Name procdump_gui_service -ScriptBlock {
|
||||||
|
$using:working_drive
|
||||||
|
cd $using:working_directory"\procdump"
|
||||||
|
./procdump.exe -n $using:number_of_dumps -s $using:total_procdump_time -ma cftpsai.exe $using:working_directory"\dumps" -accepteula
|
||||||
|
timeout /T $using:total_procdump_time_close
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
}
|
100
powershell/test_reconnect_ARM.ps1
Normal file
100
powershell/test_reconnect_ARM.ps1
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Use EFT's COM interface to configure ARM settings for auditing and reporting.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Use EFT's COM interface to check status of ARM and reconnect if needed
|
||||||
|
|
||||||
|
.PARAMETER serverName
|
||||||
|
|
||||||
|
.PARAMETER eftAdminPort
|
||||||
|
|
||||||
|
.PARAMETER authMethod
|
||||||
|
|
||||||
|
.PARAMETER eftAdminName
|
||||||
|
|
||||||
|
.PARAMETER eftAdminPassword
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$False)][string]$serverName = "localhost",
|
||||||
|
[Parameter(Mandatory=$False)][int]$eftAdminPort = 1100,
|
||||||
|
[Parameter(Mandatory=$False)][int]$authMethod = 1,
|
||||||
|
[Parameter(Mandatory=$False)][string]$eftAdminName = "",
|
||||||
|
[Parameter(Mandatory=$False)][string]$eftAdminPassword = ""
|
||||||
|
)
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# Setup logging to a file
|
||||||
|
#------------------------------------------------------------
|
||||||
|
#Output <DATE> <TIME> <UTC Offset>
|
||||||
|
Function getdate
|
||||||
|
{
|
||||||
|
Get-Date -Format "MM/dd/yyyy HH:mm:ss K "
|
||||||
|
}
|
||||||
|
$currenttime = getdate
|
||||||
|
|
||||||
|
#Path to log file
|
||||||
|
$Logfile = "C:\Users\jbranan\Desktop\ARM-Connection.log"
|
||||||
|
|
||||||
|
#Function to accept string input and append to $Logfile
|
||||||
|
Function LogWrite
|
||||||
|
{
|
||||||
|
Param ([string]$logstring)
|
||||||
|
|
||||||
|
Add-content $Logfile -value $logstring
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# login as admin
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
try {
|
||||||
|
$oServer = New-Object -ComObject 'SFTPComInterface.CIServer'
|
||||||
|
$oServer.ConnectEx( $serverName, $eftAdminPort, $authMethod, $eftAdminName, $eftAdminPassword );
|
||||||
|
Write-Host "connected"
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
$errorMessage = $_.Exception.Message;
|
||||||
|
Write-Host "failed to connect to server ${serverName}: ${errorMessage}"
|
||||||
|
Exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# get ARM settings
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
#Write-Output ("ARMServerName: {0}" -f $oServer.ARMServerName)
|
||||||
|
if ($oServer.ARMTestConnection())
|
||||||
|
{
|
||||||
|
Write-Output ('ARM Test Connection Succeeded.')
|
||||||
|
$logstring= $currenttime + 'ARM Test Connection Succeeded.'
|
||||||
|
LogWrite $logstring
|
||||||
|
if ($oServer.ARMReconnect())
|
||||||
|
{
|
||||||
|
Write-Output 'ARM Is Connected.'
|
||||||
|
$logstring= $currenttime + 'ARM Is Connected.'
|
||||||
|
LogWrite $logstring
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
write-output 'Failed To Reconnect ARM.'
|
||||||
|
$logstring= $currenttime + 'Failed To Reconnect ARM.'
|
||||||
|
LogWrite $logstring
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Write-Output ('ARM Test Connection Failed.')
|
||||||
|
$logstring=$currenttime + 'ARM Test Connection Failed.'
|
||||||
|
LogWrite $logstring
|
||||||
|
}
|
||||||
|
#$oServer.ARMReconnect()
|
||||||
|
#------------------------------------------------------------
|
||||||
|
# close resources
|
||||||
|
#------------------------------------------------------------
|
||||||
|
|
||||||
|
$oServer.Close()
|
||||||
|
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($oServer) | out-null
|
||||||
|
Remove-Variable oServer
|
25
python/Arcus admin.py
Normal file
25
python/Arcus admin.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import string
|
||||||
|
from random import choice
|
||||||
|
|
||||||
|
userlist = ['Firstname Lastname <example@example.com>',]
|
||||||
|
identifier = 'tstidt'
|
||||||
|
arcus_endpoint = '.arcusapp.globalscape.com'
|
||||||
|
print('***\n')
|
||||||
|
for user in userlist:
|
||||||
|
ul = user.lower()
|
||||||
|
characters = string.ascii_letters + '!#$+-?~' + string.digits
|
||||||
|
password = "".join(choice(characters) for x in range(16))
|
||||||
|
first, last, email = ul.split()
|
||||||
|
print('RDGW:')
|
||||||
|
print(first.title())
|
||||||
|
print(last.title())
|
||||||
|
print(first[0] + last + '_' + identifier )
|
||||||
|
strip_email = email.strip('<')
|
||||||
|
strip_email = strip_email.strip('>')
|
||||||
|
print(password + '\n')
|
||||||
|
print('Deployatron:')
|
||||||
|
print(identifier + arcus_endpoint)
|
||||||
|
print(strip_email)
|
||||||
|
print(first[0] + last + '_' + identifier)
|
||||||
|
print(password + '\n')
|
||||||
|
print('***\n')
|
24
python/appengen.py
Normal file
24
python/appengen.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
from datetime import date
|
||||||
|
|
||||||
|
time = date.today()
|
||||||
|
|
||||||
|
ln = input('What do you want the logger name to be?: ')
|
||||||
|
an = input('What do you want the appender name to be?: ')
|
||||||
|
ran = input('What is the real appender name in the EFT logging.cfg? Case sensitive!: ')
|
||||||
|
ll = input('What level do you want the logging to be?: ')
|
||||||
|
pre_str = 'log4cplus.appender.'
|
||||||
|
|
||||||
|
l1 = f'\n#{ln} logger {time}\n'
|
||||||
|
l2 = f'{pre_str}{an.lower()}=log4cplus::RollingFileAppender'
|
||||||
|
l3 = f'{pre_str}{an.lower()}.File=${{AppDataPath}}\\EFT-{ln}.log'
|
||||||
|
l4 = f'{pre_str}{an.lower()}.MaxFileSize=20MB'
|
||||||
|
l5 = f'{pre_str}{an.lower()}.MaxBackupIndex=5'
|
||||||
|
l6 = f'{pre_str}{an.lower()}.layout=log4cplus::TTCCLayout'
|
||||||
|
l7 = f'{pre_str}{an.lower()}.layout.DateFormat=%m-%d-%y %H:%M:%S,%q'
|
||||||
|
l8 = f'log4cplus.additivity.{ran}=false'
|
||||||
|
l9 = f'log4cplus.logger.{ran}={ll.upper()}, {an.lower()}\n'
|
||||||
|
|
||||||
|
llist = [ l1, l2, l3, l4, l5, l6, l7, l8, l9]
|
||||||
|
|
||||||
|
for obj in llist:
|
||||||
|
print(f'{obj}\r')
|
34
python/appengen2.py
Normal file
34
python/appengen2.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
from datetime import date
|
||||||
|
time = date.today()
|
||||||
|
|
||||||
|
ln = input('What do you want the logger name to be?: ')
|
||||||
|
an = input('What do you want the appender name to be?: ')
|
||||||
|
ran = input('What is are the real appender names in the EFT logging.cfg?\nDelimit by "," like this:\n sftp,smtp,workspaces Case sensitive!: ')
|
||||||
|
ran_list = []
|
||||||
|
if ',' in ran:
|
||||||
|
ran_list = ran.split(',')
|
||||||
|
ll = input('What level do you want the logging to be?: ')
|
||||||
|
pre_str = 'log4cplus.appender.'
|
||||||
|
l1 = f'\n#{ln} logger {time}\n'
|
||||||
|
l2 = f'{pre_str}{an.lower()}=log4cplus::RollingFileAppender'
|
||||||
|
l3 = f'{pre_str}{an.lower()}.File=${{AppDataPath}}\\EFT-{ln}.log'
|
||||||
|
l4 = f'{pre_str}{an.lower()}.MaxFileSize=20MB'
|
||||||
|
l5 = f'{pre_str}{an.lower()}.MaxBackupIndex=5'
|
||||||
|
l6 = f'{pre_str}{an.lower()}.layout=log4cplus::TTCCLayout'
|
||||||
|
l7 = f'{pre_str}{an.lower()}.layout.DateFormat=%m-%d-%y %H:%M:%S,%q'
|
||||||
|
l8 = ''
|
||||||
|
l9 = ''
|
||||||
|
|
||||||
|
if ran_list:
|
||||||
|
while ran_list:
|
||||||
|
ap = ran_list.pop()
|
||||||
|
l8 += f'log4cplus.additivity.{ap}=false\n'
|
||||||
|
l9 += f'log4cplus.logger.{ap}={ll.upper()}, {an.lower()}\n'
|
||||||
|
else:
|
||||||
|
l8 += f'log4cplus.additivity.{ran}=false\n'
|
||||||
|
l9 += f'log4cplus.logger.{ran}={ll.upper()}, {an.lower()}\n'
|
||||||
|
|
||||||
|
llist = [ l1, l2, l3, l4, l5, l6, l7, l8, l9]
|
||||||
|
|
||||||
|
for obj in llist:
|
||||||
|
print(f'{obj}\r')
|
38
python/countfolders.py
Normal file
38
python/countfolders.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import sqlite3
|
||||||
|
import logging
|
||||||
|
import logging.handlers
|
||||||
|
# make sure the slashes are forward
|
||||||
|
# create logger
|
||||||
|
filename = "C:/Users/jbranan/Desktop/temp/a/log.txt"
|
||||||
|
|
||||||
|
logger = logging.getLogger('sqllite')
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
# create console handler and set level to debug
|
||||||
|
ch = logging.handlers.RotatingFileHandler(filename, mode='a', maxBytes=20971520, backupCount=5, encoding=None, delay=False)
|
||||||
|
ch.setLevel(logging.INFO)
|
||||||
|
|
||||||
|
# create formatter
|
||||||
|
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||||
|
|
||||||
|
# add formatter to ch
|
||||||
|
ch.setFormatter(formatter)
|
||||||
|
|
||||||
|
# add ch to logger
|
||||||
|
logger.addHandler(ch)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
db = "C:/Users/jbranan/Desktop/temp/a/SiteConfig.e05dd013-0099-47c5-a727-dc0285e74204.db"
|
||||||
|
query = r"""
|
||||||
|
SELECT count(PathLowered)
|
||||||
|
FROM FSEntry
|
||||||
|
WHERE PathLowered LIKE '%az%';
|
||||||
|
"""
|
||||||
|
|
||||||
|
conn = sqlite3.connect(db)
|
||||||
|
c = conn.cursor()
|
||||||
|
c.execute(query)
|
||||||
|
data = c.fetchone()[0]
|
||||||
|
logger.info(f'{data} %az%')
|
||||||
|
conn.close()
|
9
python/eftcom-getusedspace.py
Normal file
9
python/eftcom-getusedspace.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import win32com.client as win32
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
server = win32.gencache.EnsureDispatch('SFTPCOMInterface.CIServer')
|
||||||
|
server.ConnectEx('192.168.4.14', 1100, 0, 'a', 'QjIlmT4H')
|
||||||
|
|
||||||
|
a = server.ICIClientSettings.GetUsedSpace
|
||||||
|
|
||||||
|
print(a)
|
5
python/eftcom.py
Normal file
5
python/eftcom.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import win32com.client as win32
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
server = win32.gencache.EnsureDispatch('SFTPCOMInterface.CIServer')
|
||||||
|
server.ConnectEx('localhost', 1100, 0, 'scripting', 'password')
|
10
python/file_replicator.py
Normal file
10
python/file_replicator.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
from shutil import copyfile
|
||||||
|
templatefile = "C:/tmp/work/test_12722-16345_1gb.txt"
|
||||||
|
output_folder = "C:/tmp/work/output/"
|
||||||
|
|
||||||
|
fs, fl = templatefile.split('.')
|
||||||
|
if '/' in fs:
|
||||||
|
fs = fs.split('/')[-1]
|
||||||
|
for i in range(16):
|
||||||
|
destfilename = f'{output_folder}{i}{fs}.{fl}'
|
||||||
|
copyfile(templatefile, destfilename)
|
37
python/filecreator.py
Normal file
37
python/filecreator.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import os
|
||||||
|
import string
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
now = datetime.now() # current date and time
|
||||||
|
tm = now.strftime("X%mX%dX%y-X%HX%MX%S").replace('X0','X').replace('X','')
|
||||||
|
|
||||||
|
file = 'test'
|
||||||
|
ext = '.txt'
|
||||||
|
# Must be forward slashes
|
||||||
|
outputdirectory = 'C:/tmp/work/'
|
||||||
|
fsize = '1gb'
|
||||||
|
|
||||||
|
go = True
|
||||||
|
class Del:
|
||||||
|
def __init__(self, keep=string.digits + '.'):
|
||||||
|
self.comp = dict((ord(c),c) for c in keep)
|
||||||
|
def __getitem__(self, k):
|
||||||
|
return self.comp.get(k)
|
||||||
|
DD = Del()
|
||||||
|
fname = f'{file}_{tm}_{fsize}{ext}'
|
||||||
|
|
||||||
|
if 'k' in fsize.lower():
|
||||||
|
unit = float(1024)
|
||||||
|
fsizecal = unit * float(fsize.translate(DD))
|
||||||
|
elif 'm' in fsize.lower():
|
||||||
|
unit = float(1048576)
|
||||||
|
fsizecal = unit * float(fsize.translate(DD))
|
||||||
|
elif 'g' in fsize.lower():
|
||||||
|
unit = float(1073741824)
|
||||||
|
fsizecal = unit * float(fsize.translate(DD))
|
||||||
|
else:
|
||||||
|
print("For Kilobytes please use kb or k\nFor Megabytes please use mb or m\nFor Gigabytes please use gb or g")
|
||||||
|
go = False
|
||||||
|
|
||||||
|
if go:
|
||||||
|
os.system(f'fsutil.exe file createnew {outputdirectory}{fname} {int(fsizecal)}')
|
11
python/fix_8.0.4_workspaces_db.py
Normal file
11
python/fix_8.0.4_workspaces_db.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import sqlite3
|
||||||
|
|
||||||
|
# make sure the slashes are forward
|
||||||
|
db = "C:/Users/jbranan/Desktop/SiteConfig.94e925b5-6120-4d85-8660-60a74a495361.db.old-broken"
|
||||||
|
query = """PRAGMA foreign_keys = 0; CREATE TABLE sqlitestudio_temp_table AS SELECT * FROM Participation; DROP TABLE Participation; CREATE TABLE Participation( id BLOB NOT NULL, ParticipationInfo TEXT NOT NULL, InvitationInfo TEXT NOT NULL, Files TEXT NOT NULL, Workspace BLOB, Client BLOB, Secret TEXT NOT NULL, Invitation BLOB, PRIMARY KEY ( id), CONSTRAINT Client_fk FOREIGN KEY ( Client ) REFERENCES Client (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, CONSTRAINT Workspace_fk FOREIGN KEY ( Workspace ) REFERENCES Workspace (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, CONSTRAINT Invitation_fk FOREIGN KEY ( Invitation ) REFERENCES Invitation (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED ); INSERT INTO Participation ( id, ParticipationInfo, InvitationInfo, Files, Workspace, Client, Secret, Invitation ) SELECT id, ParticipationInfo, InvitationInfo, Files, Workspace, Client, Secret, Invitation FROM sqlitestudio_temp_table; DROP TABLE sqlitestudio_temp_table; CREATE INDEX Participation_Client_i ON Participation ( "Client" ); CREATE INDEX Participation_Secret_i ON Participation ( "Secret" ); PRAGMA foreign_keys = 1;"""
|
||||||
|
|
||||||
|
conn = sqlite3.connect(db)
|
||||||
|
c = conn.cursor()
|
||||||
|
c.executescript(query)
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
32
python/gen_json.py
Normal file
32
python/gen_json.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# You can change these, make suure file_path always has forward slashes
|
||||||
|
# and make sure to double up backslashes in the output folder
|
||||||
|
file_path = 'C:/Users/klowery/Desktop/reports/'
|
||||||
|
#output_folder = '\\\\file.core.windows.net\\gsbshared\\AdminSite\\ARMDB-Output'
|
||||||
|
output_folder = 'C:\\Users\\klowery\\Desktop\\reports'
|
||||||
|
user = 'a'
|
||||||
|
ipaddress = '8.8.8.8'
|
||||||
|
|
||||||
|
#Dont change these
|
||||||
|
file_list = ['ActivityAdhocDetailed','EventRulesActivityDetailed','TransactionsTable',
|
||||||
|
'AuthenticationsTable','ExecutiveSummary','TroubleshootingEventRuleFailures',
|
||||||
|
'AdminActions','FailedLogins','WorkspacesActivity',
|
||||||
|
'AdminActivitySummary','ProtocolCommandsTable','TrafficIpWiseConnections',
|
||||||
|
'AllFiles','TrafficConnectionsSummary','ActivityByUserDetailed','TroubleshootingIpAddressActivityDetailed']
|
||||||
|
additional_parameter = ''
|
||||||
|
additional_value = ''
|
||||||
|
additional_string = f',"{additional_parameter}":"{additional_value}"'
|
||||||
|
|
||||||
|
for file_name in file_list:
|
||||||
|
fobj = file_path + file_name + '.json'
|
||||||
|
with open(fobj, 'w') as f:
|
||||||
|
if file_name == 'ActivityByUserDetailed':
|
||||||
|
additional_parameter = 'User'
|
||||||
|
additional_value = user
|
||||||
|
file_contents = f'{{"Days":"1","Report":"{file_name}","UseInterimFile":true,"OutputFolder":"{output_folder}"{additional_string}}}'
|
||||||
|
elif file_name == 'TroubleshootingIpAddressActivityDetailed':
|
||||||
|
file_contents = f'{{"Days":"1","Report":"{file_name}","UseInterimFile":true,"OutputFolder":"{output_folder}"{additional_string}}}'
|
||||||
|
additional_parameter = 'ipAddress'
|
||||||
|
additional_value = ipaddress
|
||||||
|
else:
|
||||||
|
file_contents = f'{{"Days":"1","Report":"{file_name}","UseInterimFile":true,"OutputFolder":"{output_folder}"}}'
|
||||||
|
f.write(file_contents)
|
39
python/hotfix.py
Normal file
39
python/hotfix.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# No Touchy
|
||||||
|
file_list = []
|
||||||
|
build_list = True
|
||||||
|
|
||||||
|
# Change to what ever you would like the extention of the name to be in the instructions.
|
||||||
|
rn_ext = '.old'
|
||||||
|
|
||||||
|
while build_list:
|
||||||
|
file_name = input('Name of file? If done, type d: ')
|
||||||
|
if file_name == 'd':
|
||||||
|
build_list = False
|
||||||
|
else:
|
||||||
|
file_list.append(file_name)
|
||||||
|
|
||||||
|
header_line = 'Hotfix Instructions:'
|
||||||
|
print(header_line)
|
||||||
|
line_counter = 1
|
||||||
|
service_off = f'{line_counter}.WARNING: Shut off the service on all nodes!'
|
||||||
|
print(service_off)
|
||||||
|
|
||||||
|
line_counter += 1
|
||||||
|
for fn in file_list:
|
||||||
|
if fn == file_list[0]:
|
||||||
|
main_line_rn = f'{line_counter}.Rename {fn} to {fn}{rn_ext} on all nodes. You can determine the location of this file by looking at the registry here:\n\t(HKEY_LOCAL_MACHINE\\SOFTWARE\WOW6432Node\\GlobalSCAPE Inc.\\EFT Server Enterprise) \n\tThe default location for this file is in the "C:\\Program Files (x86)\\Globalscape\\EFT Server Enterprise\\ directory".'
|
||||||
|
print(main_line_rn)
|
||||||
|
else:
|
||||||
|
alt_line_rn = f'{line_counter}.Rename {fn} to {fn}{rn_ext} in that same folder on all nodes.'
|
||||||
|
print(alt_line_rn)
|
||||||
|
line_counter += 1
|
||||||
|
for fnc in file_list:
|
||||||
|
alt_line_c = f'{line_counter}.Copy the {fnc} file into the respective directories on all nodes.'
|
||||||
|
print(alt_line_c)
|
||||||
|
line_counter += 1
|
||||||
|
|
||||||
|
validate_hotfix = f'{line_counter}.Verify the hotfix has been deployed by right clicking on the files in the destination and going to the details tab. Confirm the "Product version" property has a hotfix number.'
|
||||||
|
print(validate_hotfix)
|
||||||
|
line_counter += 1
|
||||||
|
service_on = f'{line_counter}.Start the service.'
|
||||||
|
print(service_on)
|
21
python/injectadmin.py
Normal file
21
python/injectadmin.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import sqlite3
|
||||||
|
|
||||||
|
# make sure the slashes are forward
|
||||||
|
db = "//192.168.2.21/Vault/testing stuff/ServerConfig.db"
|
||||||
|
query = """
|
||||||
|
INSERT OR REPLACE INTO "main"."Admin" ("id", "Name", "NameLowered", "Type", "LastActiveTime", "PasswordHash", "PasswordIsTemporary", "PasswordChangedTime", "PasswordHistory", "UnlockTime", "InvalidLoginAttempts", "Permissions") VALUES (X'b76a1d7bc3ad5ac4863606ce71ba3af3', 'Local computer\\Administrators', 'local computer\\administrators', '2', '1607536951', '', '1', '1607536951', '[]', '0', '[]', '{
|
||||||
|
"ACLs": [],
|
||||||
|
"Level": "Server",
|
||||||
|
"ManageCom": true,
|
||||||
|
"ManagePersonalData": true,
|
||||||
|
"ManageReporting": true,
|
||||||
|
"RestAccess": true,
|
||||||
|
"RestAdminRole": "server_full_access",
|
||||||
|
"SettingsTemplates": []
|
||||||
|
}');"""
|
||||||
|
|
||||||
|
conn = sqlite3.connect(db)
|
||||||
|
c = conn.cursor()
|
||||||
|
c.execute(query)
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
17
python/installer_crawler.py
Normal file
17
python/installer_crawler.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Requirements
|
||||||
|
# Copy all of the files from the W:\Installers folder to any local folder on the laptop
|
||||||
|
# Build a manifest
|
||||||
|
# Determine the difference between the current W:\Installers and the destination manifest
|
||||||
|
# RSYNC?
|
||||||
|
# importing required packages
|
||||||
|
import os
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
tm = now.strftime("X%mX%dX%y-X%HX%MX%S").replace('X0','X').replace('X','')
|
||||||
|
# defining source and destination
|
||||||
|
# paths
|
||||||
|
src = 'W:/installers'
|
||||||
|
trg = 'C:/Users/jbranan/Downloads/installers'
|
||||||
|
logfile = f'C:/Users/jbranan/Desktop/RC_log_{tm}.log'
|
||||||
|
|
||||||
|
os.system(f'Robocopy {src} {trg} /V /E /r:1 /w:15 /log+:{logfile} /XO /NP')
|
35
python/nc_analysis_fast.py
Normal file
35
python/nc_analysis_fast.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import time
|
||||||
|
import platform
|
||||||
|
|
||||||
|
full_list = True
|
||||||
|
results_value = 10
|
||||||
|
version = platform.architecture()
|
||||||
|
print(version[0])
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
|
d = {}
|
||||||
|
|
||||||
|
print('Building username appearance totals...')
|
||||||
|
# 71.50.132.89 - -, [28/Jan/2021:00:44:22 +0530] "user root" 331 0,
|
||||||
|
with open('C:/Users/jbranan/Desktop/temp/h/Global_support/Logs/nc210121.log', encoding='utf8') as file_object:
|
||||||
|
for line in file_object.readlines():
|
||||||
|
if not '#' in line and '] "user ' in line:
|
||||||
|
username = line.split('] "user ')[1].split('" ')[0]
|
||||||
|
if not username in d and not username.startswith('-'):
|
||||||
|
d[username] = 1
|
||||||
|
elif not username.startswith('-'):
|
||||||
|
d[username] += 1
|
||||||
|
elif '/' in username:
|
||||||
|
continue
|
||||||
|
|
||||||
|
d = sorted(d.items(), key=lambda x: x[1], reverse=True)
|
||||||
|
|
||||||
|
if full_list:
|
||||||
|
for username in d:
|
||||||
|
print(f'User: {username[0]} - Appearances: {username[1]}')
|
||||||
|
|
||||||
|
else:
|
||||||
|
for username in d[:results_value]:
|
||||||
|
print(f'User: {username[0]} - Appearances: {username[1]}')
|
||||||
|
|
||||||
|
print("--- %s seconds ---" % (time.time() - start_time))
|
75
python/parseSiteRoot.py
Normal file
75
python/parseSiteRoot.py
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
import string
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
currDir = ""
|
||||||
|
|
||||||
|
lines = []
|
||||||
|
|
||||||
|
folders = defaultdict(int)
|
||||||
|
foldersOldFiles = defaultdict(int)
|
||||||
|
|
||||||
|
parsedCurrentDir = []
|
||||||
|
|
||||||
|
while True:
|
||||||
|
in_line = sys.stdin.readline()
|
||||||
|
if not in_line:
|
||||||
|
break
|
||||||
|
|
||||||
|
in_line = in_line[:-1]
|
||||||
|
|
||||||
|
#m = re.search("Directory: (.*)$", in_line)
|
||||||
|
m = re.search("gsbdata.InetPub.(.*)$", in_line)
|
||||||
|
if m:
|
||||||
|
currDir = m.group(1)
|
||||||
|
currDir = currDir.lstrip().rstrip()
|
||||||
|
|
||||||
|
# folder names split across lines
|
||||||
|
while True:
|
||||||
|
in_line = sys.stdin.readline()
|
||||||
|
in_line = in_line[:-1]
|
||||||
|
in_line = in_line.lstrip().rstrip()
|
||||||
|
if(in_line == ''):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
currDir = currDir + in_line
|
||||||
|
|
||||||
|
#folders[currDir] = 0
|
||||||
|
parsedCurrDir = re.split(r'\\', currDir)
|
||||||
|
#print(currDir)
|
||||||
|
continue
|
||||||
|
|
||||||
|
#continue
|
||||||
|
|
||||||
|
if in_line.startswith("-a----"):
|
||||||
|
arr = re.split("\s+", in_line)
|
||||||
|
filelen = int(arr[4]) #string.atoi(arr[4])
|
||||||
|
for i in range(0, len(parsedCurrDir)):
|
||||||
|
f = r'\\'.join(parsedCurrDir[0:i])
|
||||||
|
folders[f] = folders[f] + filelen
|
||||||
|
|
||||||
|
if arr[1].endswith("2019") or arr[1].endswith("2018"):
|
||||||
|
for i in range(0, len(parsedCurrDir)):
|
||||||
|
f = r'\\'.join(parsedCurrDir[0:i])
|
||||||
|
foldersOldFiles[f] = foldersOldFiles[f] + filelen
|
||||||
|
|
||||||
|
for kv in folders.items():
|
||||||
|
#print(kv)
|
||||||
|
formattedOldFilesLen = "{:15d}".format(foldersOldFiles[kv[0]])
|
||||||
|
formattedLen = "{:15d}".format(kv[1])
|
||||||
|
if 0 != kv[1]:
|
||||||
|
percent = 100.0 * float(foldersOldFiles[kv[0]])/float(kv[1])
|
||||||
|
else:
|
||||||
|
percent = float(0.0)
|
||||||
|
|
||||||
|
line = "%s %s %s%% %s" % (formattedOldFilesLen, formattedLen, "{:6.2f}".format(percent), kv[0])
|
||||||
|
lines.append(line)
|
||||||
|
|
||||||
|
lines.sort()
|
||||||
|
lines.reverse()
|
||||||
|
for line in lines:
|
||||||
|
print(line)
|
||||||
|
|
6
python/password.py
Normal file
6
python/password.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import string
|
||||||
|
from random import *
|
||||||
|
|
||||||
|
characters = string.ascii_letters + '!#$+-?~' + string.digits
|
||||||
|
password = "".join(choice(characters) for x in range(16))
|
||||||
|
print(password)
|
10
python/updateawepath.py
Normal file
10
python/updateawepath.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import sqlite3
|
||||||
|
|
||||||
|
db = "C:/Users/jonbr/OneDrive/pyprojects/work.py/update values in sqllite/SiteConfig.33ffaac4-ee37-4fb3-95a2-928ae6333757.db"
|
||||||
|
awe_path = '\\\\file.core.windows.net\\gsbslogs\\AWE\\'
|
||||||
|
|
||||||
|
conn = sqlite3.connect(db)
|
||||||
|
c = conn.cursor()
|
||||||
|
c.execute(f"UPDATE AdvancedWorkflow set settings = json_set(AdvancedWorkflow.Settings, '$.LogDir', '{awe_path}')")
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
Loading…
x
Reference in New Issue
Block a user