Hello!
we work in a big company and have a lot of clouds which are isolated from each other, each cloud is reachable via one jumphost which is reachable and accessible from the local network. Each cloud contains a lot of hosts which are only reachable from the jumphost.
I need to readout or change files etc. from/on the hosts inside the clouds.
I have tried the following to make it work (hostname1 = jumphost, hostname2 = host inside the cloud):
$s = New-PSSession -ComputerName hostname1 -credential ad\username
Import-PSSession -Session $s -CommandName Invoke-Command, New-PSSession -prefix RS
$p = New-RSPSSession -ComputerName hostname2 -credential ad\username
Invoke-RSCommand -session $p -ScriptBlock {Get-ChildItem C:\}
remove-RSpssession $p
remove-pssession $s
It fails with the following error:
Der Parameter "Session" kann nicht gebunden werden. Der Wert "[PSSession]Session1" vom Typ
"Deserialized.System.Management.Automation.Runspaces.PSSession" kann nicht in den Typ
"System.Management.Automation.Runspaces.PSSession" konvertiert werden.
+ CategoryInfo : InvalidArgument: (:) [Invoke-Command], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.InvokeCommandCommand
+ PSComputerName : hostname1
The following works without problems (it's only a readout of the jumphost):
$cred = Get-Credential ad\username -Message "Geben Sie das Passwort fr den Server ein"
$gh = New-PSSession -ComputerName hostname1 -Credential $cred
$sb1 = {Get-ChildItem C:\}
$result = Invoke-Command -Session $gh -ScriptBlock $sb1
I have also tried to nest New-PSSession in invoke-command from here on to reach the host in the cloud, which also fails with an error.
I have tried a lot of things and searched through google to find a solution, but I have to seek your assistance and hope somebody is able to help me.
Thanks a lot!
Regards,
Marc
- Edited by Marc Tschapek Friday, August 28, 2015 11:09 AM