Home » script

Tag: script

Script a custom AWS AppStream image


Lets script a custom aws appstream image

A customer wanted to setup AWS AppStream 2.0 Image Automation for their AppStream image creation especially as there were situations where two or more images were potentially required including monthly updates (minimum) so they needed a repeatable, consistent solution for this.



You can only automate this so far within the current AppStream 2.0 limitations.

Creation of the image builders, the builder image itself, creation or the fleets and stacks then based on this image.

Short of joining your image builder to a domain that launches a script at computer startup – there is no immediate way to call a ‘zero touch build’ for AppStream images, and no current way to automate the Image Builder test and optimize wizard (the wizard you run to seal and snapshot the image)

Things to Consider Scripting / Adding

  • IEES Disable for all users
  • Local Timezone and Regional Settings (particularly if outside the US and your regional settings are not available for selection from the End User interface) (for example UK English and Timezone)
Set-WinSystemLocale en-gb
Set-Culture en-GB
Set-WinSystemLocale en-GB
Set-Timezone "GMT Standard Time"
  • If your images wont be domain joined then
    • Create a login script to apply user settings at ‘login’
    • If you manipulate local Group Policy (gpedit.msc) use the microsoft tool  LGPO.exe to backup and restore the settings easily
    • You can publish Windows Explorer in the Image Assistanc via a batchfile with content
cd %userprofile%\my files\temporary files -Force
start .


You can automate the image builder application injection using sqlite.exe per below

example.sql file to pass into C:\ProgramData\Amazon\Photon\PhotonAppCatalog.sqlite

INSERT INTO Applications (Name, AbsolutePath, DisplayName, IconFilePath, LaunchParameters) VALUES (“My Intranet Website”, “C:\Program Files (x86)\internet explorer\iexplorer.exe”, “Intranet”, “C:\ProgramData\Amazon\Photon\AppCatalogHelper\AppIcons\ie.png”, “https://www.myintranet.org.uk”)

Any questions or comments get in touch using the social media links at the top of the website and we will do out best to help! 😉


App-V 5 local publishing of an App-V client package

Here is a quick tip for App-V 5 local publishing of an App-V client package

After packaging an application recently, we wanted to test it locally first before adding to the App-V shared content store, or distributing it via the App-V infrastructure mode servers etc.

You may however come across some errors when trying to add and publish the appv package similar to the below.

add-appvclientpackage : Application Virtualization Service failed to complete requested operation.
Operation attempted: Retrieve Package and Version IDs From Package URL.
AppV Error Code: 0C80070002.
Error module: Streaming Manager. Internal error detail: 74F00F0C80070002.
Please consult AppV Client Event Log for more details.
At line:1 char:1
+ add-appvclientpackage “C:\admin\G&G IP v4.3.2015.49 OSL\G&G IP v4.3.2015.49 OSL. …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (:) [Add-AppvClientPackage], ClientException
+ FullyQualifiedErrorId : RetrieveGuidsFromPackageURL,Microsoft.AppV.AppvClientPowerShell.AddAppvPackage

Some things to keep in mind when publishing from a local source.

  • Run the powershell console as an administrator
  • Ensure your content is pointing to a UNC share path not a direct path (even though direct is apparently supported?)
  • Ensure the Network Service account has permission to access this local folder or path

So, instead of: add-appvclientpackage “C:\folder\ApplicationName\ApplicationName.appv”

Share it and try: add-appvclientpackage “\\server\folder\\ApplicationName\ApplicationName.appv


Full command to add a package locally, publish it and mount it:

Add-AppvClientPackage -Path ” \\server\folder\\ApplicationName\ApplicationName.appv ” | Publish-AppvClientPackage -Global | Mount-AppvClientPackage


Autoformat Citrix PVS Write Cache Drive


We wanted to Autoformat Citrix PVS Write Cache Drive of the PVS D drive (writecache) for things like Citrix logs, edgesight database. Otherwise the servers boot up first time and complain they cant create or access the pagefile.

Want the D Drive labelled with Server name so if ever they are moved or detached – its easy to identify.


Create a batchfile that does the following

diskpart.exe /s \serversharePVS_ddrive_creation.txt
shutdown.exe /r /t 001

Add this batchfile with additional logic to the regrunonce windows registry key or use Appsense EM to call the batchfile when deployed to a new machine.

Contents of PVS_DDrive_Creation (change to suit your needs)

select disk 0
create partition primary
select partition 1
format fs=ntfs Label=%computername%PVS quick
assign letter=d


Dynamically display the PVS environment detail on users desktop with BGINFO

I want all PVS servers to dynamically display their environment on the desktop when a users logs into the desktop.

This can be achieved by:

1) adding a new ‘personality’ variable to each device in PVS

2) scripting the import of the variables from the c:personality.ini file to the windows registry

3) setting BGINFO to display the registry information at each user logon.


