Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (30 sloc) 1.62 KB
#Requires -Version 3.0
#Requires -Module AzureRM.Resources
Param(
[Parameter(Mandatory=$true)]
[string] $dscConfigFile,
[string] $dscAutomationAccount,
[string] $dscResourceGroup,
[bool] $Force = $false
)
Function Import-DscConfiguration ($dscConfigFile, $dscAutomationAccount, $dscResourceGroup) {
$dscConfigFileFull = (Get-Item $dscConfigFile).FullName
$dscConfigFileName = [io.path]::GetFileNameWithoutExtension($dscConfigFile)
$dsc = Get-AzureRmAutomationDscConfiguration -ResourceGroupName $dscResourceGroup -AutomationAccountName $dscAutomationAccount -Name $dscConfigFileName -erroraction 'silentlycontinue'
if ($dsc -and !$Force) {
Write-Information -MessageData "Configuration $dscConfigFileName Already Exists"
} else {
Write-Information -MessageData "Importing & compiling configuration $dscConfigFileName"
Import-AzureRmAutomationDscConfiguration -AutomationAccountName $dscAutomationAccount -ResourceGroupName $dscResourceGroup -Published -SourcePath $dscConfigFileFull -Force
$CompilationJob = Start-AzureRmAutomationDscCompilationJob -ResourceGroupName $dscResourceGroup -AutomationAccountName $dscAutomationAccount -ConfigurationName $dscConfigFileName -ConfigurationData $ConfigData
while($null -eq $CompilationJob.EndTime -and $null -eq $CompilationJob.Exception)
{
$CompilationJob = $CompilationJob | Get-AzureRmAutomationDscCompilationJob
Start-Sleep -Seconds 3
Write-Information -MessageData "."
}
Write-Information -MessageData "!"
$CompilationJob | Get-AzureRmAutomationDscCompilationJobOutput
}
}
Import-DscConfiguration $dscConfigFile $dscAutomationAccount $dscResourceGroup
You can’t perform that action at this time.