I am running PS v4. And the PSModulePath thing was (supposed to have been) fixed in this Release 3. And I do see the VMware modules in the path:
PowerCLI P:\> $env:PSModulePath \\nt_san1\users\LeoneM\My Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Module s\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\;C:\Program Files\Hewlett-Packard\PowerShell\Modules;C:\Program Files (x86)\VM ware\Infrastructure\vSphere PowerCLI\Modules On Wed, Mar 23, 2016 at 3:32 PM, Damien Solodow <[email protected]> wrote: > Couple questions. :) > What PowerShell version are you running? > What is the contents of your $env:PSModulePath? > > Some versions/installers for PowerCLI have screwed up that path which breaks > PowerCLI module auto-loading. > > > DAMIEN SOLODOW > Senior Systems Engineer > 317.447.6033 (office) > 317.447.6014 (fax) > HARRISON COLLEGE > > -----Original Message----- > From: [email protected] [mailto:[email protected]] > On Behalf Of Michael Leone > Sent: Wednesday, March 23, 2016 3:19 PM > To: [email protected] > Subject: Re: [powershell] Determining what parameters were passed to > Powershell.exe as it first executes > > On Wed, Mar 23, 2016 at 3:04 PM, Damien Solodow <[email protected]> > wrote: >> Correct, the profile will execute before the script called on the command >> line. >> If you're on PS 3.0 or higher (and really should be), there is module >> auto-loading, so some of the "import-module" stuff in the profile is likely >> redundant. > > On PS 4 ... > >> If you want to do things based on if you're running PowerCLI, I'd try this: >> if ($host.ui.rawui.WindowTitle -like '*PowerCLI*') { >> PowerCLI specific stuff here >> } >> else { >> other stuff here >> } > > > Well, unfortunately, that doesn't do it, either. As you note, the script > hasn't executed at this stage, so the VMware modules aren't > (yet) loaded, so I can't do any "PowerCLI specific stuff" yet. The command > "Connect-VIServer" did not auto-load the proper VMware module, even thought > it should have auto-loaded it, as you note.Maybe the auto-loading doesn't > work in profiles? > > I have to manually execute the environment script myself, as the 3rd line in > the script fragment, so the cmdlets are available to do the later PowerCLI > specific stuff. > > But at least I have a way to determine if I started PowerCLI or stock > PowerShell; I can work around it. > > Thanks! > > > ================================================ > Did you know you can also post and find answers on PowerShell in the forums? > http://www.myitforum.com/forums/default.asp?catApp=1 > > > ================================================ > Did you know you can also post and find answers on PowerShell in the forums? > http://www.myitforum.com/forums/default.asp?catApp=1 ================================================ Did you know you can also post and find answers on PowerShell in the forums? http://www.myitforum.com/forums/default.asp?catApp=1