1) Edit the properties of the Target Device > Personality Tab > and Add your variables


2) Script the import with VB and run as a computer startup script in the GPO

Set objShel = CreateObject(“WScript.Shell”)
objShel.Run “C:Progra~1CitrixProvis~1GetPer~1.exe Environment /r=HKEY_LOCAL_MACHINESOFTWAREMYCOMPANYPVSEnv”

3) Download BGINFO from sysinternals and setup the new desktop display




Recreate or Publish the Windows Printers Folder (Win7 or 2008)

The following commands will recreate or open a ‘Printers’ folder

rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder

%windir%explorer.exe /e,::{2227A280-3AEA-1069-A2DE-08002B30309D}

control.exe printers

This can be used to publish a printers folder via Citrix XenApp

%windir%explorer.exe /e,::{2227A280-3AEA-1069-A2DE-08002B30309D

PDF Converter Script

Screipt provided will change the password associated with the PDF Printer AMYUNI Documet Converter 400.

This had to be automated as our PVS environment couldnt be updated everytime we wanted to change the devices password company wide.

START SCRIPT—————————————————–

Option Explicit

‘ This VB script can be used to configure the installed printer




‘for version 4

Set PDF = CreateObject(“cdintfex.cdintfex”)

‘for version 4.5

‘Set PDF = CreateObject(“cdintfex.cdintfex.4.5”)



‘Permission Permission value

‘Enable Printing – 64 + 4

‘Enable document modification – 64 + 8

‘Enable copying text and graphics – 64 + 16

‘Enable adding and changing notes – 64 + 32

‘To combine multiple options,

‘use -64 plus the values 4, 8, 16 or 32. E.g. to enable


‘//1 = 40-bit encryption

‘//2 = 128-bit encryption

PDF.Encryption = 2

‘PDF.OwnerPassword = “owner”

PDF.UserPassword = “password”

‘MsgBox “pwd set”

‘PDF.Permissions = (-64 + 32)

‘//Apply changes


Set PDF = Nothing

‘MsgBox “done”

App-V Application refresh failure with same name

Situation: we had recently repackaged a new verson of an applicaiton and though the ucn path had changed, the APP-V name was identical.

Error: The Application Virtualization Client cannot use the OSD file specified because the GUID attribute for the CODEBASE element changed (rc 0C403B04-00001004).

Solution: under sftcmc.msc the properties of the app showed the OSD file pointing to the previous version of the published apps directory

On the server I opened the cmd prompt as ‘run as administrator’ and did the following

list all apps: sftmime query obj:app /short

Remove the application: sftmime.exe remove app:”applicationName” /complete



Batch File – Sound Alert on Folder Exist

:TestAgain CLS


“C:windowssndrec32.exe” /play /Close  “C:WINDOWSMEDIAWindows Ringin.wav”

REm Start /MIN “C:Program FilesWindows Media Playerwmplayer.exe”  “C:WINDOWSMEDIAWindows Ringin.wav” REM “%SystemRoot%system32SoundRecorder.exe” /CLOSE /PLAY “C:WINDOWSMEDIAWindows Ringin.wav”

PING -n 5 -w 2000 >NUL Rem Taskkill /IM “WMplayer.exe” /F

PING -n 5 -w 2000 >NUL GOTO TestAgain


PING -n 5 -w 4000 >NUL

GOTO TestAgain

XenApp 6.5 PVS Generalise Script 2012

Copy of script used to further ‘generalize’ our XenApp servers before cloning via PVS


REM clear event logs

wevtutil cl System

wevtutil cl Security

wevtutil cl Application

wevtutil cl Setup

wevtutil cl “Forwarded Events”


REM Stop Edgesight and Delete database

net stop RsCorSvc

net stop FirebirdServerCSMInstance

del “C:ProgramDataCitrixSystem MonitoringDataRSDATR.FDB” /q

del “D:ProgramDataCitrixSystem MonitoringDataRSDATR.FDB” /q


REM stop Appsense Services and delete JUST the machine ID

net stop “AppSense Application Manager Agent”

net stop “AppSense Client Communications Agent”

net stop “AppSense EmCoreService”

net stop “AppSense Watchdog Service”

reg delete “HKEY_LOCAL_MACHINESOFTWAREAppSense TechnologiesCommunications Agent” /v “Group ID”

reg delete “HKEY_LOCAL_MACHINESOFTWAREAppSense TechnologiesCommunications Agent” /v “Machine ID”


REM Change EnableSecuritySignature value to 0 for drive mappings to modified down level clients (Win 2000) – this setting didnt work in just GPO.

reg delete “HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservicesLanmanWorkstationParameters” /v “EnableSecuritySignature” /f

reg add “HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservicesLanmanWorkstationParameters” /v “EnableSecuritySignature” /t REG_DWORD /d 0 /f