An Azure service that is used to automate, configure, and install updates across hybrid environments.
To make the deployment for runbook via PowerShell and using multiple variable, I used for each loop
Previous version was this
if ((Test-Path "path\runBookName-Variable.ps1"))
{
$runBookRemoteScriptVariable = "runBookName-Variable-ps1"
$runBookRemoteScriptName = "runBookName-Variable.ps1"
}
}
Current more flexible way is this:
$targetVarFiles = @(Get-ChildItem "path\nameofrunbook-variable*.*")
if ($targetvarfiles.Count -gt 0)
{
foreach ($targetFile in $targetvarfiles) {
$baseName = $targetFile.BaseName
$extension = $targetFile.Extension -replace '.','-'
[string] $runBookRemoteScriptVariable = ($baseName + $extension)
#get the correct file content from target file
[string] $script = Get-Content -Path $targetFile -Raw -Encoding "UTF8"
#create automation variable and deploy it to Azure (below link for this)
https://learn.microsoft.com/en-us/azure/automation/shared-resources/variables?tabs=azure-powershell
}
}