Forum Discussion
sivaponaka
Dec 30, 2019Copper Contributor
Unable to Pass variable value to For each loop
Hello Everyone, I'm new to Poweshell, Someone tell what's wrong in below code? i want to pass $server value to for each loop but below code is failing #getServerList $Servers = Invoke-Sql...
oliwer_sundgren
Jan 07, 2020Iron Contributor
Hello sivaponaka
Sadly im no SQL expert.
But, if you run "Write-output $server" do you get any output and does it look correct?
Also, what error do you get when trying to run the code?
Kind Regards
Oliwer Sjöberg
- sivaponakaJan 07, 2020Copper Contributor
Thanks for your time oliwer_sundgren
My issue got resolved after adding parameterized property as below to code.
foreach($Server in $Servers.server_name)
- oliwer_sundgrenJan 07, 2020Iron Contributor
No problem! sivaponaka
Ah thats nice! Good job 🙂