Apr 042014
 

Often when troubleshooting an issue a need arises to collect logs from multiple machines.  This is easily achieved when the number of machines is small, or known – a few servers or desktops here or there – but when it comes to analyzing logs for a large pooled-random group of desktops or several hundred computers in your organization, grabbing the files can be a pain.  Using the magic of Powershell, you can easily collect logs from as many computers as you desire in a matter of minutes.

Add-PSSnapin Citrix*
$DeliveryController = "citrixdc.contoso.local"
$vmCollection = Get-BrokerDesktop -PowerState On -AdminAddress $DeliveryController -MaxRecordCount 9999
# you can replace or repeat this with any collection you want (i.e. get-adcomputer).

$destbasePath="\\server.contoso.local\Share\XenDesktop\logcollection"
foreach($hostedDesktop in $vmCollection)
{
$vm = $_.DNSName
if(Test-Connection -Cn $vm -BufferSize 16 -Count 1 -ea 0 -quiet)
{
Write-Host "$vm is online, collecting logs"
$path="\\$vm\d$\" #Use your log location. In this case, logs are co-located logs on the write cache D: drive.
dir -Path $path -recurse -include "*.evtx","*.log" -Exclude "*vdiskcache","pagefile.sys" | %{ # Critera shown for example. If you include all, be sure you exclude vdiskcache and pagefile.sys
$destPath="$destbasePath\$vm" # The full destination path
if(!(test-path $destPath)) { mkdir $destPath } #make new folders for each VM you collect from
copy $_.pspath $destPath #Make the magic happen
}
}
}

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

(required)

(required)

This site uses Akismet to reduce spam. Learn how your comment data is processed.