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

Citrix Optimizer - PowerShell Task


Jake Carter

Question

I am creating a custom template. I have a script to remove profiles that works outside of the optimizer and returns valid results (inside of the Optimizer and Outside of it).

However when I run the Optimizer with this task enabled I get the following error:

 

Failed to locate HTML report. This error usually means that Powershell engine had encountered Problems.

 

C:\Temp\Image_Seal\CtxOptimizerEngine.ps1 : <params /> element is invalid for current entry. Review the definition XML
file.
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,CtxOptimizerEngine.ps1

 

Here is my Code:

 

$profiles = $null

$profiles = Get-WMIObject -class Win32_UserProfile | Where {((!$_.Special) -and ($_.LocalPath -ne "C:\Users\Administrator") -and ($_.LocalPath -ne "C:\Users\CitrixTelemetryService") -and ($_.LocalPath -ne "C:\Users\UpdatusUser"))}

if ($profiles -ne $null) {
    $profiles | Remove-WmiObject
}

$profiles = Get-WMIObject -class Win32_UserProfile | Where {((!$_.Special) -and ($_.LocalPath -ne "C:\Users\Administrator") -and ($_.LocalPath -ne "C:\Users\CitrixTelemetryService") -and ($_.LocalPath -ne "C:\Users\UpdatusUser"))}
If ($profiles -eq $null){

$Global:CTXOE_Result = $True
$Global:CTXOE_Details ="Profiles Removed Successfully"
                }
Else{
$Global:CTXOE_Result = $False
$Global:CTXOE_Details ="Profile Removal Failed!"
    }

 

If I hit the run code button here is what is returned:

CTXOE_Result: True
CTXOE_Details: Profiles Removed Successfully

 

The Optimizer Version is 2.7.0.126

 

Maybe I am missing something as I did just start working with the PowerShell capabilities within the Optimizer just today.

 

Thanks!

 

Jake

 

Link to comment

1 answer to this question

Recommended Posts

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...