Script for automapping of a port
Opened this issue · 0 comments
Goodday,
I hope someone can help me with an issue that i am having with the MeshCentralRouter. What i am trying to script (with powershell) is a mapping of a RDP connection without the need for entering a password when it is run. This coudl then also be used to auto-map a port for specific functions or monitoring when there is no vpn access to a location.
Whitin Powershell I use the ConvertFrom-SecureString to save a password file in my script directory and a ConvertTo-SecureString to read it back into a variable to be used when connecting to Meshcentral.
but when i run the script somehow the router does not recognize my password. It looks like it cannot read it form a secure powershell string? Is there a way to fix/work around this or how would you advise me to do this.
My script so far: (I removed my personal information for privacy)
`
This script is used for setting up a remote desktop connection with MeshCentral Router.
Use the command below to generate the password file in the folder (Place this together with this script)
Variables
Set-Location -Path $PSScriptRoot
$hostname = "mesh.example.com"
$username = "danny@example.com"
#Password
if (!(Test-Path .\Password.txt)) {
ECHO "ERROR: Password file is not generated... Generating file"
Read-Host "Enter Meshcentral Password" -AsSecureString | ConvertFrom-SecureString | Out-File ".\Password.txt"
$password = Get-Content ".\Password.txt" | ConvertTo-SecureString
}
else {
$password = Get-Content ".\Password.txt" | ConvertTo-SecureString
}
$password
Start the connection to the MeshCentral server
if (!(Test-Path .\MeshCentralRouter.exe)) {
ECHO "Error: MeshCentralRouter.exe was not found. Please download the application from the Meshcentral server before conecting"
BREAK
}
.\MeshCentralRouter.exe -debug
-host:$hostname -user:$username
-pass:$password
`