Author Posts

March 29, 2017 at 8:13 am

I'm trying to define a variable in psSessionConfigurationFile that holds some object (result of import-clixml cmdlet) but it's being casted to string automatically and all I get is an original object type name.

Any ideas?


March 29, 2017 at 8:59 am

can you show us the code?

March 29, 2017 at 9:22 am

New-PSSessionConfigurationFile -Path C:\temp\sample.pssc -Author Me -VariableDefinitions @{Name="SomeConf";Value=(Import-Clixml C:\Windows\bib\sysprep\GetCompConfig.cfg)} 
Register-PSSessionConfiguration -Name Test -ShowSecurityDescriptorUI -Path C:\temp\sample.pssc
etsn (hostname) -ConfigurationName test
@{ComputerName=ICT-211-4736; NetAdapterName=Local Area Connection; NetAdapterDescription=Intel(R) Ethernet Connection I217-LM; NetAdapterIndex=7; IP=; Subnet=; Router=; DNS=;10.35.

And I can't cast it back to [pscustomobject]

Or with [pscredential]

[pscredential]::new("SomeUser",(ConvertTo-SecureString -Force -AsPlainText "RidiculouslySecurePassword")) | Export-Clixml C:\temp\secureCreds.xml
New-PSSessionConfigurationFile -Path C:\temp\sample1.pssc -VariableDefinitions @{Name="Creds";Value=(Import-Clixml C:\temp\secureCreds.xml)} 
Register-PSSessionConfiguration -Path C:\temp\sample1.pssc -Name Test1

etsn (hostname) -ConfigurationName Test1 

[ICT-211-4736]: PS C:\Users\admin_osmilos\Documents> $Creds

[ICT-211-4736]: PS C:\Users\admin_osmilos\Documents> 

Best regards