I was runningt hrough examples from Jason’s Lynda.com course on PS 5 and get an error trying to use Copy-Item in a ForEach-Object loop
PS C:\> $servers | foreach-object {Copy-Item -Credential $creds .\cl21163_Groups.txt -Destination \\$_\C$\ } The FileSystem provider supports credentials only on the New-PSDrive cmdlet. Perform the operation again without specifying credentials. At line:1 char:29 + ... ch-object {Copy-Item -Credential $creds .\cl21163_Groups.txt -Destin ...
What am I doing wrong here? His example doesn’t require creds but my servers do. I have my creds stored in a variable.
thanks