---
title: "How to address the error \"ConvertTo-SecureString : Key not valid for use in specified state.\" in the Citrix Integration solution"
description: "The error occurs when the Citrix password is not encrypted by the Netprobe user. Encrypt the Citrix password using the Netprobe user to resolve the issue."
url: "https://docs.itrsgroup.com/docs/faq/geneos/360019392897-geneos-how-to-address-the-error-convertto-securestring-key-not-valid-for-use-in-specified-state-in-the-citrix-integration-solution/index.html"
---
## Cause

One may encounter the following error when setting up the Geneos Citrix Integration template for the first time:

```
<Wed Apr 7 21:32:28> ERROR: TOOLKIT2 ConvertTo-SecureString : Key not valid for use in specified state.

At C:\Program Files\NetprobeNT gelo 6371\citrix-sessions.ps1:18 char:14

- $secpasswd = ConvertTo-SecureString -String $password

- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- CategoryInfo : InvalidArgument: (:) [ConvertTo-SecureString], CryptographicException

- FullyQualifiedErrorId : ImportSecureString_InvalidArgument_CryptographicError,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand

New-Object : Exception calling ".ctor" with "2" argument(s): "Cannot process argument because the value of argument

"password" is null. Change the value of argument "password" to a non-null value."

At C:\Program Files\NetprobeNT gelo 6371\citrix-sessions.ps1:21 char:12

- $mycreds = New-Object System.Management.Automation.PSCredential($user ...

- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException

- FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

Invoke-RestMethod : Unable to connect to the remote server

At C:\Program Files\NetprobeNT gelo 6371\citrix-sessions.ps1:24 char:15

- ... essions = $(Invoke-RestMethod -Uri $($endpoint + '/Sessions/' + $ses ...

- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException

- FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
```

This happens when the Citrix password is not encrypted by the Netprobe user. For example:

- The password was encrypted using the "Administrator" user account
- The Netprobe ran as the "localgeneos" user account

### Solution

Encrypt the Citrix password using the Netprobe user.


