VINOD KUMAR
VINOD KUMAR

Reputation: 315

How to update the module files in an automation account?

Is there a way to update the module files in an Automation Account while executing the script?

For Example, I have the below snippet of code to update the module files in my local machine.

$path = $env:USERPROFILE + "\Documents\WindowsPowerShell\Modules\**\*\Framework\Abstracts\**.ps1"
$item = Get-ChildItem -Path "$path"
$Content = Get-Content -LiteralPath $item.FullName

$newContent = ""
$Content | ForEach-Object {
if ( $_ -match 'response = ""')
{
"match"
$_ = $_.replace('response = ""', 'response = "y"')
}
$newContent += $($_ + "`r`n" )
}
Set-Content -Value $newContent -LiteralPath $item.FullName

Is it possible to run the above script in a runbook to update the automation account modules?

If not, how to update the module files in an automation account while executing the script?

Where are all the modules stored? Any suggestions would be greatly appreciated.

Upvotes: 1

Views: 881

Answers (2)

Henrik
Henrik

Reputation: 342

My az.account module had latest runtime version but did not upgrade module version so I asked MS support.

To get latest module version I needed to install from here. https://www.powershellgallery.com/packages/Az.Accounts/2.15.1

enter image description here

Upvotes: 0

Doris Lv
Doris Lv

Reputation: 3398

I'm afraid you can't run your script above in a runbook. As we can see, your path includes your own environment variables and local path, which azure cannot recognize.

For Import custom modules, there are three ways, you can have a look at this link.

Actually you can configure modules directly in portal. Navigate to your automation account, find Modules and Modules gallery under Shared Resources. enter image description here Click the Module you need, such as Az. You will see the page below. Then click import. enter image description here

Upvotes: 1

Related Questions