I'm trying to get multiple RDP session opening using a Powershell Script, i'm opening the sessions for the first time, to check if everything is ok and apply the Redirect Folder Stategy.
Here is the Powershell script i'm using (copied from a forum and modified a bit):
# Comma separated list: Computer,User,Password
$listRaw = Get-Content -Path C:\Folder\Script\RDP.txt
# Parse CSV list
$list = $listRaw | ConvertFrom-CSV -Delimiter ','
# Iterate targets
foreach ($target in $list) {
Write-Host "Connecting to $($target.Computer) as $($target.User)"
# Creating credential from username and password
$SecurePassword = $target.Password | ConvertTo-SecureString -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $target.User, $SecurePassword
# Creating remote session to that computer
# Using given credentials
$session = New-PSSession -ComputerName $target.Computer -Credential $Credentials
}
I'm getting this error :
C:\Folder\Script\rdp.ps1:17 : 16
+ ... $session = New-PSSession -ComputerName $target.Computer -Credential ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : ServerNotTrusted,PSSessionOpenFailed
And saying that somehow the server does not belong to Trusted Hosts, but i'm using the script on the Remote Desktop Server itself... I dont understand how it cannot trust itself...
I'm sorry as my knowledge in powershell is limited, i wanted to try it out instead of opening each session manually, which can be boring... I may have made an obvious mistake, but i couldnt find answers looking up for this error... And i don't know what else to look for...
Thanks for any help provided !
Cheers
Jean.
PS: Please feel free to report any grammar mistakes, english is not a language i am fluent in...