I installed the vi tookit, but i am only able to execute comand through the vmware vitoolkit and not straight to the standard powershell console. How do you enable that?
add-pssnapin VMware.VimAutomation.Core
Add this to your Powershell profile.
Add-PSSnapin -Name "VMware.VimAutomation.Core"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
And if you're new to Powershell have a look at this profile info from Microsoft.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
Thanks for your quick reply. Everything is working now
add-pssnapin VMware.VimAutomation.Core
How do I call Initialize-VIToolkitEnvironment.ps1 from the profile?
You could "dot source" it:
. "$env:PROGRAMFILES\VMware\Infrastructure\VIToolkitForWindows\Scripts\Initialize-VIToolkitEnvironment.ps1"
Thank you. I got it. I just dot-source the file:
. Initialize-VIToolkitEnvironment.ps1
Comment a few lines and done.
To avoid red error messages if it's already in the environment I've been using:
& {
$ErrorActionPreference = "silentlycontinue"
$vmwareSnap = get-pssnapin -name "VMware.VimAutomation.Core"
if (! $?) { add-pssnapin "VMware.VimAutomation.Core" }
}
I bet there's a cleaner way.
I also try to make a function to initialize the vi toolkit, so I could call it when I want to load the snapin and the initialization script but I couldn't dotsource the initialization script for the current session.