cancel
Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.

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..."
}
Comments
Rborunda
Nimbostratus
Nimbostratus

Is there a place where I can download the snapim from?

Version history
Last update:
‎09-Mar-2015 11:39
Updated by:
Contributors