Shares monitoring XenDesktop power using Powershell SDK

8:51 PM
Shares monitoring XenDesktop power using Powershell SDK -

I was working on a script last night to help track actions in a power environment 10K + machine and felt forced to share a few scripts that I put together to track the actions of power in a XenDesktop environment 5.x.

for the purpose of this script is to display a real-time list of active power actions in an effort to validate the synchronization of state power between the hypervisor and XenDesktop database. I also wanted to follow because of the action of the power (admin, slow swimming, power politics, etc.), the name of the target machine, and desktop group to which it belongs. I used the ActualPriority property of the power action to identify the source of the action, and passed the name of the machine associated with Get-BrokerDesktop to identify the Office group of the machine

This the script in its current form (condensed) :.

 # Begin Script 
 # PowerShell script to monitor power measurements in a site XenDesktop 5.x # Press Ctrl + Q to stop the script itself, or Ctrl + C to stop execution 
 $ pollinginterval = 3000 ms #Polling frequency ASNPs citrix.Broker * #load the Citrix.Broker.Admin PS snap-in for (;;) {$ shares $ = null; $ Action = get-brokerhostingpoweraction -Etat waiting en route "; $ Time = Get-Date if ($ action) {foreach ($ action $ action) {$ diff = $ time - $ action.ActionStartTime; $ Elapsedsecs = "{0: N0}" -f $ diff.TotalSeconds; $ Desktop Switch = Get-BrokerDesktop -MachineName $ action.MachineName ($ action.ActualPriority) 10 {{$ actionsource = " 'restart User-driven"} 20 {$ actionsource = "launching Session"} 30 {= $ actionsource "admin"} 33 {$ actionsource = "PVD"} 40 {$ actionsource = " 'A-defilement" worker "} 50 {$ actionsource =" Power Policy "} 60 {$ actionsource =" pool Idle "}} write out "$ ($ time), UID $ ($ action.UID) $ ($ actionsource) launched $ ($ action.Action) $ ($ action.State) to $ ($ action.MachineName) in '$ (office .DesktopGroupName) '$ ($ elapsedsecs ago) seconds "}} else {Write-output" $ (time), no running of the shares of power "} if ($ host.ui.RawUi.KeyAvailable) { $ key = $ host. ui.RawUI.ReadKey ( "noecho, IncludeKeyUp") if (($ 81 key.VirtualKeyCode eq) -ET ($ key.ControlKeyState -match "LeftCtrlPressed")) {Write-host "Ctrl + Q pressed quit "; break}} Sleep Mode -MilliSeconds $ PollingInterval} 
 # Script End 

This is what the output looks like a console window:

to run the script, save the text above a .ps1 file, and run it in a Powershell console on a member of the SDC. Be sure to launch a 'Set-ExecutionPolicy Unrestricted -ExecutionPolicy "if the default execution policy block unsigned scripts. You can also direct the output to a text file (. GetRunningPowerActions.ps1> log.txt) and . use something like BareTail to display the output in real time, keeping a log of actions

This is a similar script to get the same result for the complete power of actions:

 citrix * .B ASNPs foreach ($ action get-brokerhostingpoweraction -MaxRecordCount 100 -SortBy -'ActionCompletionTime ') {if ($ action.State - not "pending" -and $ action.State -do "Started") {$ desktop = Get-BrokerDesktop switch -MachineName $ action.MachineName ($ action.ActualPriority) {{$ 10 for actionsource = " 'restart User-driven"} 20 {$ actionsource = "start session"} 30 {$ actionsource = "admin "} 33 {$ actionsource =" PVD "} 40 {$ actionsource =" 'A-defilement "worker"} 50 {$ actionsource = "Power Politics"} 60 {$ actionsource = "Pool Idle"}} write out "UID $ ($ action.UID) $ ($ actionsource) launched $ ($ action.Action) $ ($ action.State) to $ ($ action.MachineName) in '$ ($ desktop.DesktopGroupName)' with $ ( $ action.ActionCompletionTime) "}} 
Previous
Next Post »
0 Komentar