Good Afternoon Experts!
We are trying to use vRA to orchestrate an action and/or workflow to export our host profiles.
What I can do.
1. I can connect to my vCenters using the Connect-viserver command
2. I can write-host to tell me which vCenter I am connected to
3. I can pull the host profile I am using to test and I can write-host to tell me that it is working.
What I cannot do
1. When I do the first step New-PSDrive -Name "I" -PSProvider FileSystem -Root $Export_directory -Credential $CREDS, I get an error that the directory I am pointing to either does not exist or is not a folder.
2. Because it is not creating that drive, the export is failing.
Below is the script I am using...minus the credentials of course
______________________________________________________
function Handler($context, $inputs)
{
$inputsString = $inputs | ConvertTo-Json -Compress
##Set PowerCLI config
Write-Host "Set PowerCLI config" Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -ParticipateInCeip:$false -Scope Session -Confirm:$false
##Connect Shared Drive for Export
$Export_directory = ''
## LOGIN INFO
$USER = ""
$PASS = ""
$PASSSecure = ConvertTo-SecureString $PASS -AsPlainText -Force
## GENERATE CREDENTIALS OBJECT (SAME AS GET-CREDENTIALS)
$CREDS = New-Object System.Management.Automation.PsCredential $USER,$PASSSecure
## MAP NETWORK DRIVE WITH ABOVE CREDENTIALS
New-PSDrive -Name "I" -PSProvider FileSystem -Root $Export_directory -Credential $CREDS
## CONNECT TO VCENTER
Write-Host "Connect to vCenter"
Connect-VIServer FQDN of vCenter -User "" -Password ""
Write-Host "What Server Am I Connected To"
Write-Host $global:defaultviserver $profile = (Get-VMHostProfile -Name ACAS )
Write-Host $profile
## Export ACAS Host Profile
Export-VMHostProfile -FilePath 'I' -Profile $profile -Force
}
Any help would be appreciated!
Also, I am new to this so it is ok to laugh at my spaghetti code!! Thanks, Derrell