Insert PowerCLI directory to $env:PSModulePath

Query Powershell Profile Scripts



Authors:
  • Claus Astheimer
  • Jochen Schnuerle
$profile | get-member -type noteproperty

On RHEL 7 with installed Powershell 7 LTS:

PS /root> $profile | get-member -type noteproperty

   TypeName: System.String

Name                   MemberType   Definition
----                   ----------   ----------
AllUsersAllHosts       NoteProperty string AllUsersAllHosts=/opt/microsoft/powershell/7-lts/profile.ps1
AllUsersCurrentHost    NoteProperty string AllUsersCurrentHost=/opt/microsoft/powershell/7-lts/Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts    NoteProperty string CurrentUserAllHosts=/root/.config/powershell/profile.ps1
CurrentUserCurrentHost NoteProperty string CurrentUserCurrentHost=/root/.config/powershell/Microsoft.PowerShell_profile.ps1

Create “AllUsersAllHosts” profile script if it does not exist

“AllUsersAllHosts” on RHEL 7 with Powershell 7 LTS = /opt/microsoft/powershell/7-lts/profile.ps1

Add the following 2 lines to the profile script (or another path where PowerCLI is installed):

$env:PSModulePath = $env:PSModulePath + ":/opt/fsi/portal/tools/powercli/modules"
import-module -name vmware.vimautomation.core

Restart Powershell to acvtvate and test the changes



Authors:
  • Claus Astheimer
  • Jochen Schnuerle