Hello kind people! Some help would be greatly appreciated for a PS enthusiast and an absolute beginner.
I am trying to set a bunch of string values/computernames which I imported from a csv file.
I used this command to have strings:
Know I wolud like to feed that to "Set-Item wsman:\localhost\Client\TrustedHosts -Value" all at once so I can PSRemote to these machines in a workgroup environment which I trust.
I can't seem to accomplish this.
I can't figure it out how to do it. Please advise.
Guess it is because the Value field within WSMAN is expecting the value to be in the format of "computer1,computer2,computer3"
but from what you say you have a list of computernames like this
I recon you need for format it properly to a new variable string and then pass the new variable to the set-item command.
Hope this helps.
you wrote an entire function? thank you for sharing this.
Thank you very much. This is awesome!
In fact all I needed is the piece of code in your function where I put my import-csv -path c:\csvfile.csv | select-object computername -expandproperty computrername in a variable and created another variable and used " join ',' " with the first one.
I fed that to set-item parameter "-value" and it worked. What a rookie thing not to know the "join" operator to join a bunch of imported strings and delimited them with commas.
Well I didn't konw how to do it and I wanted to use a "oneliner".
thank you once more.
You must be logged in to reply to this topic.