Tag Archives: Powershell

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

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

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

Setting Default Mailbox Language in Powershell


This method is on a single mailbox: Set-Mailbox username -Languages “en-GB”

Continue reading