Forum Discussion

__Martin__'s avatar
__Martin__
Copper Contributor
Aug 12, 2020

Why does Powershell say that my variables are empty or null?

Dear Techcommunity

I wanted to ask why my Script keeps on saying that these variables are empty or null. the following variables are affected:

 

$pcname = 'server01'
$RDdestfile = "C:\Scripts\Cert\Certificate_04.pfx"
$ThumbprintPath = 'RDS:\GatewayServer\SSLCertificate\Thumbprint'

 

 As you can see, these Variables clearly have something in them.

Here is where I want to use them:

 

$RemoteSession = New-PSSession -ComputerName $pcname -Credential $cred
        Invoke-Command -Session $RemoteSession -ScriptBlock {
            Import-PfxCertificate -FilePath $RDdestfile -CertStoreLocation $CertLocation
            $certificate = Get-PfxCertificate -FilePath $RDdestfile
            Import-Module RemoteDesktopServices
            Set-Item -Path $ThumbprintPath -Value $certificate.Thumbprint -ErrorAction Stop
        }

 

 

I hope you can help me

 

Greetings

 

Martin

Resources