Forum Discussion
Snap-in installed but cmdlets not visible
So I have the snapin installed and have a script that starts off with this code, straight from examples here
if ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null )
{
Add-PSSnapIn iControlSnapIn
}
$success = Initialize-F5.iControl -HostName $bigip -Username $user -Password $pass
I run it the first time and everything works fine. Subsequent times I get this error:
Get-Command : The term 'iControlSnapIn' is not recognized as the name of a cmdlet, function, script file, or operable program.
The first command works and the snap-in is detected:
Name : iControlSnapIn
PSVersion : 2.0
Description : iControl Snap-in for F5 Device Management
but it won't let me call the cmdlets. Any idea why?
- That's odd. What line is the "Get-Command" error coming from? I don't see you using Get-Command in the code.
- Piers_72246NimbostratusSorry,
$success = Initialize-F5.iControl -HostName $bigip -Username $user -Password $pass
Get-Command : The term 'Initialize-F5.iControl' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:12 + Get-Command <<<< Initialize-F5.iControl + CategoryInfo : ObjectNotFound: (Initialize-F5.iControl:String) [Get-Command], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
Ok, let's start from the beginning.
First you need to run the setupSnapin.ps1 file in the "c:\program files (x86)\F5 Networks\iControlSnapin" installation directory. This will add the snapin to the registry. Maybe you missed this step...
PS C:\Program files (x86)\F5 Networks\iControlSnapin> .\setupSnapin.ps1 -force
Keep in mind that you will need run this as Administrator as it updatest the registry.
Then this command should then return the following:
PS> Get-PSSnapin -Registered iControlSnapin Name : iControlSnapIn PSVersion : 2.0 Description : iControl Snap-in for F5 Device Management
Then you'll need to add the snapin to your current runspace
PS> Add-PSSnapin iControlSnapin
Then running the Get-PSSnapin should return the snapin info:
PS> Get-PSSnapin iControlSnapin Name : iControlSnapIn PSVersion : 2.0 Description : iControl Snap-in for F5 Device Management
At this point, the snapin is loaded in the runspace and you should be able to get the exported cmdlets from the snapin:
PS> Get-Command -Module iControlSnapin CommandType Name ----------- ---- Cmdlet Add-F5.LTMPoolMember Cmdlet Add-F5.LTMVirtualServerRule ...
And the Initialize-F5.iControl cmdlet should be there too
PS> Get-Command -Module iControlSnapin Initialize-F5.iControl CommandType Name ----------- ---- Cmdlet Initialize-F5.iControl
Could you run through those steps and see where things break down.
-Joe
- Piers_72246Nimbostratus
Sorry, I wasn't clear.
I open the myscript.ps1 in powershell ISE and run it. It h runs through the code block in my first post:
if ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null ) { Add-PSSnapIn iControlSnapIn } $success = Initialize-F5.iControl -HostName $bigip -Username $user -Password $pass
and, doesn't find the snap in so it runs the Add-PSSnapIn command returns success and goes on to execute the remainder of the script.
PS C:\Windows\system32> Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"} Name : iControlSnapIn PSVersion : 2.0 Description : iControl Snap-in for F5 Device Management
However calling an F5 specific cmdlet after that doesn't work after that. Example:
PS C:\Windows\system32> Get-Command -Module iControlSnapin Initialize-F5.iControl Get-Command : The term 'Initialize-F5.iControl' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:12 + Get-Command <<<< -Module iControlSnapin Initialize-F5.iControl + CategoryInfo : ObjectNotFound: (Initialize-F5.iControl:String) [Get-Command], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
Subsequent runs of my script also fail after this because of it's dependacy on F5 cmdlets
edit: forum styling grrrrrrrr
- What does "Get-Command -Module iControlSnapin" return after you've successfully added the Snapin? If it's an empty list them something is wrong with the Snapin Install. I've been using the snapins for years now and haven't had this issue with the command prompt or ISE.
- Piers_72246NimbostratusYep, it's empty.
PS C:\Windows\system32> Get-Command -Module iControlSnapin _________________________________________________________________________________________________________________________
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