Author Posts

April 18, 2017 at 7:20 am

Is there anything related to installing acronis (Backup software) remotely on many machines and also configuring them like giving servernname,type of backup,etc.(all the things that the installation wizard of acronis ask).I know we can install using package resource but that will just install not do the settings part.

Please reach out if you need more clarification on question

April 18, 2017 at 4:09 pm

Not really. If there are switches or parameters you can use to configure those settings then you might be able to use a package resource. DSC is meant to be a configuration management platform, not a software deployment mechanism.

April 18, 2017 at 7:08 pm

You could also contribute an AcronisDSC module to the PowerShell Gallery. This would give you more flexibility than Package or Script, and the benefit of authoring a DSC module rather than other platforms is your contribution benefits anyone using any configuration management tool (DSC, Puppet, Chef, Ansible, etc).

April 19, 2017 at 4:47 am

like a custom resource?

April 19, 2017 at 7:47 am

Function Install-AcronisRemotely
{
[CmdletBinding(SupportsShouldProcess = $True)]
Param
(
[Parameter (Mandatory=$True,
ValueFromPipeline=$True,
ValueFromPipelineByPropertyName=$True,
HelpMessage='Input the computer name(s), separated by commas, on which to run the command')]
[Alias('host')]
[string[]]$Computername,

[Parameter (Mandatory=$False,
ValueFromPipeline=$True,
ValueFromPipelineByPropertyName=$True,
HelpMessage='Input credentials with which to run the command')]
[Alias('user')]
[System.Management.Automation.CredentialAttribute()]$Credential = "$env:USERDOMAIN\$env:USERNAME",

[Parameter (Mandatory=$True,
ValueFromPipeline=$True,
ValueFromPipelineByPropertyName=$True,
HelpMessage='Input the Acronis server name')]
[Alias('server')]
[string]$AcrServer,

[Parameter (Mandatory=$True,
ValueFromPipeline=$True,
ValueFromPipelineByPropertyName=$True,
HelpMessage='Input the Acronis database name')]
[Alias('database')]
[string]$AcrDatabase,

[Parameter (Mandatory=$True,
ValueFromPipeline=$True,
ValueFromPipelineByPropertyName=$True,
HelpMessage='Input an account (domain\username) with administrative privileges on all computers listed in $Computername')]
[string]$LocalAccount,

[Parameter (Mandatory=$True,
ValueFromPipeline=$True,
ValueFromPipelineByPropertyName=$True,
HelpMessage='Input the password for $LocalAccount')]
[string]$LocalPassword,

[Parameter (Mandatory=$True,
ValueFromPipeline=$True,
ValueFromPipelineByPropertyName=$True,
HelpMessage='Input an account (domain\username) in the Acronis Remote Users group on the Acronis Server')]
[string]$AcrAccount,

[Parameter (Mandatory=$True,
ValueFromPipeline=$True,
ValueFromPipelineByPropertyName=$True,
HelpMessage='Input the password for $AcrAccount')]
[string]$AcrPassword,

[Parameter (Mandatory=$True,
ValueFromPipeline=$True,
ValueFromPipelineByPropertyName=$True,
HelpMessage='Input the file path to your Acronis install .MSI and .MST files')]
[Alias('folder','directory')]
[string]$Path

)
Begin
{
If (!$Credential)
{
Break
}
If ($Computername -like "*,*")
{
$Computername = @($Computername -split ",")
}
If (-not(Test-Path -Path "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\" -PathType Container))
{
New-Item -Path "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\" -ItemType Directory -Force -Verbose
}
}#end begin

Process
{
$date = Get-Date -Format MMM-dd-yyyy
ForEach ($Computer in $Computername)
{
If ((Get-WmiObject -Class Win32_ComputerSystem -ComputerName $Computer -Credential $Credential -Property SystemType).SystemType -like "*86*")
{
$AcronisPath = "\\$computer\C$\Program Files\Acronis\BackupAndRecovery\"
}
ElseIf ((Get-WmiObject -Class Win32_ComputerSystem -ComputerName $Computer -Credential $Credential -Property SystemType).SystemType -like "*64*")
{
$AcronisPath = "\\$computer\C$\Program Files (x86)\Acronis\BackupAndRecovery\"
}
Else
{
$AcronisPath = "\\$computer\C$\Program Files\Acronis\BackupAndRecovery\"
}
$InstallCountdownCore = 0
$InstallCountdownWindows = 0
If ((Test-Connection -ComputerName $Computer -Quiet) -eq $False)
{
Write-Host -ForegroundColor Yellow "Acronis was not installed. A network connection could not be established to $computer on $(Get-Date)"
"Acronis was not installed. A network connection could not be established to $computer on $(Get-Date)" | Out-File -FilePath "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\Acronis_Powershell_Install_$date.log" -Append
Write-Error "Acronis was not installed. A network connection could not be established to $computer on $(Get-Date)"
"Acronis was not installed. A network connection could not be established to $computer on $(Get-Date)" | Out-File -FilePath "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\Acronis_Powershell_Install_$date.log" -Append
Continue
}#end if
Else
{
Delete-ManagedMachine -Computername $Computer -AcrServer $AcrServer -AcrDatabase $AcrDatabase -Verbose
Try
{
$MSIFileCore = Get-ChildItem -Path $Path | Where-Object {$_.BaseName -like "*AcronisAgentCore*" -and $_.Extension -like ".msi"}
$MSTFileCore = Get-ChildItem -Path $Path | Where-Object {$_.BaseName -like "*AcronisAgentCore*" -and $_.Extension -like ".mst"}
$MSIFileWindows = Get-ChildItem -Path $Path | Where-Object {$_.BaseName -like "*AcronisAgentWindows*" -and $_.Extension -like ".msi"}
$MSTFileWindows = Get-ChildItem -Path $Path | Where-Object {$_.BaseName -like "*AcronisAgentWindows*" -and $_.Extension -like ".mst"}
Copy-Item -Path $($MSIFileCore.FullName) -Destination \\$Computer\C$\Windows\TEMP -Container -Force -Verbose
Copy-Item -Path $($MSTFileCore.FullName) -Destination \\$Computer\C$\Windows\TEMP -Container -Force -Verbose
Copy-Item -Path $($MSIFileWindows.FullName) -Destination \\$Computer\C$\Windows\TEMP -Container -Force -Verbose
Copy-Item -Path $($MSTFileWindows.FullName) -Destination \\$Computer\C$\Windows\TEMP -Container -Force -Verbose
}#end try
Catch
{
Write-Host -ForegroundColor Yellow "Acronis was not installed. The install file copy to $computer failed on $(Get-Date)"
"Acronis was not installed. The install file copy to $computer failed on $(Get-Date)" | Out-File -FilePath "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\Acronis_Powershell_Install_$date.log" -Append
Write-Error $Error[0]
$Error[0] | Out-File -FilePath "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\Acronis_Powershell_Install_$date.log" -Append
Continue
}#end catch

Try
{
$InstallStringCore = "msiexec.exe /i c:\windows\temp\$($MSIFileCore.Name) /quiet /l* c:\acronis-core_setup_$date.log TRANSFORMS=c:\windows\temp\$($MSTFileCore.Name)"
Write-Host -ForegroundColor Yellow "Starting MSI install for Acronis Agent Core..."
(Get-WMIObject -ComputerName $computer -Credential $Credential -List -Verbose | Where-Object {$_.Name -eq "Win32_Process"}).InvokeMethod("Create","$InstallStringCore")
}#end try
Catch
{
Write-Host -ForegroundColor Yellow "Acronis Agent Core was not installed on $computer. An error occurred during MSI installation check C:\acronis-core_setup_$date.log for further troubleshooting."
"Acronis Agent Core was not installed. An error occurred during MSI installation check C:\acronis-core_setup_$date.log for further troubleshooting." | Out-File -FilePath "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\Acronis_Powershell_Install_$date.log" -Append
Write-Error $Error[0]
$Error[0] | Out-File -FilePath "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\Acronis_Powershell_Install_$date.log" -Append
Continue
}#end catch

Write-Host -ForegroundColor Yellow -NoNewline "Searching for Acronis Agent Core Install log. Please wait..."
Do
{
Start-Sleep -Seconds 1
}#end do
Until ((Test-Path -Path "\\$computer\C$\acronis-core_setup_$date.log" -PathType Leaf) -eq $True)
"`r`n"

Write-Host -ForegroundColor Yellow "Querying log file for install progress..."
Do
{
$CoreLogContent = Get-Content -Path "\\$computer\C$\acronis-core_setup_$date.log" -ErrorAction SilentlyContinue
$InstallCountdownCore += 1
Start-Sleep -Seconds 1
Write-Progress -Id 1 -Activity "Installing Acronis Agent Core. Please wait..." -Status "Seconds elapsed: $InstallCountdownCore"
}#end do
Until (($CoreLogContent | Select-Object -Last 5) -like "*Logging stopped*" -and (Get-ChildItem -Path $AcronisPath -Force) -like "MMS.EXE")
Write-Progress -Id 1 -Activity "Installing Acronis Agent Core. Please wait..." -Completed
If ($CoreLogContent -like "*Installation failed*")
{
Write-Host -ForegroundColor Yellow "Acronis Agent Core was not installed on $computer. An error occurred during MSI installation check C:\acronis-core_setup_$date.log for further troubleshooting."
"Acronis Agent Core was not installed. An error occurred during MSI installation check C:\acronis-core_setup_$date.log for further troubleshooting." | Out-File -FilePath "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\Acronis_Powershell_Install_$date.log" -Append
Write-Host -ForegroundColor Magenta $($CoreLogContent | Select-Object -Last 3)
$($CoreLogContent | Select-Object -Last 3) | Out-File -FilePath "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\Acronis_Powershell_Install_$date.log" -Append
Continue
}#end if
"`r`n"

Try
{
$InstallStringWindows = "msiexec.exe /i c:\windows\temp\$($MSIFileWindows.Name) /quiet /l* c:\acronis-windows_setup_$date.log TRANSFORMS=c:\windows\temp\$($MSTFileWindows.Name)"
Write-Host -ForegroundColor Yellow "Starting MSI install for Acronis Windows Agent..."
(Get-WMIObject -ComputerName $computer -Credential $Credential -List -Verbose | Where-Object {$_.Name -eq "Win32_Process"}).InvokeMethod("Create","$InstallStringWindows")
}#end try
Catch
{
Write-Host -ForegroundColor Yellow "Acronis Windows Agent was not installed on $computer. An error occurred during MSI installation check C:\acronis-windows_setup_$date.log for further troubleshooting."
"Acronis Windows Agent was not installed. An error occurred during MSI installation check C:\acronis-windows_setup_$date.log for further troubleshooting." | Out-File -FilePath "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\Acronis_Powershell_Install_$date.log" -Append
Write-Error $Error[0]
$Error[0] | Out-File -FilePath "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\Acronis_Powershell_Install_$date.log" -Append
Continue
}#end catch

Write-Host -ForegroundColor Yellow -NoNewline "Searching for Acronis Windows Agent Install log. Please wait..."
Do
{
Start-Sleep -Seconds 1
}#end do
Until ((Test-Path -Path "\\$computer\C$\acronis-windows_setup_$date.log" -PathType Leaf) -eq $True)
"`r`n"

Write-Host -ForegroundColor Yellow "Querying log file for install progress..."
Do
{
$WindowsLogContent = Get-Content -Path "\\$computer\C$\acronis-windows_setup_$date.log" -ErrorAction SilentlyContinue
$InstallCountdownWindows += 1
Start-Sleep -Seconds 1
Write-Progress -Id 1 -Activity "Installing Acronis Windows Agent. Please wait..." -Status "Seconds elapsed: $InstallCountdownWindows"
}#end do
Until (($WindowsLogContent | Select-Object -Last 5) -like "*Logging stopped*" -and (Get-ChildItem -Path $AcronisPath -Force) -like "BackupandRecoveryMonitor.exe")
Write-Progress -Id 1 -Activity "Installing Acronis Windows Agent. Please wait..." -Completed
If ($WindowsLogContent -like "*Installation failed*")
{
Write-Host -ForegroundColor Yellow "Acronis Windows Agent was not installed on $computer. An error occurred during MSI installation check C:\acronis-windows_setup_$date.log for further troubleshooting."
"Acronis Windows Agent was not installed. An error occurred during MSI installation check C:\acronis-windows_setup_$date.log for further troubleshooting." | Out-File -FilePath "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\Acronis_Powershell_Install_$date.log" -Append
Write-Host -ForegroundColor Magenta $($WindowsLogContent | Select-Object -Last 3)
$($WindowsLogContent | Select-Object -Last 3) | Out-File -FilePath "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\Acronis_Powershell_Install_$date.log" -Append
Continue
}#end if
"`r`n"
Write-Host -ForegroundColor Yellow "Restarting Acronis services for program stability."
Reset-AcronisAgent -Computername $Computer -Credential $Credential -AcrServer $AcrServer -AcrDatabase $AcrDatabase -LocalAccount $LocalAccount -LocalPassword $LocalPassword -AcrAccount $AcrAccount -AcrPassword $AcrPassword -Verbose
"`r`n"

Write-Host -ForegroundColor Green "Acronis installed correctly on $computer on $(Get-Date)"
"Acronis installed correctly on $computer on $(Get-Date)" | Out-File -FilePath "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\Acronis_Powershell_Install_$date.log" -Append
$($CoreLogContent | Select-Object -Last 3) | Out-File -FilePath "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\Acronis_Powershell_Install_$date.log" -Append
$($WindowsLogContent | Select-Object -Last 3) | Out-File -FilePath "$env:USERPROFILE\Desktop\Acronis Powershell Install Logs\Acronis_Powershell_Install_$date.log" -Append
Start-Sleep -Seconds 5
}#end else
}#end foreach
}#end process
}#end function

#FILL OUT THE PARAMETER INFO FOR YOUR ENVIRONMENT!!!

Install-AcronisRemotely -Computername CommaSeparatedListOfComputersBeingInstalledOn -AcrServer NameOfDeviceHostingAcronisManagmentServer -AcrDatabase ActualAcronisDatabaseNameE.G.ACRONIS -LocalAccount AdminAccountForAllComputersBeingInstalledOn -LocalPassword PasswordFor`$LocalAccount -AcrAccount AccountInAcronisRemoteUsersGroupOnAcronisServer -AcrPassword PasswordFor`$AcrAccount -Path \\Path\to\share\containing\install\files -Verbose

Can all this be performed using dsc??