PowerCLI Errors
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
- jojohnson@digitalriver.com
- Posts: 7
- Last visit: Mon Sep 19, 2011 3:40 am
PowerCLI Errors
I'm testing PrimalScript 2011 with PowerShell and specifically PowerCLI. I have added Add-PSSnapin -Name "vmware.vimautomation.core" to the profile.ps1 file and it is showing up in auto-completion and the Object Browser.However, whenever I run the script (by clicking on the Debug Script arrow or hitting F5), none of the PowerCLI cmdLets are being recognized. Below is just an example but all PowerCLI commands are reporting an Error.Am I missing something?ERROR: The term 'Disconnect-VIServer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a pERROR: ath was included, verify that the path is correct and try again.ERROR: At C:UsersxxxxxxDocuments_ESX_ScriptsFQDN_VM_List1.ps1:12 char:20ERROR: + Disconnect-VIServer <<<< -Server $hosts -Confirm:$false -ForceERROR: + CategoryInfo : ObjectNotFound: (Disconnect-VIServer:String) [], CommandNotFoundExceptionERROR: + FullyQualifiedErrorId : CommandNotFoundException
- Alexander Riedel
- Posts: 8478
- Last visit: Tue Mar 26, 2024 8:52 am
- Been upvoted: 37 times
PowerCLI Errors
Add the add-pssnapin to the PrimalScript.profile.ps1
profile in your [My Documents]WindowsPowerShell folder.
However, as a best practice, for a script you should not rely on any specific profile setting and add the required add-pssnapin or import-module statements to your script as required.
Alexander Riedel2011-09-16 11:34:30
profile in your [My Documents]WindowsPowerShell folder.
However, as a best practice, for a script you should not rely on any specific profile setting and add the required add-pssnapin or import-module statements to your script as required.
Alexander Riedel2011-09-16 11:34:30
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- jojohnson@digitalriver.com
- Posts: 7
- Last visit: Mon Sep 19, 2011 3:40 am
PowerCLI Errors
Hi Alexander and thanks for your input.However, as noted in my post, I already have the add-pssnapin statement added to that file and I still am not able to execute powercli cmdlets.
- Alexander Riedel
- Posts: 8478
- Last visit: Tue Mar 26, 2024 8:52 am
- Been upvoted: 37 times
PowerCLI Errors
You wrote "profile.ps1" and I referred to "PrimalScript.profile.ps1" Can you verify you have the statement in both?
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- jojohnson@digitalriver.com
- Posts: 7
- Last visit: Mon Sep 19, 2011 3:40 am
PowerCLI Errors
Ah, ok. Sorry about that.I only saw PrimalScript.profile.ps1 in that directory. I don't see a profile.ps1 file anywhere.
- Alexander Riedel
- Posts: 8478
- Last visit: Tue Mar 26, 2024 8:52 am
- Been upvoted: 37 times
PowerCLI Errors
Try "Run in shell" (Ctrl+Alt+F5) and see if that runs.
It is also possible that he snapin is platform specific, are you on a 64 bit OS? If so, make sure the platform selector is set accordingly.
It is also possible that he snapin is platform specific, are you on a 64 bit OS? If so, make sure the platform selector is set accordingly.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- jojohnson@digitalriver.com
- Posts: 7
- Last visit: Mon Sep 19, 2011 3:40 am
PowerCLI Errors
The Run in Shell works. I'm running windows 7 64 bit with the platform selector on 64 bit. Just to be sure, I set it to 32 bit and tried running from within PrimalScript and I get the same results - commands not recognized.Again though, it does run successfully when doing a Ctrl+Alt_F5.Thanks again for your quick response.
- Alexander Riedel
- Posts: 8478
- Last visit: Tue Mar 26, 2024 8:52 am
- Been upvoted: 37 times
PowerCLI Errors
Ok, that means the snapin is loaded in "some" profile.
Try creating the "profile.ps1" file and just adding that line there.
These are the potential profile locations:
http://msdn.microsoft.com/en-us/library ... s.85).aspx
Check where your snapin is loaded from.
Try creating the "profile.ps1" file and just adding that line there.
These are the potential profile locations:
http://msdn.microsoft.com/en-us/library ... s.85).aspx
Check where your snapin is loaded from.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- jojohnson@digitalriver.com
- Posts: 7
- Last visit: Mon Sep 19, 2011 3:40 am
PowerCLI Errors
Okay, it looks like there's a problem with my powershell profile. That link you provided had me run the command test-path $profileand that returned false. So, I created it via the instructions on the page and I'll just keep poking at it untilI can get it to work. Thanks again for all your help.
- Alexander Riedel
- Posts: 8478
- Last visit: Tue Mar 26, 2024 8:52 am
- Been upvoted: 37 times
PowerCLI Errors
Ok, please let me know if you need anything.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.