Archive | Powershell RSS feed for this section

Find out who is using your XenApp Published Applications


Here is a quick bit of PowerShell code to list out users logged into a specific application of your choice. This works with XenApp 6.0, but would also work with newer versions : Add-PSSnapin citrix* Get-XASession -BrowserName ‘Application Name’ | Select AccountName, ServerName This will list out Active and Disconnected sessions Alternatively, here is a piece […]

Continue reading

Exporting Contacts from a Users Mailbox to a PST file


This may be of use to some of you: Prerequisites: A 32-bit Windows machine with Outlook 2003 SP2 or above and with the Exchange Tools installed also An admin account with a Mailbox attached What to do: Open the Powershell Window Run the following commands: Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin Add-MailboxPermission –Identity “Users Full Name” –User UserNameOfAdminAccount –AccessRights Fullaccess […]

Continue reading

Clear Up Windows 2008 User Profiles


This code can be used in a StartUp GPO script or as a manual script to clear out stuck profiles on a server. This probably won’t delete the entire profile of users that are in use, but I haven’t tested that yet. This will just leave the default required profiles behind. If you need any […]

Continue reading

Locating which Servers a User is Logged onto


The following code allows you to see which servers a particular user account is logged onto. The code allows you to enter the root path in AD to where your servers are and you would like to search from. It also prompts for the users name. It then goes off and searches the servers for […]

Continue reading

Working with Powershell and the Registry


This article explain how to test whether parts of the registry structure exist for a user. The following will test if a key exists in the registry: Test-path “HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles” This will return either True or False You can also do this to see if a property exists in the key as below: […]

Continue reading

Export AD Members from a Group


Start by running: Import-Module activedirectory This displays the SAMAccountNames of contents on the screen: Get-ADGroupMember -Identity “GroupName” | SELECT name,samaccountname Add this to export to a file: | Export-Csv c:\FileName.txt

Continue reading

Exchange Recurring Apointments


This is a useful command if you need to set or unset the ability to set recurring appointments in Exchangeby powershell: set-MailboxCalendarSettings -Identity “UserEmailAddress@yourdomain.com” -AllowRecurringMeetings:$true This also works using the accounts alias in place of the email address.

Continue reading

Mail Folders to another Mailbox with Powershell


This code allows you to export a folder and all contents to anothers mailbox with Powershell. This can be useful if a manager requires the contents of certain folders created by an ex-exployee. Export-Mailbox -Identity SourceUserName -IncludeFolders ‘\Inbox\_Misc’ -TargetFolder _Misc -TargetMailbox TargetUserName This needs to be run on the mail server Hope this helps  

Continue reading

Deleting Folder Contents with Powershell


Here a few methods of deleting the contents of folders with Powershell. These methods are useful for keeping servers clean and tidy and emptying users recycle bins. Clear out users recycle bin data based on SID Import-Module activedirectory [string]$recycleBinPath = ‘C:\$Recycle.Bin\’ $userSID = ((Get-ADUser chrisa).sid).value Remove-Item “$recycleBinPath$userSID” -recurse -force Delete all folders in $Recycle.bin dir […]

Continue reading

Getting a mailbox size with Powershell


Open the Exchange Management Shell and type: get-mailbox username|get-mailboxstatistics|fl totalitemsize The Output:

Continue reading