For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

PowerShell Setup Snapin

Problem this snippet solves:

This PowerShell script will register the iControl Snapin on 32 and 64 bit platforms.

Code :

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'";
    $installUtil = "$env:windir\Microsoft.Net\Framework${platform}\v2.0.50727\installUtil.exe";
    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..."
}
Published Mar 09, 2015
Version 1.0

1 Comment