Forum Discussion
iControlSnapIn Problems
- Apr 26, 2017
Thanks to DeniceJ for necromancing this thread, I would have forgotten about it if I didn't get the alert
Here's the code I've been using for the last few years to register the iControlSnapIn.dll and add the snap-in to the current session
$PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition $snapinPath = "$PSScriptRoot\f5-icontrol-powershell-snapin-12_1_0\iControlSnapIn.dll" $snapinName = "iControlSnapIn" if (Get-PSSnapIn -name $snapinName -ErrorAction Ignore) { Write-Output "Verified that '$snapinName' snap-in is currently registered to this session" } else { Write-Output "The '$snapinName' snap-in is not currently registered to this session, installing assembly for this snap-in from the following path now:`n$snapinPath" $installUtil = "$env:windir\Microsoft.Net\Framework${platform}\v2.0.50727\installUtil.exe"; if ( [System.IO.File]::Exists($installUtil) ) { Set-Alias installUtil $installUtil; installUtil $snapinPath /LogToConsole=false /LogFile=; } Write-Output "The '$snapinName' snap-in assembly has been registered, adding snap-in to this session now..." Add-PSSnapIn $snapinName Add F5 iControl Library Write-Output "The '$snapinName' snap-in has been added to this session, continuing...`n" }
Note that I store the f5-icontrol-powershell-snapin-12_1_0 folder which contains the iControlSnapIn.dll in my script directory, as the script needs to run from different machines that may not have any F5 software installed.
Thanks to DeniceJ for necromancing this thread, I would have forgotten about it if I didn't get the alert
Here's the code I've been using for the last few years to register the iControlSnapIn.dll and add the snap-in to the current session
$PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
$snapinPath = "$PSScriptRoot\f5-icontrol-powershell-snapin-12_1_0\iControlSnapIn.dll"
$snapinName = "iControlSnapIn"
if (Get-PSSnapIn -name $snapinName -ErrorAction Ignore)
{
Write-Output "Verified that '$snapinName' snap-in is currently registered to this session"
}
else
{
Write-Output "The '$snapinName' snap-in is not currently registered to this session, installing assembly for this snap-in from the following path now:`n$snapinPath"
$installUtil = "$env:windir\Microsoft.Net\Framework${platform}\v2.0.50727\installUtil.exe";
if ( [System.IO.File]::Exists($installUtil) )
{
Set-Alias installUtil $installUtil;
installUtil $snapinPath /LogToConsole=false /LogFile=;
}
Write-Output "The '$snapinName' snap-in assembly has been registered, adding snap-in to this session now..."
Add-PSSnapIn $snapinName Add F5 iControl Library
Write-Output "The '$snapinName' snap-in has been added to this session, continuing...`n"
}
Note that I store the f5-icontrol-powershell-snapin-12_1_0 folder which contains the iControlSnapIn.dll in my script directory, as the script needs to run from different machines that may not have any F5 software installed.
Thanks, but my issues is that the add-pssnapin doesn't load the file. It gives me a message that it is already loaded.
What is most interesting, is that if I look in the registry at the Powershell Snapins, it is registered w/ a PSVersion of 2.0 rather than 5.1. I can hack the registry to say 5.1 in the display that shows registered snapins. But it still will not load.
I receive the following message
add-pssnapin : An item with the same key has already been added. At line:1 char:1 + add-pssnapin icontrolsnapin + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Add-PSSnapin], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.AddPSSnapinCommand
However, get-pssnapin -registered shows the module is registered.
PS C:\Program Files\F5 Networks\iControlSnapIn> Get-PSSnapin -Registered
Name : iControlSnapIn PSVersion : 2.0 Description : iControl Snap-in for F5 Device Management
If I try to remove-pssnapin icontrolsnapin, i receive a message that it is not loaded.
remove-pssnapin : No Windows PowerShell snap-ins matching the pattern 'icontrolsnapin' were found. Check the pattern and then try the command again. At line:1 char:1 + remove-pssnapin icontrolsnapin + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (icontrolsnapin:String) [Remove-PSSnapin], PSArgumentException + FullyQualifiedErrorId : NoPSSnapInsFound,Microsoft.PowerShell.Commands.RemovePSSnapinCommand
It seems to me that the old version is being "installed" even though the registry indicates that it is version 13.0.0.0 of the snapin.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com