Wednesday, July 16, 2014

Quick one-liner to change vDisk on devices


FOR /L %A IN (28,1,60) DO (
MCLI run assigndisklocator -p disklocatorname=XenApp65Pn03 sitename=AHI storename=XenApp devicename=WSCTXAPP4%A
MCLI run removedisklocator -p disklocatorname=XenApp65Pn01 sitename=AHI storename=XenApp devicename=WSCTXAPP4%A
)


Tuesday, July 15, 2014

Call PowerShell from CMD.exe and a application-prelaunch script that logs the user off when the application is exited.

        > "%TEMP%\proc_logoff.ps1" echo Start-Sleep -s 60
       >> "%TEMP%\proc_logoff.ps1" echo $localSession = Get-ChildItem 'HKCU:\Volatile Environment' -name
       >> "%TEMP%\proc_logoff.ps1" echo $process = get-process ^| where {$_.sessionID -eq $localSession} ^| where {$_.processName -eq "MetaVision"}
       >> "%TEMP%\proc_logoff.ps1" echo if ($process -eq $null) {logoff.exe}
       >> "%TEMP%\proc_logoff.ps1" echo $process.waitforexit()
       >> "%TEMP%\proc_logoff.ps1" echo logoff.exe
powershell.exe -ExecutionPolicy Unrestricted -WindowStyle Hidden -File "%TEMP%\proc_logoff.ps1" 

I should comment this later, for now, this is the whole script.

Monday, July 14, 2014

Extend disk space on a VMWare PVS system

#############################################################################################################
#
#  By: Trentent Tye - Intel Server
#
#  Date: 2014-07-14
#
#  Comment: This script was written to extend the available free space on Citrix PVS servers.  It uses
#           a text file with the list of servers that need their disk space extended.  It assumes disk 0
#           needs extended by default because that's the only disk on a provisioned server.  Use with
#           caution against other servers.
#
#
##############################################################################################################

$executingScriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
pushd $executingScriptDirectory
cd $executingScriptDirectory

$servers = get-content serverlist.txt

foreach ($server in $servers) {
   Get-HardDisk -vm $server | Set-HardDisk -CapacityGB 40 -ResizeGuestPartition -Confirm:$false
   echo "select volume 0" | out-file  -FilePath \\$server\c$\swinst\diskpart.txt  -Encoding ASCII  -force
   echo "extend" | out-file  -FilePath \\$server\c$\swinst\diskpart.txt  -Encoding ASCII -Append  -force
   .\psexec.exe -accepteula \\$server diskpart.exe /s C:\swinst\diskpart.txt
}



########################
ServerList.txt
Server1
Server2
Server3
#######################