Tuesday, March 31, 2026

A powershell script to update rustdesk in action 1

For maintaining remote access for our IT systems we use a mix of action1 and rustdesk.  Though action1 has a very good remote web interface it can be slow at times.  I've setup a rustdesk server for additional security.  Below is a powershell script that I created.  

The script creates a folder for downloading rustdesk from github; and if it isn't there create it, download and install.  There is a else where if it is installed, uninstall rustdesk then create the install directory and install the latest version.


$Folder = 'c:\#NAMEOFFOLDER'

"Test to see if folder [$Folder]  exists"

if (Test-Path -Path $Folder) {

Remove-Item -Recurse -Force c:\#NAMEOFFOLDER\*.*

Remove-Item 'c:\#NAMEOFFOLDER'

Get-CimInstance -ClassName win32_product | Where-Object Name -Match "RustDesk" | 

    ForEach-Object -Process { 

        Invoke-CimMethod -InputObject $_ -Name Uninstall 

                            }

New-Item -Path "c:\" -Name "#NAMEOFFOLDER" -ItemType "directory"

Invoke-WebRequest https://github.com/rustdesk/rustdesk/releases/download/1.4.6/rustdesk-1.4.6-x86_64.msi -OutFile c:\saplit\rustdesk-1.4.0-x86_64.msi

$pkg = "c:\#NAMEOFFOLDER\rustdesk-1.4.0-x86_64.msi";

Start-Process msiexec "/i $pkg /norestart /qn" -Wait;

##Start-Process msiexec "/i $pkg /qn" -Wait;

##Start-Process msiexec "/i $pkg /norestart /qn" -Wait;

Start-Sleep -Seconds 30

Remove-Item -Recurse -Force c:\#NAMEOFFOLDER\*.*

Remove-Item 'c:\#NAMEOFFOLDER'


} else {

#uninstall rustdesk

Get-CimInstance -ClassName win32_product | Where-Object Name -Match "RustDesk" | 

    ForEach-Object -Process { 

        Invoke-CimMethod -InputObject $_ -Name Uninstall 

                            }

New-Item -Path "c:\" -Name "#NAMEOFFOLDER" -ItemType "directory"

Invoke-WebRequest https://github.com/rustdesk/rustdesk/releases/download/1.4.6/rustdesk-1.4.6-x86_64.msi -OutFile c:\saplit\rustdesk-1.4.0-x86_64.msi

$pkg = "c:\#NAMEOFFOLDER\rustdesk-1.4.0-x86_64.msi";

Start-Process msiexec "/i $pkg /norestart /qn" -Wait;

##Start-Process msiexec "/i $pkg /qn" -Wait;

##Start-Process msiexec "/i $pkg /norestart /qn" -Wait;

Start-Sleep -Seconds 30

Remove-Item -Recurse -Force c:\#NAMEOFFOLDER\*.*

Remove-Item 'c:\#NAMEOFFOLDER'

}

Monday, March 30, 2026

Removing a VM from Hyper-V High Availability cluster

 To remove a virtual machine from a Hyper-V High Availability cluster is really relatively trivial, so long as you don't have any system on the cluster in failover, you right click on the role and click remove



You will then be prompted; asking if you want to remove the role and you select YES.


Then the system is removed from the cluster and is operating on the host the VM was assigned to run to.




Wednesday, March 11, 2026

Automating SQL Data Dump and SFTP File Transfer with Powershell and WinSCP on Windows



We work with a third party that takes care of a few systems for us that we automated and to make that work we had to script an automated process to export data from our SQL server and automatically upload it to an SFTP Server.

For this setup we are using WINSCP for doing the file transfer and a combination of a bat file and powershell for exporting the data out of SQL and automating the process.  I am using windows for automating this process.

What will be required:



So install powershell and WINSCP on to the system.  

Open powershell as and administrator and install the Clobber the WINSCP Module and the SQLServer module

Install-Module -Name PowershellGet
Install-Module -Name SQLServer
Install-Module -Name WinSCP

Once done we will make two files, they will be running from the same directory.
SQLDataExport.ps1 and gen_sql_data.bat
The powershell file is fairly straight forward. It essentially gets and runs the sql query and saves it to a directory as a txt or csv.

SQLDataExport.ps1

$serverInstance = "$address, $port" 
$databaseName = "$databaseName" 
$Username = "$databaseUser" 
 $Password = "$databasePassword" 
