-1

I need your help

Set-ClientAccessServer -AutoDiscoverSiteScope Location1,Location2,etc.....

I'll use a txt file where I add locations and need help to tweak the command so I only need to write:

Set-ClientAccessServer -AutoDiscoverSiteScope | Get-Content -path C:\txtfile

Hope you know what i mean BR

sugaa337
  • 13
  • 1
  • [1] if you want to send the content of a file to the cmdlet ... you need to load the file FIRST. ///// [2] also, the docs show how to ADD to the existing sites. use something like this >>> `@{Add="Value1","Value2"...;` << – Lee_Dailey Mar 15 '21 at 14:38

1 Answers1

1

In PowerShell, to incorporate the returned objects of one command as parameters to a second, enclose the first command in parentheses (). Assuming that you are passing these locations to the -AutoDiscoverSiteScope parameter, your command would be

Set-ClientAccessServer -AutoDiscoverSiteScope (Get-Content -Path C:\TxtFile)
Jeff Zeitlin
  • 7,808
  • 2
  • 17
  • 31
  • Nicely done; since variations of this problem keep coming up, I've been trying to put a "canonical" answer together at https://stackoverflow.com/a/41254359/45375, which also explains how unquoted tokens are parsed as arguments in general. (The premise of the linked question is a different one, but it also boils down to needing `(...)`.) – mklement0 Mar 15 '21 at 14:37
  • The answer at the link is well-written, but it's what I generally describe as "information dense", and it can be difficult to find a particular use case in it. I don't know if SO allows it (probably not, just because of traffic levels), but at least one other stack I'm on allows posting of "Tips for ..." as 'questions', where the 'question' is an introductory remark, and the 'answers' are simple FAQ-type Q-and-A entries. I'd give serious thought to that format, if it's allowed here. – Jeff Zeitlin Mar 15 '21 at 14:54
  • Yes, there's a lot packed into that answer, but I've tried to mitigate the problem of readers getting lost by showcasing two examples and a brief explanation at the top, with the comprehensive discussion in an "optional reading" section. What you're describing sounds interesting, and it has in at least one case that I know of been done here as well, as a community effort: [Reference - What does this regex mean?](https://stackoverflow.com/q/22937618/45375). – mklement0 Mar 15 '21 at 15:04
  • 1
    That's the sort of thing I'm thinking of, but with (multiple) shorter answers - an example would be [**Tips for golfing in APL**](https://codegolf.stackexchange.com/questions/17665/tips-for-golfing-in-apl/) over at CodeGolf. – Jeff Zeitlin Mar 15 '21 at 15:08