PowerCLI

 View Only
  • 1.  Error while trying get-* commands:

    Posted 12 days ago

    I have a powercli on linux. I've been using it can years now but today its getting an error while trying to run get-* commands. I don't know what changed. I can connect-viserver just fine.

    The error reads:

    Get-Datacenter: 6/2/2025 3:34:01 PM    Get-Datacenter        Could not find item /root/.local.

    Get-vm also does the same thing. That folder does exist and I can use cd /root/.local while in powershell and it works. All the modules live in that area, so if it was permissions then I would also expect connect-viserver to also fail. But maybe there still is.

    I swear I've seen this once before, but I'm struggling to remember how it was fixed.

    And it appears other modules are having the same issue, but I thought to come here first since other people may have seen that before.

    Thanks.



  • 2.  RE: Error while trying get-* commands:

    Posted 11 days ago

    Some thoughts from other posts with similar issue:

    1. https://community.broadcom.com/vmware-cloud-foundation/discussion/azure-hybrid-worker-fails-new-vm-powercli#bm53a7e4ea-45dc-46b3-968e-21b49d8fb7a8

    The workaround was to change the working directory to " cd 'C:\temp' "
    It might be similar in your case since you can run some commands and navigate to /root/.local
    After running the Connect-VIServer command, you can check your current working directory by using $PWD or Get-Location. I believe you should see /root or /home/user - if not, you can test and try by running Set-Location /root then re-run Get-Datacenter..

    2. https://community.broadcom.com/vmware-cloud-foundation/discussion/powercli-script-runs-fine-normally-fails-when-called-by-apcupsd-linux

    The workaround here (2) was to set the HOME environment variable to " /root "
    Before changing anything check if the $HOME env variable is returning " /root "





  • 3.  RE: Error while trying get-* commands:

    Posted 11 days ago

    Thank you! Those posts you linked helped jog my memory and allowed me to continue.