Forum / Remote Desktop Manager - Macro/Script/Tools

Create sessions spreadsheet or delimited file?

  • Create an Issue
  • Cancel

Is there a way to create seessions based off of a excel spreadsheet or a delimited file. I support multiple locations and rather then manually creating a connection for each site I would like to supply a list of IPs and have a connection created for each one. Any help would be appreciated.

Clock7 yrs

You can use the (File -> Import -> Import Session csv wizard) for simple csv imports. If it's not a simple csv, PowerShell is the way to go.


Stefane Lavergne


9-17-2013 10-09-53 AM.jpg
Clock7 yrs

I hope this does complicate things even more but if you want a function that will import an excel document directly this is one I found about a year a go. In other words I didn't write this but have found it very useful.

function Import-Excel
param (
[bool]$DisplayProgress = $true

if ($FileName -eq "") {
throw "Please provide path to the Excel file"

if (-not (Test-Path $FileName)) {
throw "Path '$FileName' does not exist."

$FileName = Resolve-Path $FileName
$excel = New-Object -com "Excel.Application"
$excel.Visible = $false
$workbook = $$FileName)

if (-not $WorksheetName) {
Write-Warning "Defaulting to the first worksheet in workbook."
$sheet = $workbook.ActiveSheet
} else {
$sheet = $workbook.Sheets.Item($WorksheetName)

if (-not $sheet)
throw "Unable to open worksheet $WorksheetName"

$sheetName = $sheet.Name
$columns = $sheet.UsedRange.Columns.Count
$lines = $sheet.UsedRange.Rows.Count

Write-Warning "Worksheet $sheetName contains $columns columns and $lines lines of data"

$fields = @()

for ($column = 1; $column -le $columns; $column ++) {
$fieldName = $sheet.Cells.Item.Invoke(1, $column).Value2
if ($fieldName -eq $null) {
$fieldName = "Column" + $column.ToString()
$fields += $fieldName

$line = 2

for ($line = 2; $line -le $lines; $line ++) {
$values = New-Object object[] $columns
for ($column = 1; $column -le $columns; $column++) {
$values[$column - 1] = $sheet.Cells.Item.Invoke($line, $column).Value2

$row = New-Object psobject
$fields | foreach-object -begin {$i = 0} -process {
$row | Add-Member -MemberType noteproperty -Name $fields[$i] -Value $values[$i]; $i++
$percents = [math]::round((($line/$lines) * 100), 0)
if ($DisplayProgress) {
Write-Progress -Activity:"Importing from Excel file $FileName" -Status:"Imported $line of total $lines lines ($percents%)" -PercentComplete:$percents

Clock3 yrs