$filePath = "$PATH\$FILENAME" + (Get-Date).ToString("yyyyMMddTHHmmss") + ".txt" 

Import-Module SqlServer 

$sqlQuery = "$YOURSQLQUERY" 

Invoke-Sqlcmd -ServerInstance $serverInstance -Username $Username -Password $Password -Database $databaseName -TrustServerCertificate -Query $sqlQuery | Out-File $filePath -Encoding UTF8


BatFile (This is where all the FTP Magic happens)

@ECHO OFF
powershell.exe -executionpolicy remotesigned -File $PATHTOPOWERSHELLSCRIPT.ps1

timeout /t 120

echo "FTP Started" >> seed_exReport.rpt
date /t >> exReport.rpt
time /t >> exReport.rpt
echo option batch abort > ftpPutCmds.txt
echo option confirm off >> ftpPutCmds.txt


echo open sftp://$USERNAME@$SFTPURL -privatekey=$SFTPPRIVATEKEY.ppk -passphrase=$PASSWORD -hostkey=acceptnew >> ftpPutCommands.txt
echo option transfer binary >> ftpPutCmds.txt
echo cd seed >> ftpPutCmds.txt
echo put $SQLDATA_*.txt >> ftpPutCmds.txt
echo close >> ftpPutCmds.txt
echo exit >> ftpPutCmds.txt


"C:\Program Files (x86)\WinSCP\WinSCP.exe" /console /script=ftpPutCmds.txt /log="$PATH2Error.log" /loglevel=1* /logsize=5*100M
echo "FTP Finished" >> seed_exReport.rpt
IF EXIST *.txt (move *SQLDATA_*.txt Old\) REM move old file to a folder called old
date /t >> exReport.rpt
time /t >> exReport.rpt
echo. >> exReport.rpt

Once done you can setup the task scheduler to run the batfile.  You will need the script to start in the directory that the bat file and powershell file are in.

Tuesday, January 13, 2026

Allowing Windows 11 Access to Unauthenticated Shares

Windows 11 prevents you from accessing open SMB shares because they are a security risk.  However sometimes you need to access these unauthenticated shares for a variety of reasons.  Here is how you do that.





Method 1: Use the Local Group Policy Editor 
  1. Open the search menu and type gpedit.msc, then select "Edit group policy" to open the Local Group Policy Editor.
  2. Navigate to Computer Configuration > Administrative Templates > Network > Lanman Workstation.
  3. Find and double-click the policy named "Enable insecure guest logons".
  4. Select "Enabled," click "Apply," and then "OK".
  5. Restart your computer for the changes to take effect. 

Method 2: Use the Registry Editor 
  1. Open the search menu, type regedit, and press Enter to open the Registry Editor.
  2. Navigate to the following path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters.
  3. In the right-hand pane, find the AllowInsecureGuestAuth value. If it doesn't exist, right-click in an empty space, select New > DWORD (32-bit) Value, and name it AllowInsecureGuestAuth.
  4. Double-click AllowInsecureGuestAuth, set the "Value data" to 1, and click "OK".
  5. Close the Registry Editor and restart your computer. 


Monday, October 27, 2025

Enabling Java Virtual Console on Windows 11 and Windows Server

I wrote a post about bypassing Java MD5 to run Java KVM viewer, well now to get it to run on the latest version of java and Windows you need to disable it completely or have an alternative to using the iKVM Viewer.

With the MD5 algorithm disabled with the new java, you get an application error attempting to launch the iKVM Viewer as shown below.


To resolve the issue you need to open a text editor program as administrator on windows and browse to your JAVA directory a typical default example is 

"C:\Program Files (x86)\Java\jre-1.8\lib\security\"

Open java.security

an go to line 694 and disable the jdk.jar.disabedAlgorithms by putting a # in front of the line as shown below.






You will then be able to run the iKVM viewer as shown below.



Friday, September 12, 2025

Replacing a drive and repairing a storage spaces volume

When you have a drive fail in a storage spaces, changing out the drive isn't straight forward, however well worth the effort when you consider the advantages storage spaces has over regular RAID.  Specifically the lack of a an expensive disk controller, and tiered spaces with the use of HDDs and SSDs.


So in my case it is a 2U server with a RAID Controller set to JOBD, and I had a failure of a Seagate drive as shown in the picture above.  On the server we removed the bad physical drive, if on a raid controller prepare the drive, should be set to JOBD.  Formatting may be required.  As shown in image below, I added a Toshiba drive; and to replace it we need to the the following.


