I am new to PowerShell. I am trying to use data from 2 files in a set command. Tried the below. But it gives an error. AppName.txt has multiple application names and CollName.txt has its Collection Names. I want to use both the files in the below code. Any help would be really appreciated. Thanks in advance.
Error:
Set-CMApplicationDeployment : Cannot convert ‘System.Object’ to the type ‘System.String’ required by parameter
‘ApplicationName’. Specified method is not supported.
At line:1 char:46
Assuming you have more than one application and more than one collection in your input files you will need a nested loop to create deployments for all apps for all collections.
Olaf is right.
you have two collections and you can’t simply use two collecitons as the parameter.
you should use foreach to read every name in collecitons.
It depends pretty much on the content of the files you’re using to provide the ApplicationName and the CollectionName.
You could output both to the console and check if they exist actually. And you could try to add a -Verbose swtich to your command to get more information.
Hi Olaf, Iam sorry. The foreach loop is working. It has made the required changes. However, the above mentioned error message is still showing. I think this is because for each application name in AppName.txt, the script is executing against all the collections available in CollName.txt. Each application should execute only once against its respective collection. Is it possible?
That’s an essential information. You should have mention that in your initial question.
Everything is possible.
But in that case having two unrelated txt files is the worst condition you can have. You should save the applications and the according collections together in a csv file.
Here’s an example: I will name the file “ApplicationsAndCollections.csv” and it will have this content: