Coder Social home page Coder Social logo

Add vCenter User about scripts HOT 2 CLOSED

thesleepyadmin avatar thesleepyadmin commented on August 10, 2024
Add vCenter User

from scripts.

Comments (2)

DonRWettr avatar DonRWettr commented on August 10, 2024

Hey there,

I've tried myself on the issue for a bit, and maybe it works by just passing along your credentials after saving them where you're running the script from:

$CredentialPath = $PSScriptRoot + "\Credentials\" + $env:USERNAME.clixml

if (Test-Path $PSScriptRoot\Credentials == False) {
    Write-Warning "Credentials folder does not exist, creating one..."
    New-Item -Path . -Name "Credentials" -ItemType "directory"
}

if (Test-Path -Path $CredentialPath == False) {
    Write-Warning "Credentials of current user not saved yet, prompting cmdlet..."
    Get-Credential | Export-Clixml -Path $CredentialPath
}

$Credentials = Import-clixml -Path $CredentialPath
Write-Host "Credentials of current user imported"

And then of course update the connect command accordingly:

$VCStatus = connect-VIServer $VCServer -Credential $Credentials -ErrorAction SilentlyContinue -ErrorVariable ErrorProcess;

You'll need to enter your credentials the first time you run it, but after that it should run on its own.
Again, can't verify if it works or not, since I don't have access to our vCenters right now, but maybe give it a go and see how it goes.

from scripts.

TheSleepyAdmin avatar TheSleepyAdmin commented on August 10, 2024

Hi MeinhartEsrohr

Sorry didn't see this issue notification.

I have the script running against two different vCenter in linked mode and never seen the popup. I have seen the popup issue before when the certificate from vCenter is not trusted. Have you check this.

Also you could look at using New-VICredentialStoreItem to save credenital that can be a called later but it not something I can't add to the script as it different for each environment.

New-VICredentialStoreItem -User domain\username -Password Password -Host vc.domain.local -File C:\Temp\vicreds.xml

$logon = Get-ViCredentialStoreItem -File C:\Temp\vicreds.xml
Connect-VIServer -Server $logon.Host -User $logon.User -Password $logon.Password

from scripts.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.