Hi
I’m probably just making a very simple mistake here but the following line works:
$PSSessionList = New-PSSession -ComputerName CACDC01,CACDC03,CACDS01,CACFPS -Credential (Get-Credential -UserName “$env:USERDOMAIN$env:USERNAME” -Message “Please enter credentials for $env:USERDOMAIN”)
However, when I try to do the following it fails:
$ComputerList = “CACDC01,CACDC03,CACDS01,CACFPS”
$PSSessionList = New-PSSession -ComputerName $ComputerList -Credential (Get-Credential -UserName “$env:USERDOMAIN$env:USERNAME” -Message “Please enter credentials for $env:USERDOMAIN”)
How can I get New-PSSession to take a list I build up dynamically and then open a possession to them?
In the end I will check what computers on the network has been discovered, open a session to them and run a bunch of commands on them.