Closed spuder closed 1 year ago
This is still very much needed.
Until an official chocolatey package is available, we've worked around with a chef cookbook.
default['f5-snapin']['source'] = 'https://artifact.repository.example.com/f5-icontrol-powershell-snapin-12_1_0.zip'
directory 'c:/program files/f5 networks' do
action :create
end
windows_zipfile 'c:/program files/f5 networks' do
source node['f5-snapin']['source']
not_if { ::File.exist?('c:/program files/f5 networks/iControl.dll') }
end
template 'c:/program files/f5 networks/setupSnapIn.ps1' do
source 'setupSnapin.ps1.erb'
action :create
end
powershell_script 'register snapin' do
cwd 'c:/program files/f5 networks'
code <<-EOH
./setupSnapin.ps1
EOH
action :run
end
param([switch]$force)
function Is-SnapinRegistered()
{
$registered = $false;
if ( $null -ne (Get-PSSnapIn -Registered | where { $_.Name -eq "iControlSnapIn" } ) )
{
$registered = $true;
}
$registered;
}
function Install-Snapin()
{
param(
[string]$assembly = $null
);
foreach ($platform in ("", "64") )
{
Write-Host "Registering $assembly on platform '$platform'";
if ( Test-Path "$env:windir\Microsoft.Net\Framework${platform}\v4.0.30319" )
{
Write-Host '.NET v4 present'
$installUtil = "$env:windir\Microsoft.Net\Framework${platform}\v4.0.30319\installUtil.exe";
}
ElseIf ( Test-Path "$env:windir\Microsoft.Net\Framework${platform}\v3.5" )
{
Write-Host '.NET v3.5 present'
$installUtil = "$env:windir\Microsoft.Net\Framework${platform}\v3.5\installUtil.exe";
}
ElseIf ( Test-Path "$env:windir\Microsoft.Net\Framework${platform}\v3.0" )
{
Write-Host '.NET v3.0 present'
$installUtil = "$env:windir\Microsoft.Net\Framework${platform}\v3.0\installUtil.exe";
}
ElseIf ( Test-Path "$env:windir\Microsoft.Net\Framework${platform}\v2.0.507272" )
{
Write-Host '.NET v2 present'
$installUtil = "$env:windir\Microsoft.Net\Framework${platform}\v2.0.50727\installUtil.exe";
}
Else
{
Write-Host 'Could not find any version of .NET >=2 and <=4'
Exit 1
}
if ( [System.IO.File]::Exists($installUtil) )
{
Set-Alias installUtil $installUtil;
installUtil $assembly /LogToConsole=false /LogFile=;
}
}
}
function Remove-Snapin()
{
param(
[string]$assembly = $null
);
foreach ($platform in ("", "64") )
{
Write-Host "Unregistering $assembly on platform '$platform'";
$installUtil = "$env:windir\Microsoft.Net\Framework${platform}\v2.0.50727\installUtil.exe";
if ( [System.IO.File]::Exists($installUtil) )
{
Set-Alias installUtil $installUtil;
installUtil /u $assembly /LogToConsole=false /LogFile=;
}
}
}
if ( ($force) -or !(Is-SnapinRegistered) )
{
Install-Snapin -assembly iControlSnapin.dll;
}
else
{
Write-Host "iControlSnapIn already registered..."
}
Repository Archived
It would be great to have this powershell snapin available on the chocolatey market. Installing would be as simple as
choco install icontrol
.I don't have distribution rights to publish a chocolatey package.
Here is a basic example (not complete) of what it would take to make a chocolatey package.
https://chocolatey.org/docs/create-packages
icontrol.nuspec
tools/chocolateyInstall.ps1
Then run the following commands