I have this line of code:
invoke-command -Session $s -scriptblock {Set-Adgroup $using:ListBox1.SelectedItem -add @{proxyaddresses="$using:smtps"}}
$s is legitimate session, $listbox.selecteditem is for example a dist group called Old-Sales-Users , and $smtps is a string array like so: @smtps = "smtp:[email protected]", "smtp:[email protected]", "smtp:[email protected]"
i want to invoke this command so i can add those smtps to the proxyaddresses of the dist group. but the way this works here is that its adding the 3 strings to the same line so i get one line proxyaddress with "smtp:[email protected] smtp:bla2@bla...." i want it to create 3 seperate lines (or more if there's more in that array) meaning like an ENTER is pressed after each item in the array... my second question is if thats the correct way to be doing this? because i actually open 3 invoke commands is there a way using 1 invoke command to add all that array to the proxyaddress?
Thank you
"double-quotes around$using:smpts$using:ListBox1.SelectedItem, maybe try$GroupName = $ListBox1.SelectedItem.DistinguishedNameand then pass$using:GroupNametoSet-ADGroupinside the remote script block-Add @{proxyaddresses= [string[]]$using:smtps}