Automation

 View Only
  • 1.  Unable to run Save-PowerCLI

    Posted Jun 14, 2019 12:16 PM

    It's probably easy solution, but Save-PowerCLI.ps1 does nothing when I attempt to download.

    Obtaining Specific PowerCLI Versions from the PowerShell Gallery - VMware PowerCLI Blog - VMware Blogs

    Running the script, there's no output. I understand only basics of PS.

    PS C:\Installs\PowerCLI> .\Save-PowerCLI -RequiredVersion '10.2.0.9372002' -Path .\Downloads\

    Security warning
    Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your
    computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
    message. Do you want to run C:\Installs\PowerCLI\Save-PowerCLI.ps1?
    [D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): R
    PS C:\Installs\PowerCLI>

    Running Save-PowerCLI without parameters returns the same.

    I'm on Win10.

    PS C:\Installs\PowerCLI> $PSVersionTable

    Name                           Value
    ----                           -----
    PSVersion                      5.1.17763.316
    PSEdition                      Desktop
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    BuildVersion                   10.0.17763.316
    CLRVersion                     4.0.30319.42000
    WSManStackVersion              3.0
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1

    ModuleType Version    Name                                ExportedCommands

    ---------- -------    ----                                ----------------

    Script     2.1.4      PowerShellGet                       {Find-Command, Find-DSCResource, Find-Module, Find-RoleCap...

    PS C:\Installs\PowerCLI> $env:PSModulePath

    X:\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\Intel\

    I would appreciate any suggestions. LMK if other details required.

    David.



  • 2.  RE: Unable to run Save-PowerCLI

    Posted Jun 14, 2019 07:22 PM

    Did you store the function from the blog post in a .ps1 file? For example savePowerCLI.ps1.
    Did you then dot-source that .ps1 file

    . .\savePowerCLI.ps1

    Now the function is 'known' to the PS engine, and you can call it.

    Just type at the PS prompt

    Save-PowerCLI -RequiredVersion '10.2.0.9372002' -Path .\Downloads\ -Confirm:$false

    Does that work?



  • 3.  RE: Unable to run Save-PowerCLI

    Posted Jul 08, 2019 01:19 PM

    Hi. Sorry, I don't seem to have received an email update and just remembered to check for replies.

    Yes, I had dot sourced, but I tried again just now, including recreating the ps1 and it still doesn't do anything (returns immediately).

    PS C:\Installs\PowerCLI> cd .\Download-10.2.0.9372002\
    PS C:\Installs\PowerCLI\Download-10.2.0.9372002> dir
    PS C:\Installs\PowerCLI\Download-10.2.0.9372002> cd ..
    PS C:\Installs\PowerCLI> . .\Save-PowerCLI.ps1
    PS C:\Installs\PowerCLI> .\Save-PowerCLI.ps1 -RequiredVersion '10.2.0.9372002' -Path .\Download-10.2.0.9372002 -Confirm:$false

    PS C:\Installs\PowerCLI>

    PS C:\Installs\PowerCLI> cd .\Download-10.2.0.9372002\

    PS C:\Installs\PowerCLI\Download-10.2.0.9372002> dir

    PS C:\Installs\PowerCLI\Download-10.2.0.9372002>

    I've attached the script, but it is just a copy from the blog.



  • 4.  RE: Unable to run Save-PowerCLI
    Best Answer

    Posted Jul 08, 2019 01:38 PM

    After you dot-source the .ps1 file, you should call the function, not the .ps1 file.

    At the PS prompt do

    PS:> Save-PowerCLI -Path .\Download-10.2.0.9372002 -RequiredVersion '10.2.0.9372002'

    ---------------------------------------------------------------------------------------------------------

    Was it helpful? Let us know by completing this short survey here.



  • 5.  RE: Unable to run Save-PowerCLI

    Posted Jul 08, 2019 02:34 PM

    Thank you, working!

    PS C:\Users\djohnson> dir C:\Installs\PowerCLI\                                                                        
                                                                                                                                Directory: C:\Installs\PowerCLI                                                                                                                                                                                                                                                                                                                                     Mode                LastWriteTime         Length Name                                                                   ----                -------------         ------ ----                                                                   d-----       08/07/2019     14:00                Download-10.2.0.9372002                                                -a----       08/07/2019     13:57           7499 Save-PowerCLI.ps1                                                                                                                                                                             
    PS C:\Users\djohnson> . C:\Installs\PowerCLI\Save-PowerCLI.ps1                                                          PS C:\Users\djohnson> Save-PowerCLI -Path C:\Installs\PowerCLI\Download-10.2.0.9372002 -RequiredVersion '10.2.0.9372002'
                                                                                                                            PS C:\Users\djohnson> dir C:\Installs\PowerCLI\Download-10.2.0.9372002\                                                

        Directory: C:\Installs\PowerCLI\Download-10.2.0.9372002


    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    d-----       08/07/2019     15:15                VMware.DeployAutomation
    d-----       08/07/2019     15:15                VMware.ImageBuilder
    d-----       08/07/2019     15:15                VMware.PowerCLI
    d-----       08/07/2019     15:22                VMware.Vim
    d-----       08/07/2019     15:23                VMware.VimAutomation.Cis.Core
    d-----       08/07/2019     15:23                VMware.VimAutomation.Cloud
    d-----       08/07/2019     15:22                VMware.VimAutomation.Common
    d-----       08/07/2019     15:23                VMware.VimAutomation.Core
    d-----       08/07/2019     15:15                VMware.VimAutomation.HA
    d-----       08/07/2019     15:22                VMware.VimAutomation.HorizonView
    d-----       08/07/2019     15:22                VMware.VimAutomation.License
    d-----       08/07/2019     15:17                VMware.VimAutomation.Nsxt
    d-----       08/07/2019     15:15                VMware.VimAutomation.PCloud
    d-----       08/07/2019     15:22                VMware.VimAutomation.Sdk
    d-----       08/07/2019     15:19                VMware.VimAutomation.Srm
    d-----       08/07/2019     15:20                VMware.VimAutomation.Storage
    d-----       08/07/2019     15:21                VMware.VimAutomation.StorageUtility
    d-----       08/07/2019     15:23                VMware.VimAutomation.Vds
    d-----       08/07/2019     15:18                VMware.VimAutomation.Vmc
    d-----       08/07/2019     15:15                VMware.VimAutomation.vROps
    d-----       08/07/2019     15:15                VMware.VumAutomation

    PS C:\Users\djohnson> dir C:\Installs\PowerCLI\Download-10.2.0.9372002\VMware.DeployAutomation\                        

        Directory: C:\Installs\PowerCLI\Download-10.2.0.9372002\VMware.DeployAutomation


    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    d-----       08/07/2019     15:15                6.7.0.8250345