Export and Import user assignments from one Citrix RemotePC to another

$srcRemotePC = ‘DomainName\65TELW19’$destRemotePC = ‘DomainName\65TELW20’Get-BrokerUser -PrivateDesktopUid (get-BrokerPrivateDesktop -MachineName $srcRemotePC ).Uid | | %{ if($_.Upn -ne “”) {Add-BrokerUser -Machine $destRemotePC -Name $_.Upn}}

VMware View Reset DesktopVM via Powershell

Problem: Can’t reset multiple VMs at one time via admin portal​ page based on session duration. View PowerCLI snippt to reset non responding machines what are stuck in disconnected state for more than a 24 hrs [code language=”powershell”] Get-RemoteSession -State Disconnected | ? {$_.duration -like "*day*"} | % {Get-DesktopVM -Name $_.DNSName.Split(".")[0] | Send-VMReset} [/code] View …

XenApp 6x – Export Application list with Published Servers

Making report more pretty:open csv with excel and perform replace CTRL + H, Find “, ” Replace with hold the ALT key down and then press 010 on the number pad.ref – http://www.exceldashboardtemplates.com/how-to-find-and-replace-a-hard-return-in-an-excel-spreadsheet/

Powershell Format Operator (-f)

Padding Prefix PS C:\Users\User> 1..10 | % { “{0:d2}” -f $_} 01 02 03 04 05 06 07 08 09 10 Space Padding PS C:\Users\User> 1..10 | % { “{0,5}” -f $_} 1 2 3 4 5 6 7 8 9 10 Number of decimal places PS C:\Users\User> 1..10 | % { “{0:n2}” -f $_} …

Powershell Snippet – Retrieve Citrix Endpoint Name from WFAPI

[code language=”powershell”] $code = @’ using System; using System.Runtime.InteropServices; namespace WFAPI { public enum WF_INFO_CLASS { WFVersion, // OSVERSIONINFO WFInitialProgram, WFWorkingDirectory, WFOEMId, WFSessionId, WFUserName, WFWinStationName, WFDomainName, WFConnectState, WFClientBuildNumber, WFClientName, WFClientDirectory, WFClientProductId, WFClientHardwareId, WFClientAddress, WFClientDisplay, WFClientCache, WFClientDrives, WFICABufferLength, WFLicenseEnabler, RESERVED2, WFApplicationName, WFVersionEx, WFClientInfo, WFUserInfo, WFAppInfo, WFClientLatency, WFSessionTime, WFLicensingModel } public class Program { [DllImport("wfapi.dll", CharSet=CharSet.Unicode,SetLastError=true)] public …

Powershell Snippets – Create local windows user and set password to never expire

[code language=”powershell”] [ADSI]$server = "WinNT://localhost" $LocalUser = $server.Create("User", "localuser") $LocalUser.SetPassword("localuser") $ADS_UF_DONT_EXPIRE_PASSWD = 0x10000 $LocalUser.userflags = $LocalUser.userflags[0] -bor $ADS_UF_DONT_EXPIRE_PASSWD $LocalUser.SetInfo() [/code]

Powershell Snippet – check for isAdmin?

[code language=”powershell”] $isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") if (-NOT $isAdmin) { Write-Error "You must run this script as an Administrator." return } [/code]

WordPress Appliance - Powered by TurnKey Linux