So what is special about Powershell PSC1 files?

12,316

Solution 1

PSC1 files are "PowerShell Console files." They are XML configuration files that tell PowerShell which snapins to load automatically. The other way to do that would be to call Import-Module or Add-PSSnapin in your Profile.ps1 script.

You can create your own psc1 files using Export-Console.

Solution 2

Try like this:

add-pssnapin VMware.VimAutomation.Core

. 'C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1' # dot sourcing!
Share:
12,316

Related videos on Youtube

Steven T. Cramer
Author by

Steven T. Cramer

Senior Software Architect at TimeWarp Enterprises Relationships: I have found over the years that although I love technology, relationships are what give life value. Being shown appreciation for the value you bring and being able to build genuine life long relationship are the greatest rewards one can obtain from a career. Passionate pursuit of excellence: I am not the best software engineer, I am not the best mentor, nor the best father nor the best mate. But as long as I am alive I see no reason to strive for anything other than being the best at all of these and along the way sacrificing none of my principles or character. Open and honest: True communication is the ultimate human challenge. I know that without a sincere concern for people, transmission may occur but communication will not. It is only when people have respect for each other, a firm grasp on the principles, and desire to convey a message that true communication can occur. Even then it is a challenge and those successful should cherish the accomplishment. Life growth is about learning and sharing:. The things I enjoy most in life are, learning from people I respect and admire, and sharing that knowledge with those I respect and admire and to be able to give and receive the acknowledgement of both learning and sharing.

Updated on June 04, 2022

Comments

  • Steven T. Cramer
    Steven T. Cramer almost 2 years

    On my PowerShell shortcut I have the following:

    C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -psc "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -noe -c ". \"C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\""
    

    Yet, I would prefer to add the registration of snapins and to run the init of the PowerCLI environment to my profile.

    So in my profile I add the following:

    Add-PSSnapin VMware.VimAutomation.Core
    & "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"
    

    Yet, the Get-VICommand is no longer available using this method. Why?