PS C:\> $PDToRemove = Get-PhysicalDisk -FriendlyName "$DISKNAME" 

In this case the drive's friendly name is "SEAGATE ST600MP0006" then we need to remove the disk with the following Powershell statement.

PS C:\> Remove-PhysicalDisk -PhysicalDisks $PDToRemove -StoragePoolFriendlyName "$PoolName"

(in this case SEAGATE ST600MP0006)


Once the old disk is removed we can run a repair with the following powershell statement

PS C:\>Repair-VirtualDisk -FriendlyName "$VIRTALDISK"


This will take some time to run, but it is much faster then repairing a RAID setup, taking about 20 minutes to repair the storage spaces mirror setup.  While the dive is being repaired you will see it in a InService status.


When storage spaces finishes the drive will show as being in good health.



Thursday, September 11, 2025

Troubleshooting Edifact Import Files on SirsiDynix Horizon ILS

Some libraries use edifact files for automating purchasing from different vendors.  In this case acquisition librarian uses an FTP client to download and load the edifact file into the ILS.  Errors can easily happen where you can then no longer access the invoice from the vendor and a new edifact file must be issued and imported into horizon.

What is an Edifact File?

The UN/EDIFACT Syntax Rules were approved as the ISO standard ISO 9735 by the International Standardization Organization.


The EDIFACT standard provides:

  • a set of syntax rules to structure data

  • an interactive exchange protocol (I-EDI)

  • standard messages which allow multi-country and multi-industry exchange


Read more about it here

Edifact File Sample

UNA:+.? '

UNB+UNOC:3+###:###+####:###+250903:1557+B000025704'

UNH+B000025707+INVOIC:D:###:UN:EAN008'

Header

BGM+380+#####+43'

DTM+137:20250903:102'

NAD+BY+####::###'

NAD+SU+#####::###'

NAD+SU+++Name.+Address .+City+Province+PostalCode+Country'

CUX+2:CAD:4'

Vendor Info

LIN+000001'

IMD+L+050+:::Library MARC - CUSTOM'

ALC+C++++ABK::28'

QTY+$$$$'

MOA+####'

RTE+Quantity:1.07'

RFF+LI:'

PO/Item Info

UNS+S'

CNT+2:8'

MOA+####'

TAX+7+GST'

MOA+#####'


Summary

UNT+69+B000025707'

UNZ+1+B000025704'

Footer


The UNB number the B number MUST match the B number in UNZ, also the UNH B number MUST match the UNZ B number.  These are unique identifiers for the invoice generated by the vendor.  If there is an issue with the import of an invoice such as cancelled items on the PO, or any other error you will need to get a new Edifact file from the vendor.


How to check the error on edifact files in Horizon


To check for errors on edifact imports (uploads) you need to view them in table Editor



Double click table editor to open up the search and type in edifact



Then select double click on “edifact exceptions” and scroll to the bottom for the most recent errors.  You will want to look for the errors highlighted in Green, not errors stating the edifact file has already been uploaded.





If you try import a file and it fails do the following:


  1. Ask the vendor for a new Edifact File with new header numbers.  (Once you try import it once it can not be imported again with the same header numbers)

  2. Check the PO in horizon, verify everything is ok and there is nothing cancelled, etc.

  3. Check for error codes in table editor using the edifact exceptions view

  4. Either fix the PO or remove the troublesome line in the edifact file using Notepad.

  5. Once the PO or the edifact file is fixed, reimport (upload) the file into horizon.


Additional Error info:


If you get an error like Process Invoice Error PO/Line, means there is a mismatch with the PO and the invoice, and the PO in Horizon needs to be fixed or an item in the edifact file needs to be removed shown in the example in orange.  Verify the PO in horizon before trying to re-import the edifact file in Horizon.   The PO either needs to be corrected or remove anything that is not in the PO in the edifact file.


Unfortunately you have to go back to the vendor and ask for a new edifact file because there was an error on import and a new header needs to be generated so the Unique identifier matches what the vendor gives for the import and once a file has been imported it can not be easily deleted in Horizon.


A powershell script to update rustdesk in action 1

For maintaining remote access for our IT systems we use a mix of action1 and rustdesk.  Though action1 has a very good remote web interface ...