Alex
asked on
Yet another, arduous powershell question
$computers = Get-content 'C:\Powershell Projects\lastconnect\New Text Document.txt'
Foreach ($computer in $computers)
{Copy-Item -Path '\\$Computer\Program Files (x86)\Quest Software\Toad for Oracle 10.5\ClientFiles\QSAuth11.key' -Destination 'c:\programs\powershell projects\$computer.txt'}
Afternoon,
So the script above, I know I can't put the variable in like that, but I can't find or figure out how to get it to work the way I need it to.
Could you help at all?
Cheers
Alex
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect
Note: It would have been sufficient to use "\\$Computer\c$\...", but that only works if parsing allows for clear detection where the variable name ends. "\\${Computer}\c$\..." is more safe, but then it is not far from generally using "$($Computer)\c$\...", which technically uses a subexpression ( $(...) is a subexpression, allowing for expressions).
ASKER
So it was the $ at the start and the double quotes..
I even put double quotes in to start but then thought I'd go with the single quotes.... Woe is me :(
Right,
I'm up to this now
Open in new window