Forum Discussion

Jeffrey_Silver1's avatar
Jeffrey_Silver1
Icon for Nimbostratus rankNimbostratus
Jan 15, 2014

Error loading windows powershell PSSnapIn

I am getting the following error. Can someone help me with this.

 

Add-PSSnapIn : Cannot load Windows PowerShell Snap-In iControlSnapIn because of the following error: The Windows PowerShell Snap-In module C:\Program Files\F5 Networks\iControlSnapIn\iControlSnapin.dll does not have required Windows PowerShell Snap-In strong name iControlSnapIn, Version=11.2.0.0, Culture=neutral, PublicKeyToken=null. At line:1 char:1 + Add-PSSnapIn iControlSnapIn + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (iControlSnapIn:String) [Add-PSSnapin], PSSnapInException + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

 

1 Reply

  • Ok, I found the answer. I have been using the following lines of code that I have seen in many PS examples:

     

    $checkSnapIn = Get-PSSnapIn iControlSnapIn -ErrorAction SilentlyContinue;  
    If ($checkSnapIn -notlike "iControlSnapIn) {Add-PSSnapIn iControlSnapIn}; 

    What I found was the the if statement, the first time through failed to perform the Add-PSSSnapIn, even though the $Get-PSSnapIn command failed to populate the variable. It appears that the first time through, the $checkSnapIn variable is actually not defined, and when the Get-PSSnapIn command fails, the $checkSnapIn variable remains not defined.

     

    To get around this (i believe new feature....) I changed the if statement as follows:

     

    If ($checkSnapIn.length  -eq 0) {Add-PSSnapIn iControlSnapIn}; 

    So, when the Get-PSSnapIn fails, it will correctly evaluate the variable as having a "0" length.