Hello,
I can get the individual usernames/passwords of a session but the list is not working.
$rdmSession = get-RDMSession | Where-Object { $_.Name -like "*Admin O365*"} | ForEach-Object {
$O365Username = Get-RDMSessionUserName -Session $rdmSession
$O365ClearPassword = Get-RDMSessionPassword -Session $rdmSession -AsPlainText
Write-Output $O365Username
Write-Output $O365ClearPassword
}
Where is the mistake?
Thanks in advance.
Hello,
It's not possible to refer to the variable set at the first statement within a pipeline. And using the pipeline, there is no need to save the first command in a variable.
$PSItem or $_ can be used to refer to the variable sent to the pipeline. Here is an interesting article about $PSItem and $_ pipeline variables.
Try this one instead.
get-RDMSession | Where-Object { $_.Name -like "*Admin O365*"} | ForEach-Object {
$O365Username = Get-RDMSessionUserName -Session $PSItem
$O365ClearPassword = Get-RDMSessionPassword -Session $PSItem -AsPlainText
Write-Output $O365Username
Write-Output $O365ClearPassword
}
Let me know if that helps.
Best regards,
Érica Poirier