Force User to Change Password a day before their password expires

[code language=”powershell” title=”Powershell code snippet”] Get-ADUser -Filter ‘(enabled -eq $true) -and ((passwordneverexpires -eq $false) -and (pwdlastset -ne 0 ))’ -properties MsDS-UserPasswordExpiryTimeComputed | sort-object name | select-object Name,sAmAccountName,@{Name="PasswordExpiry";Expression={(([datetime]::fromfiletime(($_."MsDS-UserPasswordExpiryTimeComputed"))))}} | % { if(($_.PasswordExpiry -ne $null) -and ((($_.PasswordExpiry – (Get-Date)).Days) -le 1)) { Set-ADUser $_.Name -ChangePasswordAtLogon $true } } [/code] Schedule task on AD [code language=”powershell” title=”Complete Powershell …

Disconnect ICA session from inside

[code language=”csharp” title=”C# .Net”] /******************************************************************** * Citrix Server SDK WFAPI Component * Author: Siva Mulpuru * The following code invokes the WFDisconnectSession in WFAPI.dll * Works on XenDesktop and Xenapp ICA session **********************************************************************/ using System; using System.ComponentModel; using System.Runtime.InteropServices; namespace ICA_Disconnect { class Program { const int CurrentSession = -1; static readonly IntPtr CurrentServer = …

LockWorkstation using Powershell and pInvoke

[code language=”powershell” title=”Powershell Code”] $signature = @’ [DllImport("user32.dll", SetLastError = true)] public static extern bool LockWorkStation(); ‘@ Add-Type -MemberDefinition $signature -Name CustomName -Namespace CustomNamespace -PassThru [CustomNamespace.CustomName]::Lockworkstation() [/code] Notes Keyword PUBLIC is a must, or else wont be able to call the native function. Unlike variables, Add-Type cant be changed once created in a powershell session. …

Delete shortcut pointing to a specific URL

There will be cases where some users are asked to test a dev/training webapp. Few of these users tend to create shortcuts/bookmark to the dev/training webapp and still keep using the dev even after the webapp was rolled to production. Desktop guys to rescue to clean out these shortcuts or bookmarks 🙂 [code language=”css” title=”Powershell …

SetDefaultPrinter using Pinvoke and Powershell

[code language=”powershell” wraplines=”false” collapse=”false”] $code = @’ using System; using System.Runtime.InteropServices; namespace ChangeDefaultPrinter { public class Program { [DllImport("Winspool.drv", CharSet=CharSet.Auto, SetLastError=true)] private static extern bool SetDefaultPrinter(string printerName); public static bool Run(string PrinterName) { bool default_result = SetDefaultPrinter(PrinterName); return default_result; } } } ‘@ cls Add-Type -TypeDefinition $code -Language CSharp #Set Default Printer – for network …

Client side XENAPP Session enumeration and selective logoff based on XenApp Server using ICA Client Object (WFICALib)

In my previous post i used AutoIt script to achieve this and now finally figured out to do it using ICA Client Object (WFICALib) [code language=”powershell” title=”PowerShell Script”] #the following keys need to be set on 32bit machine; for x64 use wow6432node. #HKLM\Software\Citrix\ICA Client\CCM\AllowLiveMonitoring=1 (DWORD 32) #HKLM\Software\Citrix\ICA Client\CCM\AllowSimulationAPI=1 (DWORD 32) #Use Program Files (x86) for …

Copy AD Members/Users from one Group to another using Powershell

The following script will Add the users from Group_A to Group_B only when the user doesn’t exist on Group_B and Group_C [code language=”powershell” gutter=”true” highlight=”4,7″ light=”true” title=”PowerShell Code”] Import-Module ActiveDirectory $Group_BUsers = Get-ADGroup Group_B -properties members | Select-Object members | % { $_.Members} $Group_CUsers = Get-ADGroup Group_C -properties members | Select-Object members | % { …

Renew IP on Machines Remotely with Powershell Invoke-Command

Import-Module activedirectory $XDMachines = Get-ADComputer -LDAPFilter “(name=*)”-SearchBase “OU=XenDesktop-VMs,OU=WorkStations,DC=mulpuru,DC=local” foreach ($XDMachine in $XDMachines) { if(Test-Connection -ComputerName $XDMachine.Name -Quiet -Count 1) { Invoke-Command -ComputerName $XDMachine.Name -ScriptBlock { ipconfig /renew} } }

Applying HDX Policy's based on Access Gateway Connection

The following article illustrates how to apply certain policies (eg: disable access to local drive, printers, clipboard etc..) for users connecting from home (through Citrix Netscaler / Access Gateway) Step 1 Ensure xendesktop controllers configured to trust requests sent to the Citrix XML service. This can be done by executing the following powershell command on …

WordPress Appliance - Powered by TurnKey Linux