Jump to content
Welcome to our new Citrix community!
  • 0

import citrix policy fails when run from Azure DevOps with Invoke-VMScript


Janus Stampe

Question

I am trying to import citrix policies, in an automated setup, using the SDK's
The script is working fine, when run manually on the DDC, but when i run it from AzureDevOps with the Invoke-VMScript, it failes, due to missing the psdrive i assume. 

I am guessing there is some session issue, being the problem. 

The script is run with domain admin credentials, on the VM. 

and its pretty simple:
 

    Add-PSSnapin Citrix*
    Import-module 'C:\Program Files\CITRIX\Telemetry Service\TelemetryModule\Citrix.GroupPolicy.Commands.psm1'
    New-psdrive -name LocalFarmGpo -psprovider CitrixGroupPolicy -Controller localhost \
    Import-CtxGroupPolicy C:\temp\CitrixCVAD\Files\Policies\CTXPOL_ClientDrive_2012R2_Prod\
    Import-CtxGroupPolicy C:\temp\CitrixCVAD\Files\Policies\CTXPOL_2012R2_Prod\

 

The invoke script, run from the agent vm, has the credentials. 

 

#connect
Set-PowerCLIConfiguration -Scope User -InvalidCertificateAction Ignore -ParticipateInCeip $false -Confirm:$false
Connect-VIServer -Server $VMwareConfig.VMwareServer -Credential $VMcredentials
#getvmname
$VMName =Get-VM -Name $VMwareConfig.GuestMachine
try{
    $VMName | Invoke-VMScript -ScriptText 'C:\temp\citrixCVAD\12_CitrixPolicies_Config.ps1' -ScriptType Powershell -GuestCredential $SomethingSomehingCredentials
} 
catch
{

    if ($_.Exception.Message -like '*The guest operations agent could not be contacted*') {
        Write-Host "OK"
    } else {
        Write-Host "Something went wrong"
    }
    
}

 

The output i am getting is:
 

Quote

2023-12-13T09:34:13.5055116Z ScriptOutput : 
2023-12-13T09:34:13.5119640Z                Name           Used (GB)     Free (GB) Provider      Root                                               
2023-12-13T09:34:13.5121096Z                CurrentLocation
2023-12-13T09:34:13.5147491Z                ----           ---------     --------- --------      ----                                               
2023-12-13T09:34:13.5148773Z                ---------------
2023-12-13T09:34:13.5182934Z                LocalFa...                             CitrixGrou... LocalFarmGpo:\                                     
2023-12-13T09:34:13.5184297Z                               
2023-12-13T09:34:13.5185443Z                New-Item : Cannot find drive. A drive with the name 'LocalFarmGpo' does not exist.
2023-12-13T09:34:13.5187703Z                At C:\Program Files\CITRIX\Telemetry Service\TelemetryModule\Citrix.GroupPolicy.Commands.psm1:503 
2023-12-13T09:34:13.5189592Z                char:21
2023-12-13T09:34:13.5190280Z                +             $item = New-Item "$($DriveName):\$Type\$PolicyName"
2023-12-13T09:34:13.5191556Z                +                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2023-12-13T09:34:13.5193186Z                    + CategoryInfo          : ObjectNotFound: (LocalFarmGpo:String) [New-Item], DriveNotFoundException
2023-12-13T09:34:13.5195211Z                    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.NewItemCommand
2023-12-13T09:34:13.5196552Z                 
2023-12-13T09:34:13.5197652Z                Set-ItemProperty : Cannot find drive. A drive with the name 'LocalFarmGpo' does not exist.
2023-12-13T09:34:13.5199951Z                At C:\Program Files\CITRIX\Telemetry Service\TelemetryModule\Citrix.GroupPolicy.Commands.psm1:506 
2023-12-13T09:34:13.5201578Z                char:51
2023-12-13T09:34:13.5202512Z                + ... y($prop)) { Set-ItemProperty "$($DriveName):\$Type\$PolicyName" $prop ...
2023-12-13T09:34:13.5204003Z                +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2023-12-13T09:34:13.5210886Z                    + CategoryInfo          : ObjectNotFound: (LocalFarmGpo:String) [Set-ItemProperty], 
2023-12-13T09:34:13.5212278Z                DriveNotFoundException
2023-12-13T09:34:13.5213886Z                    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetItemPropertyCommand

 

Link to comment

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...