Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script for automapping of a port #37

Open
ddkooker2 opened this issue Jan 31, 2022 · 0 comments
Open

Script for automapping of a port #37

ddkooker2 opened this issue Jan 31, 2022 · 0 comments

Comments

@ddkooker2
Copy link

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 = "[email protected]"
#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
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant