Это то, что я пробовал до сих пор:
$Path="C:\Users\Desktop\test.json"
$json=(Get-Content $Path | ConvertFrom-Json).parameters.FileArray
//FileArray is array name in json file
$demo=$json.GetType().FullName //System.Object[]
foreach($file in Get-ChildItem "D:\A\DF\ls\" -Include $json|ForEach Object{$_} -Recurse){
Write-Output $file.BaseName
Write-Output $file.FullName
Set-AzureRmDataFactoryV2LinkedService -DataFactoryName "adfg1" - ResourceGroupName "bgc" -Name $file.BaseName -DefinitionFile $file.FullName -Force
}
Json Я использую test.json:
{
"параметры":
{
"FileArray": [
"ABC.json",
"DEF.json"]
}
}
Исключение, которое я получаю:
ForEach-Object: Невозможно связать параметр 'RemainingScripts'. Не могу конвертировать
значение "-Recurse" типа "System.String" для
введите "System.Management.Automation.ScriptBlock".
Что я ожидаю (имена файлов):
ABC.json
DEF.json
Any help how it can be handled.
How I can iterate over array values from json.
P.S: I am beginner in powershell