PowerCLI

 View Only
  • 1.  Powercli integration in VSCode

    Posted Jan 13, 2023 09:50 AM

    Hello there

    I have a powershell script which I currently use in Powershell ISE to log automatically into vsphere, and load some custom vsphere modules which i use

    I cannot see how to transfer this over to vscode. 

    I took my file from powershell and renamed it to Microsoft.VSCode_profile and put this in my windows powershell folder, but this doesnt work. 

    Do I put this file somewhere else, or use the settings.json for this kind of configuration?

    Thanks



  • 2.  RE: Powercli integration in VSCode

    Posted Jan 13, 2023 10:10 AM

    Not really sure what the question is I'm afraid.

    If you have code in the ISe, just save it to a file with the type .ps1.
    Then in VSCode you can open the .ps1 file.

    To use PowerShell code in VSCode you need to install the PowerShell extension in VSCode.
    That will give you Syntax highlighting and intellisense.
    See PowerShell in Visual Studio Code for more details on using PS in VSCode. 



  • 3.  RE: Powercli integration in VSCode

    Posted Jan 13, 2023 10:19 AM

    sorry the question isnt clear, let me try again LucD

     

    When i start vscode i want it to log into vsphere and load some custom modules that i regularly use for vm deployments etc.

     

    In the ISE, I have a file called Microsoft.PowerShellISE_profile.ps1 which does this for me....I just want an equivalent in vscode

    Thanks



  • 4.  RE: Powercli integration in VSCode

    Posted Jan 13, 2023 10:44 AM

    You can use $HOME\Documents\PowerShell\Microsoft.VSCode_profile.ps1
    See about_Profiles 

    But be aware that this profile only runs in the extension's Integrated Console.
    If you want to preload modules I would personally do that in one of the general PS profiles, or even better add the Import-Module in the code you are writing. That way your code doesn't depend on hidden files and becomes more portable.



  • 5.  RE: Powercli integration in VSCode

    Posted Jan 13, 2023 10:52 AM

    Great, thanks LucD