Importing software licenses entry from CSV

Importing software licenses entry from CSV

avatar

Hello,

I'm trying to import software licenses into RDM from a CSV via the following script:

$lineno = 0


Get-Content "C:\License.csv" | ForEach-Object {


$lineno = $lineno + 1


$fields = $_.split(",")


$group = $fields[0]

$name = "Software License"

$exp = $fields[1]

$count = $fields[2]



$session = New-RDMSession -Type "DataEntry" -Name $name;


Set-RDMSession -Session $session -Refresh;


Update-RDMUI;


Set-RDMSessionProperty -ID $session.ID -Property "Group" -Value $group

Set-RDMSessionProperty -ID $session.ID -Path "DataEntry" -Property "ConnectionTypeInfos" -Value "Serial"


Update-RDMUI;


Set-RDMSessionProperty -ID $session.ID -Path "DataEntry" -Property "SoftwareExpiration" -Value $exp

Set-RDMSessionProperty -ID $session.ID -Path "DataEntry" -Property "SoftwareLicenseCount" -Value $count

Set-RDMSessionProperty -ID $session.ID -Path "DataEntry" -Property "SoftwareHidden" -Value $false


Update-RDMUI;


}


However, I keep getting the following failures:

Set-RDMSessionProperty : Object of type 'System.String' cannot be converted to type 'Devolutions.RemoteDesktopManager.Business.DataEntryConnectionTypeInfo[]'.
At C:\Users\Dennis\Desktop\RDM Powershell\RDM License.ps1:22 char:1
+ Set-RDMSessionProperty -ID $session.ID -Path "DataEntry" -Property "C ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-RDMSessionProperty], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,RemoteDesktopManager.PowerShellModule.SetRDMSessionPropertyCommand

Set-RDMSessionProperty : Object of type 'System.String' cannot be converted to type 'System.Nullable`1[System.DateTime]'.
At C:\Users\Dennis\Desktop\RDM Powershell\RDM License.ps1:26 char:1
+ Set-RDMSessionProperty -ID $session.ID -Path "DataEntry" -Property "S ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-RDMSessionProperty], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,RemoteDesktopManager.PowerShellModule.SetRDMSessionPropertyCommand

Set-RDMSessionProperty : Object of type 'System.String' cannot be converted to type 'System.Int32'.
At C:\Users\Dennis\Desktop\RDM Powershell\RDM License.ps1:27 char:1
+ Set-RDMSessionProperty -ID $session.ID -Path "DataEntry" -Property "S ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-RDMSessionProperty], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,RemoteDesktopManager.PowerShellModule.SetRDMSessionPropertyCommand

Set-RDMSessionProperty : Object of type 'System.Boolean' cannot be converted to type 'Devolutions.RemoteDesktopManager.DefaultBoolean'.
At C:\Users\Dennis\Desktop\RDM Powershell\RDM License.ps1:28 char:1
+ Set-RDMSessionProperty -ID $session.ID -Path "DataEntry" -Property "S ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-RDMSessionProperty], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,RemoteDesktopManager.PowerShellModule.SetRDMSessionPropertyCommand

Any help would be greatly appreciated. Thank you!

All Comments (3)

avatar

Hello,

All Data entry types are quite different than other entries as it needs to first create its own object.

Here is what you have to do to create such entry with the RDM PowerShell module.

$dataEntryConnectionType = New-Object Devolutions.RemoteDesktopManager.Business.DataEntryConnectionTypeInfo
$dataEntryConnectionType.DataEntryConnectionType = [Devolutions.RemoteDesktopManager.DataEntryConnectionType]::Serial

$session = New-RDMSession -Type "DataEntry" -Name $name
$session.DataEntry.ConnectionTypeInfos = $dataEntryConnectionType 
Set-RDMSession -Session $session -Refresh


Then, you should be able to update the properties of the Serial Data entry.

Best regards,

Érica Poirier

avatar

Thank you! That worked in created that licence data entry. I'm still getting an error when adding the expiration and count to their fields. Error thrown is the following:

et-RDMSessionProperty : Object of type 'System.String' cannot be converted to type 'System.Nullable`1[System.DateTime]'.
At C:\Users\Dennis\Desktop\RDM Powershell\RDM License.ps1:26 char:1
+ Set-RDMSessionProperty -ID $session.ID -Path "DataEntry" -Property "S ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-RDMSessionProperty], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,RemoteDesktopManager.PowerShellModule.SetRDMSessionPropertyCommand

Set-RDMSessionProperty : Object of type 'System.String' cannot be converted to type 'System.Int32'.
At C:\Users\Dennis\Desktop\RDM Powershell\RDM License.ps1:27 char:1
+ Set-RDMSessionProperty -ID $session.ID -Path "DataEntry" -Property "S ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-RDMSessionProperty], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,RemoteDesktopManager.PowerShellModule.SetRDMSessionPropertyCommand

avatar

Hello,

These two errors happen because the type of your variables are string instead of datetime and int32.

Please try these at the beginning of your script and that should solve your issue.

[datetime]$exp = $fields[1]

[int]$count = $fields[2]


Best regards,

Érica Poirier